#include <iostream>
#include <opencv.hpp>
using namespace std;
using namespace cv;
int main(int argc, char** argv)
{
Mat image, imageShow;
Mat imageOR = imread("HTCPump.jpg");
imageShow = imageOR.clone();
cvtColor(imageOR, image, CV_BGR2GRAY);
if (image.empty())
{
return -1;
}
// Create LSD detector
Ptr<LineSegmentDetector> lsd = createLineSegmentDetector();
vector<Vec4f> lines_lsd;
lines_lsd.clear();
for (int run_count = 0; run_count < 10; run_count++) {
lsd->detect(image, lines_lsd);
}
// Show found lines with LSD
Mat line_image_lsd(image);
lsd->drawSegments(line_image_lsd, lines_lsd);
imshow("LSD result", line_image_lsd);
// Show found lines with FLD
waitKey();
return 0;
}
IPOL Journal · LSD: a Line Segment Detector
LSD: a Line Segment Detector and source code