54 lines
1.5 KiB
C++
Raw Normal View History

2022-11-03 09:23:30 +01:00
#include "lfr.h"
2022-11-10 14:41:27 +01:00
2022-10-30 20:01:47 +01:00
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()
2022-11-03 09:23:30 +01:00
{
this->iAmLooping = false;
this->thresholdBinary = thresholdBinary;
this->gaussKernelSize = gaussKernelSize;
this->thresholdCanny1 = thresholdCanny1;
this->thresholdCanny2 = thresholdCanny2;
this->apertureSizeCanny = apertureSizeCanny;
2022-11-03 09:23:30 +01:00
}
2022-11-03 09:23:30 +01:00
LFR::~LFR()
2022-10-30 20:01:47 +01:00
{
2022-11-03 11:18:18 +01:00
if(iAmLooping)
{
this->endLoop();
}
2022-11-03 09:23:30 +01:00
}
void LFR::loop()
{
2022-11-10 14:41:27 +01:00
namedWindow("Display window");
while(iAmLooping)
2022-11-03 09:23:30 +01:00
{
2022-11-16 11:09:35 +01:00
Mat image = input.readWebcam();
processing.processImage(image, this->thresholdBinary, this->gaussKernelSize, this->thresholdCanny1, thresholdCanny2, this->apertureSizeCanny);
2022-11-16 11:09:35 +01:00
std::vector<Vec4i> lines = processing.calculateLineSegments(image);
2022-11-15 17:33:20 +01:00
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 );
}
2022-11-03 09:23:30 +01:00
imshow("Display window", image);
2022-11-10 14:41:27 +01:00
char c = (char)waitKey(1);
2022-11-03 09:23:30 +01:00
}
2022-11-10 14:41:27 +01:00
destroyWindow("Display window");
input.freeWebcam();
2022-11-03 09:23:30 +01:00
}
2022-11-03 08:54:35 +01:00
2022-11-10 14:41:27 +01:00
void LFR::startLoop()
2022-11-03 09:23:30 +01:00
{
2022-11-03 11:18:18 +01:00
iAmLooping = true;
2022-11-10 14:41:27 +01:00
this->loopThread=thread(&LFR::loop, this);
2022-11-03 09:23:30 +01:00
}
void LFR::endLoop()
{
2022-11-03 11:18:18 +01:00
iAmLooping = false;
2022-11-10 14:41:27 +01:00
this->loopThread.join();
2022-11-03 11:18:18 +01:00
return;
2022-10-30 20:01:47 +01:00
}