Skip to content

Commit

Permalink
Update fld_lines.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
sturkmen72 authored Dec 15, 2019
1 parent a71820e commit d2ae2d9
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions modules/ximgproc/samples/fld_lines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ using namespace cv::ximgproc;

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}");
string in;
CommandLineParser parser(argc, argv, "{@input|corridor.jpg|input image}{help h||show help message}");
if (parser.has("help"))
{
parser.printMessage();
return 0;
}
in = parser.get<string>("@input");
in = samples::findFile(parser.get<string>("@input"));

Mat image = imread(in, IMREAD_GRAYSCALE);

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

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

// Show found lines with FLD
Mat line_image_fld(image);
fld->drawSegments(line_image_fld, lines_fld);
fld->drawSegments(line_image_fld, lines);
imshow("FLD result", line_image_fld);

waitKey(1);

Ptr<EdgeDrawing> ed = createEdgeDrawing();

for (int run_count = 0; run_count < 10; run_count++) {
double freq = getTickFrequency();
lines.clear();
int64 start = getTickCount();
// Detect the lines with EdgeDrawing
ed->getLines(image, lines);
double duration_ms = double(getTickCount() - start) * 1000 / freq;
cout << "Elapsed time for EdgeDrawing " << duration_ms << " ms." << endl;
}
Mat line_image_ed(image);
fld->drawSegments(line_image_ed, lines);
imshow("EdgeDrawing result", line_image_ed);
waitKey();
return 0;
}

0 comments on commit d2ae2d9

Please sign in to comment.