- #include "lfr.h"
-
-
- 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()
- {
- if(iAmLooping)
- {
- this->endLoop();
- }
- }
-
- void LFR::loop()
- {
- namedWindow("Display window");
- while(iAmLooping)
- {
- Mat image = input.readWebcam();
- processing.processImage(image, this->thresholdBinary, this->gaussKernelSize, this->thresholdCanny1, thresholdCanny2, this->apertureSizeCanny);
- std::vector<Vec4i> lines = processing.calculateLineSegments(image);
- 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();
- }
-
- void LFR::startLoop()
- {
- iAmLooping = true;
- this->loopThread=thread(&LFR::loop, this);
- }
-
- void LFR::endLoop()
- {
- iAmLooping = false;
- this->loopThread.join();
- return;
- }
|