split lfr in cpp and h file

This commit is contained in:
Tim Zeuner 2022-11-03 09:23:30 +01:00
parent cbb147c6fa
commit d952629b39
2 changed files with 68 additions and 22 deletions

60
lfr.cpp
View File

@ -1,29 +1,45 @@
#include <iostream>
#include <opencv2/opencv.hpp>
#include <input.h>
#include <processing.h>
#include <control_module.h>
#include <interpreter.h>
#include <intersection_handler.h>
using namespace cv;
#include "lfr.h"
const int threshold_binary = 110;
LFR::LFR() : iAmLooping(false), input(), processing(), controlModule(), interpreter(), intersectionHandler()
{
}
LFR::~LFR()
{
}
void LFR::loop()
{
//Give it 10 loops while async processing is not supported.
//while(iAmLooping)
for(int i = 0; i < 3; i++)
{
Mat image = input.readWebcam();
processing.calculate_binaray(image, threshold_binary);
imshow("Display window", image);
waitKey(0);
}
iAmLooping = false;
}
void LFR::startLoop()
{
this->loop();
}
void LFR::endLoop()
{
std::cout<<"The loop has been started. You may not dare to tell it to stop.";
}
int main(void)
{
//Set up
Input input;
Processing processing;
ControlModule controleModule;
Interpreter interpreter;
IntersectionHandler intersectionHandler;
//Mat image1 = input.readFile("C:\\Line-Following-Robot\\Test_data\\*.jpeg");
Mat image1 = input.readWebcam();
processing.calculate_binaray(image1, threshold_binary);
imshow("Display window", image1);
waitKey(0);
LFR lfr;
lfr.startLoop();
}

30
lfr.h Normal file
View File

@ -0,0 +1,30 @@
#include <iostream>
#include <opencv2/opencv.hpp>
#include <input.h>
#include <processing.h>
#include <control_module.h>
#include <interpreter.h>
#include <intersection_handler.h>
using namespace cv;
class LFR
{
Input input;
Processing processing;
ControlModule controlModule;
Interpreter interpreter;
IntersectionHandler intersectionHandler;
bool iAmLooping;
void loop();
public:
LFR();
~LFR();
void startLoop();
void endLoop();
};