|
123456789101112131415161718192021222324252627282930313233343536373839404142 |
- #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;
- }
|