Getting rid of all the hard coded constants
This commit is contained in:
parent
cd3b613b0a
commit
d00cd2945b
@ -1,12 +1,9 @@
|
|||||||
#include "input.h"
|
#include "input.h"
|
||||||
|
|
||||||
Input::Input(/* args */) : cap(0)
|
Input::Input(int video_height, int video_width) : cap(0), video_height(video_height), video_width(video_width)
|
||||||
{
|
{
|
||||||
const int VID_HEIGHT = 240;
|
this->cap.set(CAP_PROP_FRAME_HEIGHT, video_height);
|
||||||
const int VID_WIDTH = 320;
|
this->cap.set(CAP_PROP_FRAME_WIDTH, video_width);
|
||||||
|
|
||||||
this->cap.set(CAP_PROP_FRAME_HEIGHT, VID_HEIGHT);
|
|
||||||
this->cap.set(CAP_PROP_FRAME_WIDTH, VID_WIDTH);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Input::~Input()
|
Input::~Input()
|
||||||
|
@ -17,7 +17,10 @@ private:
|
|||||||
VideoCapture cap;
|
VideoCapture cap;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Input(/* args */);
|
int video_height;
|
||||||
|
int video_width;
|
||||||
|
Input(int video_height, int video_width);
|
||||||
|
Input() = delete;
|
||||||
~Input();
|
~Input();
|
||||||
Mat readFile(String filePath);
|
Mat readFile(String filePath);
|
||||||
Mat readWebcam();
|
Mat readWebcam();
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include "lfr.h"
|
#include "lfr.h"
|
||||||
|
|
||||||
#include <opencv2/core/utils/logger.hpp>
|
#include <opencv2/core/utils/logger.hpp>
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
@ -7,8 +6,13 @@ int main(void)
|
|||||||
//Disable opencv logging messages
|
//Disable opencv logging messages
|
||||||
cv::utils::logging::setLogLevel(cv::utils::logging::LOG_LEVEL_WARNING);
|
cv::utils::logging::setLogLevel(cv::utils::logging::LOG_LEVEL_WARNING);
|
||||||
|
|
||||||
LFR lfr;
|
const int threshold_binary = 110;
|
||||||
|
const int video_height = 240;
|
||||||
|
const int video_width = 320;
|
||||||
|
|
||||||
|
LFR lfr(video_height, video_width, threshold_binary);
|
||||||
lfr.startLoop();
|
lfr.startLoop();
|
||||||
|
//To end the video stream, write any char in the console.
|
||||||
char a;
|
char a;
|
||||||
std::cin >> a;
|
std::cin >> a;
|
||||||
lfr.endLoop();
|
lfr.endLoop();
|
||||||
|
8
lfr.cpp
8
lfr.cpp
@ -2,8 +2,11 @@
|
|||||||
|
|
||||||
const int threshold_binary = 110;
|
const int threshold_binary = 110;
|
||||||
|
|
||||||
LFR::LFR() : iAmLooping(false), input(), processing(), controlModule(), interpreter(), intersectionHandler()
|
LFR::LFR(int video_height, int video_width, int threshold_binary)
|
||||||
|
: iAmLooping(false), input(video_height, video_width), processing(), controlModule(), interpreter(), intersectionHandler()
|
||||||
{
|
{
|
||||||
|
this->iAmLooping = false;
|
||||||
|
this->threshold_binary = threshold_binary;
|
||||||
}
|
}
|
||||||
|
|
||||||
LFR::~LFR()
|
LFR::~LFR()
|
||||||
@ -20,7 +23,8 @@ void LFR::loop()
|
|||||||
while(iAmLooping)
|
while(iAmLooping)
|
||||||
{
|
{
|
||||||
Mat image = input.readWebcam();
|
Mat image = input.readWebcam();
|
||||||
processing.calculate_binaray(image, threshold_binary);
|
processing.calculate_binaray(image, this->threshold_binary);
|
||||||
|
std::vector<LFRLine> lines = processing.calculate_line_segments(image);
|
||||||
imshow("Display window", image);
|
imshow("Display window", image);
|
||||||
char c = (char)waitKey(1);
|
char c = (char)waitKey(1);
|
||||||
}
|
}
|
||||||
|
4
lfr.h
4
lfr.h
@ -25,10 +25,12 @@ class LFR
|
|||||||
volatile bool iAmLooping;
|
volatile bool iAmLooping;
|
||||||
void loop();
|
void loop();
|
||||||
thread loopThread;
|
thread loopThread;
|
||||||
|
int threshold_binary;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
LFR();
|
LFR() = delete;
|
||||||
|
LFR(int video_height, int video_width, int threshold_binary);
|
||||||
~LFR();
|
~LFR();
|
||||||
|
|
||||||
void startLoop();
|
void startLoop();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user