Skip to content

Commit d2ae2d9

Browse files
authored
Update fld_lines.cpp
1 parent a71820e commit d2ae2d9

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

modules/ximgproc/samples/fld_lines.cpp

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ using namespace cv::ximgproc;
1111

1212
int main(int argc, char** argv)
1313
{
14-
std::string in;
15-
cv::CommandLineParser parser(argc, argv, "{@input|../samples/data/corridor.jpg|input image}{help h||show help message}");
14+
string in;
15+
CommandLineParser parser(argc, argv, "{@input|corridor.jpg|input image}{help h||show help message}");
1616
if (parser.has("help"))
1717
{
1818
parser.printMessage();
1919
return 0;
2020
}
21-
in = parser.get<string>("@input");
21+
in = samples::findFile(parser.get<string>("@input"));
2222

2323
Mat image = imread(in, IMREAD_GRAYSCALE);
2424

@@ -50,27 +50,43 @@ int main(int argc, char** argv)
5050
Ptr<FastLineDetector> fld = createFastLineDetector(length_threshold,
5151
distance_threshold, canny_th1, canny_th2, canny_aperture_size,
5252
do_merge);
53-
vector<Vec4f> lines_fld;
53+
vector<Vec4f> lines;
5454

5555
// Because of some CPU's power strategy, it seems that the first running of
5656
// an algorithm takes much longer. So here we run the algorithm 10 times
5757
// to see the algorithm's processing time with sufficiently warmed-up
5858
// CPU performance.
59-
for(int run_count = 0; run_count < 10; run_count++) {
59+
for (int run_count = 0; run_count < 10; run_count++) {
6060
double freq = getTickFrequency();
61-
lines_fld.clear();
61+
lines.clear();
6262
int64 start = getTickCount();
6363
// Detect the lines with FLD
64-
fld->detect(image, lines_fld);
64+
fld->detect(image, lines);
6565
double duration_ms = double(getTickCount() - start) * 1000 / freq;
66-
std::cout << "Elapsed time for FLD " << duration_ms << " ms." << std::endl;
66+
cout << "Elapsed time for FLD " << duration_ms << " ms." << endl;
6767
}
6868

6969
// Show found lines with FLD
7070
Mat line_image_fld(image);
71-
fld->drawSegments(line_image_fld, lines_fld);
71+
fld->drawSegments(line_image_fld, lines);
7272
imshow("FLD result", line_image_fld);
7373

74+
waitKey(1);
75+
76+
Ptr<EdgeDrawing> ed = createEdgeDrawing();
77+
78+
for (int run_count = 0; run_count < 10; run_count++) {
79+
double freq = getTickFrequency();
80+
lines.clear();
81+
int64 start = getTickCount();
82+
// Detect the lines with EdgeDrawing
83+
ed->getLines(image, lines);
84+
double duration_ms = double(getTickCount() - start) * 1000 / freq;
85+
cout << "Elapsed time for EdgeDrawing " << duration_ms << " ms." << endl;
86+
}
87+
Mat line_image_ed(image);
88+
fld->drawSegments(line_image_ed, lines);
89+
imshow("EdgeDrawing result", line_image_ed);
7490
waitKey();
7591
return 0;
7692
}

0 commit comments

Comments
 (0)