linux c++ 编译链接 opencv
#include<opencv2/core/core.hpp>
#include<opencv2/highgui/highgui.hpp>
#include<iostream>
#include <opencv2/opencv.hpp>
using namespace cv;
using namespace std;
int main()
{
cout << "hello world" << endl;
Mat image = imread("edge.png");
Mat grayImage;
cvtcolor(image, grayimage, cv_bgr2gray);
ptr<linesegmentdetector> ls = createlinesegmentdetector(
lsd_refine_std, 0.8,
0.6, 2.0, 22.5,
0, 0.75);
vector<vec4f> lines_std;
ls->detect(grayimage, lines_std);
ofstream outfile("test.txt");
for (int i = 0; i < lines_std.size(); i++)
{
cout << lines_std[i][0] << " " << lines_std[i][1] << " "
<< lines_std[i][2] << " " << lines_std[i][3] << endl;
outfile << lines_std[i][0] << " " << lines_std[i][1] << " "
<< lines_std[i][2] << " " << lines_std[i][3] << endl;
}
outfile.close();
show found lines
mat drawnlines(image);
ls->drawsegments(drawnlines, lines_std);
imwrite("drawnLines.png", image);
return 0;
}