|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- #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.readFile("C:\\Line-Following-Robot\\Test_data");
- Mat processedImage = image;
- processing.processImage(processedImage, this->thresholdBinary, this->gaussKernelSize);
- std::vector<Vec4i> lines = processing.calculateLineSegments(processedImage);
- 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;
- }
|