diff --git a/Processing/processing.cpp b/Processing/processing.cpp index a8f3056..c7bc1f3 100644 --- a/Processing/processing.cpp +++ b/Processing/processing.cpp @@ -17,16 +17,16 @@ static double angle( Point pt1, Point pt2, Point pt0 ) return (dx1*dx2 + dy1*dy2)/sqrt((dx1*dx1 + dy1*dy1)*(dx2*dx2 + dy2*dy2) + 1e-10); } -void Processing::processImage(Mat& inputPicture, int thresholdValue, int gaussKernelSize) +void Processing::processImage(Mat& inputPicture, int thresholdBinary, int gaussKernelSize, int thresholdCanny1, int thresholdCanny2, int apertureSizeCanny) { //Idea here is: Processing module consists of two methods: // One (this) to do all kinds of stuff to the picture (grayscale conversion, threshold, gauss etc etc) // And one (the other one) to segment the lines. // No return value here as the input is passed by reference -> directly modified. cvtColor(inputPicture, inputPicture, COLOR_BGR2GRAY); - threshold(inputPicture, inputPicture, thresholdValue, 255, THRESH_BINARY); + threshold(inputPicture, inputPicture, thresholdBinary, 255, THRESH_BINARY); GaussianBlur(inputPicture, inputPicture, Size(gaussKernelSize, gaussKernelSize), 0); - Canny(inputPicture, inputPicture, 50, 100, 3); + Canny(inputPicture, inputPicture, thresholdCanny1, thresholdCanny2, apertureSizeCanny); } std::vector Processing::calculateLineSegments(const Mat& inputPicture) diff --git a/Processing/processing.h b/Processing/processing.h index 09092b7..bad9aae 100644 --- a/Processing/processing.h +++ b/Processing/processing.h @@ -19,7 +19,7 @@ public: // End und Anfangspunkt analysieren und Winkel und Ausrichtung der Linie extrahieren (Abstand des untersten Punktes von der Mitte) ~Processing(); - void processImage(Mat& inputPicture, int thresholdValue, int gaussKernelSize); + void processImage(Mat& inputPicture, int thresholdBinary, int gaussKernelSize, int thresholdCanny1, int thresholdCanny2, int apertureSizeCanny); std::vector calculateLineSegments(const Mat& inputPicture); }; \ No newline at end of file diff --git a/Spielwiese/spielwiese.cpp b/Spielwiese/spielwiese.cpp index fe0be59..dbd4843 100644 --- a/Spielwiese/spielwiese.cpp +++ b/Spielwiese/spielwiese.cpp @@ -18,6 +18,9 @@ int main(void) const int videoHeight = 720; const int videoWidth = 960; const int gaussKernelSize = 21; + const int thresholdCanny1 = 50; + const int thresholdCanny2 = 100; + const int apertureSizeCanny = 3; @@ -29,7 +32,7 @@ int main(void) { Mat image = input.readFile("Der\\Pfad\\zum\\Input\\Bilder\\Ordner\\auf\\deinem\\System"); Mat processedImage = image; - processing.processImage(processedImage, thresholdBinary, gaussKernelSize); + processing.processImage(processedImage, thresholdBinary, gaussKernelSize, thresholdCanny1, thresholdCanny2 ,apertureSizeCanny); std::vector lines = processing.calculateLineSegments(processedImage); for( size_t i = 0; i < lines.size(); i++ ) { diff --git a/autonomous_mode_main.cpp b/autonomous_mode_main.cpp index bfa2604..5fcb8c5 100644 --- a/autonomous_mode_main.cpp +++ b/autonomous_mode_main.cpp @@ -10,8 +10,11 @@ int main(void) const int videoHeight = 240; const int videoWidth = 320; const int gaussKernelSize = 21; + const int thresholdCanny1 = 50; + const int thresholdCanny2 = 100; + const int apertureSizeCanny = 3; - LFR lfr(videoHeight, videoWidth, thresholdBinary, gaussKernelSize); + LFR lfr(videoHeight, videoWidth, thresholdBinary, gaussKernelSize, thresholdCanny1, thresholdCanny2, apertureSizeCanny); lfr.startLoop(); //To end the video stream, write any char in the console. char a; diff --git a/lfr.cpp b/lfr.cpp index c3f4484..45b1058 100644 --- a/lfr.cpp +++ b/lfr.cpp @@ -1,12 +1,15 @@ #include "lfr.h" -LFR::LFR(int videoHeight, int videoWidth, int thresholdBinary, int gaussKernelSize) +LFR::LFR(int videoHeight, int videoWidth, int thresholdBinary, int gaussKernelSize, int thresholdCanny1, int thresholdCanny2, int apertureSizeCanny) : iAmLooping(false), input(videoHeight, videoWidth), processing(), controlModule(), interpreter(), intersectionHandler() { this->iAmLooping = false; this->thresholdBinary = thresholdBinary; this->gaussKernelSize = gaussKernelSize; + this->thresholdCanny1 = thresholdCanny1; + this->thresholdCanny2 = thresholdCanny2; + this->apertureSizeCanny = apertureSizeCanny; } LFR::~LFR() @@ -23,7 +26,7 @@ void LFR::loop() while(iAmLooping) { Mat image = input.readWebcam(); - processing.processImage(image, this->thresholdBinary, this->gaussKernelSize); + processing.processImage(image, this->thresholdBinary, this->gaussKernelSize, this->thresholdCanny1, thresholdCanny2, this->apertureSizeCanny); std::vector lines = processing.calculateLineSegments(image); for( size_t i = 0; i < lines.size(); i++ ) { diff --git a/lfr.h b/lfr.h index 5daf4ca..acbb0b5 100644 --- a/lfr.h +++ b/lfr.h @@ -27,11 +27,14 @@ class LFR thread loopThread; int thresholdBinary; int gaussKernelSize; + int thresholdCanny1; + int thresholdCanny2; + int apertureSizeCanny; public: LFR() = delete; - LFR(int videoHeight, int videoWidth, int thresholdBinary, int gaussKernelSize); + LFR(int videoHeight, int videoWidth, int thresholdBinary, int gaussKernelSize, int thresholdCanny1, int thresholdCanny2, int apertureSizeCanny); ~LFR(); void startLoop();