An example using the FastLineDetector
#include <iostream>
int main(int argc, char** argv)
{
std::string in;
cv::CommandLineParser parser(argc, argv,
"{@input|../samples/data/corridor.jpg|input image}{help h||show help message}");
{
return 0;
}
in = parser.
get<
string>(
"@input");
if( image.empty() )
{
return -1;
}
vector<Vec4f> lines_lsd;
int length_threshold = 10;
float distance_threshold = 1.41421356f;
double canny_th1 = 50.0;
double canny_th2 = 50.0;
int canny_aperture_size = 3;
bool do_merge = false;
distance_threshold, canny_th1, canny_th2, canny_aperture_size,
do_merge);
vector<Vec4f> lines_fld;
for(int run_count = 0; run_count < 10; run_count++) {
lines_lsd.clear();
lsd->detect(image, lines_lsd);
double duration_ms_lsd = double(
getTickCount() - start_lsd) * 1000 / freq;
std::cout << "Elapsed time for LSD: " << duration_ms_lsd << " ms." << std::endl;
lines_fld.clear();
fld->detect(image, lines_fld);
double duration_ms = double(
getTickCount() - start) * 1000 / freq;
std::cout << "Ealpsed time for FLD " << duration_ms << " ms." << std::endl;
}
Mat line_image_lsd(image);
lsd->drawSegments(line_image_lsd, lines_lsd);
imshow(
"LSD result", line_image_lsd);
Mat line_image_fld(image);
fld->drawSegments(line_image_fld, lines_fld);
imshow(
"FLD result", line_image_fld);
return 0;
}