#include<opencv2/opencv.hpp>
#include<opencv2/imgproc/imgproc.hpp>
using namespace cv;
using namespace std;
int main() {
Mat src = imread("D:\\杂项\\图片素材\\2.jpg");
Mat dst, edge;
Canny(src, edge,50,200,3);
cvtColor(edge, dst, CV_BGR2GRAY);
vector<Vec2f> lines;
HoughLines(edge, lines, 1, CV_PI / 180, 150,0,0);
for (size_t i = 0; i < lines.size(); i++) {
float r = lines[i][0], theta = lines[i][1];
double x0 = r*cos(theta), y0 = r*sin(theta);
Point ptr1, ptr2;
ptr1.x = cvRound(x0 - 1000 * sin(theta));
ptr1.y = cvRound(y0 + 1000 * cos(theta));
ptr2.x = cvRound(x0 + 1000 * sin(theta));
ptr2.y = cvRound(y0 - 1000 * cos(theta));
line(dst, ptr1, ptr2, Scalar(55, 100, 195), 1, CV_AA);
}
imshow("my girl", dst);
waitKey(0);
return(0);
}
不知道哪里错了,求大神指教