Kantendetection und Liniendetection
This commit is contained in:
@@ -8,15 +8,49 @@ 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 thresholdValue, int gaussKernelSize)
|
||||
{
|
||||
//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.
|
||||
vector<Vec4i> lines;
|
||||
|
||||
|
||||
cvtColor(inputPicture, inputPicture, COLOR_BGR2GRAY);
|
||||
threshold(inputPicture, inputPicture, thresholdValue, 255, THRESH_BINARY);
|
||||
GaussianBlur(inputPicture, inputPicture, Size(gaussKernelSize, gaussKernelSize), 0);
|
||||
|
||||
Canny(inputPicture, inputPicture, 50, 200, 3);
|
||||
|
||||
HoughLinesP(inputPicture, lines, 1, CV_PI/180, 150, 0, 0);
|
||||
//Draw lines
|
||||
for( size_t i = 0; i < lines.size(); i++ )
|
||||
{
|
||||
line( inputPicture, Point(lines[i][0], lines[i][1]),
|
||||
Point( lines[i][2], lines[i][3]), Scalar(0,0,255), 3, 8 );
|
||||
}
|
||||
|
||||
imshow("Result", inputPicture);
|
||||
waitKey(0);
|
||||
destroyWindow("Result");
|
||||
|
||||
for( size_t i = 0; i < lines.size(); i++ )
|
||||
{
|
||||
line( inputPicture, Point(lines[i][0], lines[i][1]),
|
||||
Point( lines[i][2], lines[i][3]), Scalar(0,0,255), 3, 8 );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::vector<LFRLine> Processing::calculateLineSegments(const Mat& inputPicture)
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#include <iostream>
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include <utils.h>
|
||||
#include <vector>
|
||||
|
||||
using namespace cv;
|
||||
using namespace std;
|
||||
|
||||
class Processing
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user