@@ -11,14 +11,14 @@ using namespace cv::ximgproc;
11
11
12
12
int main (int argc, char ** argv)
13
13
{
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}" );
16
16
if (parser.has (" help" ))
17
17
{
18
18
parser.printMessage ();
19
19
return 0 ;
20
20
}
21
- in = parser.get <string>(" @input" );
21
+ in = samples::findFile ( parser.get <string>(" @input" ) );
22
22
23
23
Mat image = imread (in, IMREAD_GRAYSCALE);
24
24
@@ -50,27 +50,43 @@ int main(int argc, char** argv)
50
50
Ptr<FastLineDetector> fld = createFastLineDetector (length_threshold,
51
51
distance_threshold, canny_th1, canny_th2, canny_aperture_size,
52
52
do_merge);
53
- vector<Vec4f> lines_fld ;
53
+ vector<Vec4f> lines ;
54
54
55
55
// Because of some CPU's power strategy, it seems that the first running of
56
56
// an algorithm takes much longer. So here we run the algorithm 10 times
57
57
// to see the algorithm's processing time with sufficiently warmed-up
58
58
// CPU performance.
59
- for (int run_count = 0 ; run_count < 10 ; run_count++) {
59
+ for (int run_count = 0 ; run_count < 10 ; run_count++) {
60
60
double freq = getTickFrequency ();
61
- lines_fld .clear ();
61
+ lines .clear ();
62
62
int64 start = getTickCount ();
63
63
// Detect the lines with FLD
64
- fld->detect (image, lines_fld );
64
+ fld->detect (image, lines );
65
65
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;
67
67
}
68
68
69
69
// Show found lines with FLD
70
70
Mat line_image_fld (image);
71
- fld->drawSegments (line_image_fld, lines_fld );
71
+ fld->drawSegments (line_image_fld, lines );
72
72
imshow (" FLD result" , line_image_fld);
73
73
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);
74
90
waitKey ();
75
91
return 0 ;
76
92
}
0 commit comments