2022-11-03 09:23:30 +01:00
|
|
|
#include "lfr.h"
|
2022-11-10 14:41:27 +01:00
|
|
|
|
2022-11-03 09:23:30 +01:00
|
|
|
const int threshold_binary = 110;
|
2022-10-30 20:01:47 +01:00
|
|
|
|
2022-11-03 09:23:30 +01:00
|
|
|
LFR::LFR() : iAmLooping(false), input(), processing(), controlModule(), interpreter(), intersectionHandler()
|
|
|
|
{
|
|
|
|
}
|
2022-11-01 16:34:51 +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
|
|
|
{
|
|
|
|
Mat image = input.readWebcam();
|
|
|
|
processing.calculate_binaray(image, threshold_binary);
|
|
|
|
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
|
|
|
}
|