From 7937c78326fc96fccecbe29ba5e47d0552f92b2b Mon Sep 17 00:00:00 2001 From: TimZnr Date: Wed, 16 Nov 2022 10:44:06 +0100 Subject: [PATCH] Added subdirectory "Spielwiese" to test stuff without scrambling up our code. --- CMakeLists.txt | 1 + Spielwiese/CMakeLists.txt | 37 ++++++++++++++++++++++++++++++++ Spielwiese/spielwiese.cpp | 44 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 Spielwiese/CMakeLists.txt create mode 100644 Spielwiese/spielwiese.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index b1c52cc..8ca822e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,7 @@ add_subdirectory(ControlModule) add_subdirectory(Interpreter) add_subdirectory(IntersectionHandler) add_subdirectory(Utils) +add_subdirectory(Spielwiese) target_include_directories(Input PRIVATE .) target_include_directories(Processing PRIVATE .) diff --git a/Spielwiese/CMakeLists.txt b/Spielwiese/CMakeLists.txt new file mode 100644 index 0000000..0f37e8b --- /dev/null +++ b/Spielwiese/CMakeLists.txt @@ -0,0 +1,37 @@ +set(THREADS_PREFER_PTHREAD_FLAG ON) + +find_package( OpenCV REQUIRED ) +find_package(Threads REQUIRED) + +include_directories( ${OpenCV_INCLUDE_DIRS} + ${Input_SOURCE_DIRS} + ${Processing_SOURCE_DIRS} + ${ControlModule_SOURCE_DIRS} + ${Interpreter_SOURCE_DIRS} + ${IntersectionHandler_SOURCE_DIRS} + ${Utils_SOURCE_DIRS} +) + +link_directories( ${Input_SOURCE_DIRS} + ${Processing_SOURCE_DIRS} + ${ControlModule_SOURCE_DIRS} + ${Interpreter_SOURCE_DIRS} + ${IntersectionHandler_SOURCE_DIRS} + ${Utils_SOURCE_DIRS} +) + + +target_include_directories(Input PRIVATE .) +target_include_directories(Processing PRIVATE .) +target_include_directories(ControlModule PRIVATE .) +target_include_directories(Interpreter PRIVATE .) +target_include_directories(IntersectionHandler PRIVATE .) +target_include_directories(Utils PRIVATE .) + +add_executable(spielwiese spielwiese.cpp) + +target_link_libraries( spielwiese ${OpenCV_LIBS} Input Processing ControlModule Interpreter IntersectionHandler Utils Threads::Threads) + +set(CPACK_PROJECT_NAME ${PROJECT_NAME}) +set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) +include(CPack) diff --git a/Spielwiese/spielwiese.cpp b/Spielwiese/spielwiese.cpp new file mode 100644 index 0000000..aed77df --- /dev/null +++ b/Spielwiese/spielwiese.cpp @@ -0,0 +1,44 @@ +#include +#include + +#include + +#include +#include +#include +#include +#include + +int main(void) +{ + //Disable opencv logging messages + cv::utils::logging::setLogLevel(cv::utils::logging::LOG_LEVEL_WARNING); + + const int thresholdBinary = 140; + const int videoHeight = 240; + const int videoWidth = 320; + const int gaussKernelSize = 21; + + + + Input input(videoHeight, videoWidth); + Processing processing; + + namedWindow("Display window"); + while(true) + { + Mat image = input.readFile("Der//Pfad//zum//Input//Bilder//Ordner//auf//deinem//System"); + Mat processedImage = image; + processing.processImage(processedImage, thresholdBinary, gaussKernelSize); + std::vector lines = processing.calculateLineSegments(processedImage); + for( size_t i = 0; i < lines.size(); i++ ) + { + line( image, Point(lines[i][0], lines[i][1]), + Point( lines[i][2], lines[i][3]), (0,0,255), 1, 8 ); + } + imshow("Display window", image); + char c = (char)waitKey(1); + } + destroyWindow("Display window"); + input.freeWebcam(); +} \ No newline at end of file