Added the Communication Module to the repo.
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
find_package( OpenCV REQUIRED )
|
||||
include_directories( ${OpenCV_INCLUDE_DIRS} )
|
||||
include_directories( ${Utils_SOURCE_DIRS})
|
||||
|
||||
link_directories(${Utils_SOURCE_DIRS})
|
||||
|
||||
add_library(Processing processing.cpp)
|
||||
set_target_properties(Processing PROPERTIES VERSION ${PROJECT_VERSION})
|
||||
target_include_directories(Processing PRIVATE .)
|
||||
|
||||
target_link_libraries( Processing ${OpenCV_LIBS} Utils)
|
||||
|
||||
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
|
||||
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
|
||||
include(CPack)
|
||||
@@ -0,0 +1,42 @@
|
||||
#include "processing.h"
|
||||
|
||||
Processing::Processing(/* args */)
|
||||
{
|
||||
}
|
||||
|
||||
Processing::~Processing()
|
||||
{
|
||||
}
|
||||
|
||||
static double angle( Point pt1, Point pt2, Point pt0 )
|
||||
{
|
||||
double dx1 = pt1.x - pt0.x;
|
||||
double dy1 = pt1.y - pt0.y;
|
||||
double dx2 = pt2.x - pt0.x;
|
||||
double dy2 = pt2.y - pt0.y;
|
||||
return (dx1*dx2 + dy1*dy2)/sqrt((dx1*dx1 + dy1*dy1)*(dx2*dx2 + dy2*dy2) + 1e-10);
|
||||
}
|
||||
|
||||
void Processing::processImage(Mat& inputPicture, int thresholdBinary, int gaussKernelSize, int thresholdCanny1, int thresholdCanny2, int apertureSizeCanny)
|
||||
{
|
||||
//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);
|
||||
threshold(inputPicture, inputPicture, thresholdBinary, 255, THRESH_BINARY);
|
||||
GaussianBlur(inputPicture, inputPicture, Size(gaussKernelSize, gaussKernelSize), 0);
|
||||
Canny(inputPicture, inputPicture, thresholdCanny1, thresholdCanny2, apertureSizeCanny);
|
||||
}
|
||||
|
||||
std::vector<Vec4i> Processing::calculateLineSegments(const Mat& inputPicture)
|
||||
{
|
||||
//See following link
|
||||
//https://stackoverflow.com/questions/45322630/how-to-detect-lines-in-opencv
|
||||
vector<Vec4i> lines;
|
||||
VectorOfLines linesInVectors;
|
||||
HoughLinesP(inputPicture, lines, 1, CV_PI/360, 150, 0, 250);
|
||||
//lines = linesInVectors.findMiddleLine(lines);
|
||||
|
||||
return lines;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#include <iostream>
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include <utils.h>
|
||||
#include <vector>
|
||||
|
||||
using namespace cv;
|
||||
using namespace std;
|
||||
|
||||
class Processing
|
||||
{
|
||||
private:
|
||||
/* data */
|
||||
public:
|
||||
Processing(/* args */);
|
||||
// To do:
|
||||
// Binärbild
|
||||
// Linien finden (HoughLinesP())
|
||||
// Entscheidung über wie viele Linien und welche Art von Linien erkannt werden (abknickende Linien)
|
||||
// End und Anfangspunkt analysieren und Winkel und Ausrichtung der Linie extrahieren (Abstand des untersten Punktes von der Mitte)
|
||||
~Processing();
|
||||
|
||||
void processImage(Mat& inputPicture, int thresholdBinary, int gaussKernelSize, int thresholdCanny1, int thresholdCanny2, int apertureSizeCanny);
|
||||
|
||||
std::vector<Vec4i> calculateLineSegments(const Mat& inputPicture);
|
||||
};
|
||||
Reference in New Issue
Block a user