Cleaned up snake/camel case inconsistencies, added parameter for gauss kernel size
This commit is contained in:
parent
d00cd2945b
commit
0d619a22f8
@ -1,9 +1,9 @@
|
|||||||
#include "input.h"
|
#include "input.h"
|
||||||
|
|
||||||
Input::Input(int video_height, int video_width) : cap(0), video_height(video_height), video_width(video_width)
|
Input::Input(int videoHeight, int videoWidth) : cap(0), videoHeight(videoHeight), videoWidth(videoWidth)
|
||||||
{
|
{
|
||||||
this->cap.set(CAP_PROP_FRAME_HEIGHT, video_height);
|
this->cap.set(CAP_PROP_FRAME_HEIGHT, videoHeight);
|
||||||
this->cap.set(CAP_PROP_FRAME_WIDTH, video_width);
|
this->cap.set(CAP_PROP_FRAME_WIDTH, videoWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
Input::~Input()
|
Input::~Input()
|
||||||
|
@ -17,9 +17,9 @@ private:
|
|||||||
VideoCapture cap;
|
VideoCapture cap;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int video_height;
|
int videoHeight;
|
||||||
int video_width;
|
int videoWidth;
|
||||||
Input(int video_height, int video_width);
|
Input(int videoHeight, int videoWidth);
|
||||||
Input() = delete;
|
Input() = delete;
|
||||||
~Input();
|
~Input();
|
||||||
Mat readFile(String filePath);
|
Mat readFile(String filePath);
|
||||||
|
@ -8,15 +8,17 @@ Processing::~Processing()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Mat Processing::calculate_binaray(Mat& inputPicture, int thresholdValue)
|
void Processing::processImage(Mat& inputPicture, int thresholdValue, int gaussKernelSize)
|
||||||
{
|
{
|
||||||
//Mat &outputPicture;
|
//Idea here is: Processing module consists of two methods:
|
||||||
|
// One (this) to do all kinds of stuff to the picture (grayscale conversion, threshold, gauss etc etc)
|
||||||
|
// And one (the other one) to segment the lines.
|
||||||
|
// No return value here as the input is passed by reference -> directly modified.
|
||||||
cvtColor(inputPicture, inputPicture, COLOR_BGR2GRAY);
|
cvtColor(inputPicture, inputPicture, COLOR_BGR2GRAY);
|
||||||
threshold(inputPicture, inputPicture, thresholdValue, 255, THRESH_BINARY);
|
threshold(inputPicture, inputPicture, thresholdValue, 255, THRESH_BINARY);
|
||||||
return inputPicture;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<LFRLine> Processing::calculate_line_segments(const Mat& inputPicture)
|
std::vector<LFRLine> Processing::calculateLineSegments(const Mat& inputPicture)
|
||||||
{
|
{
|
||||||
return std::vector<LFRLine>();
|
return std::vector<LFRLine>();
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ public:
|
|||||||
// End und Anfangspunkt analysieren und Winkel und Ausrichtung der Linie extrahieren (Abstand des untersten Punktes von der Mitte)
|
// End und Anfangspunkt analysieren und Winkel und Ausrichtung der Linie extrahieren (Abstand des untersten Punktes von der Mitte)
|
||||||
~Processing();
|
~Processing();
|
||||||
|
|
||||||
Mat calculate_binaray(Mat& inputPicture, int thresholdValue);
|
void processImage(Mat& inputPicture, int thresholdValue, int gaussKernelSize);
|
||||||
|
|
||||||
std::vector<LFRLine> calculate_line_segments(const Mat& inputPicture);
|
std::vector<LFRLine> calculateLineSegments(const Mat& inputPicture);
|
||||||
};
|
};
|
@ -6,11 +6,12 @@ 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);
|
||||||
|
|
||||||
const int threshold_binary = 110;
|
const int thresholdBinary = 110;
|
||||||
const int video_height = 240;
|
const int videoHeight = 240;
|
||||||
const int video_width = 320;
|
const int videoWidth = 320;
|
||||||
|
const int gaussKernelSize = 5;
|
||||||
|
|
||||||
LFR lfr(video_height, video_width, threshold_binary);
|
LFR lfr(videoHeight, videoWidth, thresholdBinary, gaussKernelSize);
|
||||||
lfr.startLoop();
|
lfr.startLoop();
|
||||||
//To end the video stream, write any char in the console.
|
//To end the video stream, write any char in the console.
|
||||||
char a;
|
char a;
|
||||||
|
12
lfr.cpp
12
lfr.cpp
@ -1,12 +1,12 @@
|
|||||||
#include "lfr.h"
|
#include "lfr.h"
|
||||||
|
|
||||||
const int threshold_binary = 110;
|
|
||||||
|
|
||||||
LFR::LFR(int video_height, int video_width, int threshold_binary)
|
LFR::LFR(int videoHeight, int videoWidth, int thresholdBinary, int gaussKernelSize)
|
||||||
: iAmLooping(false), input(video_height, video_width), processing(), controlModule(), interpreter(), intersectionHandler()
|
: iAmLooping(false), input(videoHeight, videoWidth), processing(), controlModule(), interpreter(), intersectionHandler()
|
||||||
{
|
{
|
||||||
this->iAmLooping = false;
|
this->iAmLooping = false;
|
||||||
this->threshold_binary = threshold_binary;
|
this->thresholdBinary = thresholdBinary;
|
||||||
|
this->gaussKernelSize = gaussKernelSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
LFR::~LFR()
|
LFR::~LFR()
|
||||||
@ -23,8 +23,8 @@ void LFR::loop()
|
|||||||
while(iAmLooping)
|
while(iAmLooping)
|
||||||
{
|
{
|
||||||
Mat image = input.readWebcam();
|
Mat image = input.readWebcam();
|
||||||
processing.calculate_binaray(image, this->threshold_binary);
|
processing.processImage(image, this->thresholdBinary, this->gaussKernelSize);
|
||||||
std::vector<LFRLine> lines = processing.calculate_line_segments(image);
|
std::vector<LFRLine> lines = processing.calculateLineSegments(image);
|
||||||
imshow("Display window", image);
|
imshow("Display window", image);
|
||||||
char c = (char)waitKey(1);
|
char c = (char)waitKey(1);
|
||||||
}
|
}
|
||||||
|
5
lfr.h
5
lfr.h
@ -25,12 +25,13 @@ class LFR
|
|||||||
volatile bool iAmLooping;
|
volatile bool iAmLooping;
|
||||||
void loop();
|
void loop();
|
||||||
thread loopThread;
|
thread loopThread;
|
||||||
int threshold_binary;
|
int thresholdBinary;
|
||||||
|
int gaussKernelSize;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
LFR() = delete;
|
LFR() = delete;
|
||||||
LFR(int video_height, int video_width, int threshold_binary);
|
LFR(int videoHeight, int videoWidth, int thresholdBinary, int gaussKernelSize);
|
||||||
~LFR();
|
~LFR();
|
||||||
|
|
||||||
void startLoop();
|
void startLoop();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user