Browse Source

Cleaned up snake/camel case inconsistencies, added parameter for gauss kernel size

pull/1/head
Tim Zeuner 1 year ago
parent
commit
0d619a22f8
7 changed files with 28 additions and 24 deletions
  1. 3
    3
      Input/input.cpp
  2. 3
    3
      Input/input.h
  3. 6
    4
      Processing/processing.cpp
  4. 2
    2
      Processing/processing.h
  5. 5
    4
      autonomous_mode_main.cpp
  6. 6
    6
      lfr.cpp
  7. 3
    2
      lfr.h

+ 3
- 3
Input/input.cpp View File

#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_WIDTH, video_width);
this->cap.set(CAP_PROP_FRAME_HEIGHT, videoHeight);
this->cap.set(CAP_PROP_FRAME_WIDTH, videoWidth);
} }


Input::~Input() Input::~Input()

+ 3
- 3
Input/input.h View File

VideoCapture cap; VideoCapture cap;


public: public:
int video_height;
int video_width;
Input(int video_height, int video_width);
int videoHeight;
int videoWidth;
Input(int videoHeight, int videoWidth);
Input() = delete; Input() = delete;
~Input(); ~Input();
Mat readFile(String filePath); Mat readFile(String filePath);

+ 6
- 4
Processing/processing.cpp View File

{ {
} }


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>();
} }

+ 2
- 2
Processing/processing.h View File

// 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);
}; };

+ 5
- 4
autonomous_mode_main.cpp View File

//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 video_height = 240;
const int video_width = 320;
const int thresholdBinary = 110;
const int videoHeight = 240;
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;

+ 6
- 6
lfr.cpp View File

#include "lfr.h" #include "lfr.h"


const int threshold_binary = 110;


LFR::LFR(int video_height, int video_width, int threshold_binary)
: iAmLooping(false), input(video_height, video_width), processing(), controlModule(), interpreter(), intersectionHandler()
LFR::LFR(int videoHeight, int videoWidth, int thresholdBinary, int gaussKernelSize)
: 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()
while(iAmLooping) while(iAmLooping)
{ {
Mat image = input.readWebcam(); Mat image = input.readWebcam();
processing.calculate_binaray(image, this->threshold_binary);
std::vector<LFRLine> lines = processing.calculate_line_segments(image);
processing.processImage(image, this->thresholdBinary, this->gaussKernelSize);
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);
} }

+ 3
- 2
lfr.h View File

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…
Cancel
Save