Opencv3从头开始(七)霍夫线、霍夫圆检测
霍夫线变换\标准霍夫线、多尺度霍夫线、累计概率霍夫线
标准霍夫线
Mat image_stard=image.clone();
vector<Vec2f> lines_stard;
//line包含rho和theta
HoughLines(image_canny,lines_stard,1,CV_PI/180,100,1,1);
for(size_t i = 0;i<lines_stard.size();i++){
float rho=lines_stard[i][0],theta=lines_stard[i][1];
Point p1, p2;
double p_x = cos(theta)*rho, p_y = sin(theta)*rho;
p1.x = cvRound(p_x + 1000*(-sin(theta)));
p1.y = cvRound(p_y + 1000*(cos(theta)));
p2.x = cvRound(p_x - 1000*(-sin(theta)));
p2.y = cvRound(p_y - 1000*(cos(theta)));
line( image_stard, p1, p2, Scalar(0,0,255), 1, CV_AA);
}
imshow("标准霍夫线检测",image_stard);
累计概率霍夫线
//累计概率霍夫变换
Mat image_line=image.clone();