4
#include "opencv2/core/core.hpp"
5
#include "opencv2/core/utility.hpp"
6
#include "opencv2/imgproc/imgproc.hpp"
7
#include "opencv2/imgcodecs.hpp"
8
#include "opencv2/highgui/highgui.hpp"
13
int main(int argc, char** argv)
16
cv::CommandLineParser parser(argc, argv, "{@input|../data/building.jpg|input image}{help h||show help message}");
17
if (parser.has("help"))
19
parser.printMessage();
22
in = parser.get<string>("@input");
24
Mat image = imread(in, IMREAD_GRAYSCALE);
27
Canny(image, image, 50, 200, 3); // Apply canny edge
30
// Create and LSD detector with standard or no refinement.
32
Ptr<LineSegmentDetector> ls = createLineSegmentDetector(LSD_REFINE_STD);
34
Ptr<LineSegmentDetector> ls = createLineSegmentDetector(LSD_REFINE_NONE);
37
double start = double(getTickCount());
38
vector<Vec4f> lines_std;
41
ls->detect(image, lines_std);
43
double duration_ms = (double(getTickCount()) - start) * 1000 / getTickFrequency();
44
std::cout << "It took " << duration_ms << " ms." << std::endl;
47
Mat drawnLines(image);
48
ls->drawSegments(drawnLines, lines_std);
49
imshow("Standard refinement", drawnLines);