~paparazzi-uav/paparazzi/v5.0-manual

« back to all changes in this revision

Viewing changes to sw/ext/opencv_bebop/opencv/samples/cpp/lsd_lines.cpp

  • Committer: Paparazzi buildbot
  • Date: 2016-05-18 15:00:29 UTC
  • Revision ID: felix.ruess+docbot@gmail.com-20160518150029-e8lgzi5kvb4p7un9
Manual import commit 4b8bbb730080dac23cf816b98908dacfabe2a8ec from v5.0 branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <iostream>
 
2
#include <string>
 
3
 
 
4
#include "opencv2/core/core.hpp"
 
5
#include "opencv2/core/utility.hpp"
 
6
#include "opencv2/imgproc/imgproc.hpp"
 
7
#include "opencv2/imgcodecs.hpp"
 
8
#include "opencv2/highgui/highgui.hpp"
 
9
 
 
10
using namespace std;
 
11
using namespace cv;
 
12
 
 
13
int main(int argc, char** argv)
 
14
{
 
15
    std::string in;
 
16
    cv::CommandLineParser parser(argc, argv, "{@input|../data/building.jpg|input image}{help h||show help message}");
 
17
    if (parser.has("help"))
 
18
    {
 
19
        parser.printMessage();
 
20
        return 0;
 
21
    }
 
22
    in = parser.get<string>("@input");
 
23
 
 
24
    Mat image = imread(in, IMREAD_GRAYSCALE);
 
25
 
 
26
#if 0
 
27
    Canny(image, image, 50, 200, 3); // Apply canny edge
 
28
#endif
 
29
 
 
30
    // Create and LSD detector with standard or no refinement.
 
31
#if 1
 
32
    Ptr<LineSegmentDetector> ls = createLineSegmentDetector(LSD_REFINE_STD);
 
33
#else
 
34
    Ptr<LineSegmentDetector> ls = createLineSegmentDetector(LSD_REFINE_NONE);
 
35
#endif
 
36
 
 
37
    double start = double(getTickCount());
 
38
    vector<Vec4f> lines_std;
 
39
 
 
40
    // Detect the lines
 
41
    ls->detect(image, lines_std);
 
42
 
 
43
    double duration_ms = (double(getTickCount()) - start) * 1000 / getTickFrequency();
 
44
    std::cout << "It took " << duration_ms << " ms." << std::endl;
 
45
 
 
46
    // Show found lines
 
47
    Mat drawnLines(image);
 
48
    ls->drawSegments(drawnLines, lines_std);
 
49
    imshow("Standard refinement", drawnLines);
 
50
 
 
51
    waitKey();
 
52
    return 0;
 
53
}