核心代码:
vector<Vec4f> lines;
HoughLinesP(t3, lines, 1, CV_PI / 180, 30, 10, 10);
for (size_t i = 0; i < lines.size(); i++) {
Scalar color = Scalar(rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255));
line(t1, Point(lines[i][0], lines[i][1]), Point(lines[i][2], lines[i][3]), color, 1, 8);
}
做霍夫变换之前记得提取图像边缘,是对图像边缘做霍夫变换
原理:
https://blog.csdn.net/ycj9090900/article/details/52944708
https://blog.csdn.net/abcjennifer/article/details/7448513