-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathdetectLine.cpp
More file actions
41 lines (31 loc) · 1 KB
/
detectLine.cpp
File metadata and controls
41 lines (31 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/line_descriptor/descriptor.hpp>
#include <opencv/cv.h>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <fstream>
using namespace std;
using namespace cv;
using namespace cv::line_descriptor;
int main(int argc, const char* argv[])
{
if(argc<3) {
std::cout<<argv[0]<<" infilename outfilename"<<std::endl;
return 1;
}
cv::Mat img = cv::imread(argv[1],CV_LOAD_IMAGE_GRAYSCALE);
cv::imshow("WS", img);
cv::waitKey(0);
std::vector<KeyLine> keylines;
Ptr<line_descriptor::LSDDetector> lsd = line_descriptor::LSDDetector::createLSDDetector();
lsd->detect(img, keylines, 1.2, 1, cv::Mat());
ofstream out(argv[2]);
for(size_t i = 0; i<keylines.size() ; i++)
{
out<<keylines[i].startPointX<<" "<<keylines[i].startPointY<<" "<<keylines[i].endPointY<<" "<<keylines[i].endPointY<<endl;
}
out.close();
return 0;
}