#include "lfr.h" LFR::LFR(int videoHeight, int videoWidth, int thresholdBinary, int gaussKernelSize) : iAmLooping(false), input(videoHeight, videoWidth), processing(), controlModule(), interpreter(), intersectionHandler() { this->iAmLooping = false; this->thresholdBinary = thresholdBinary; this->gaussKernelSize = gaussKernelSize; } 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); std::vector 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; }