1 //Hough Line transform Hough2Vector<vec2f> lines;//defines a vector structure lines used to store the resulting segment vector collection3Houghlines (Dstimage,lines,1, cv_pi/ the, Max);4 //draw each line segment in the diagram, in turn5 for(size_t i =0; i < lines.size (); i++)6 {7 floatRho = lines[i][0],theta = lines[i][1];8 Point pt1,pt2;9 DoubleA = cos (theta), B =sin (theta);Ten Doublex0 = Rho*a,y0 = rho*b;//A is the line intersection axis perpendicular to the line (x0,y0) = (Rho*cos (theta), Rho*sin (theta)); One //take the whole function up Cvceil, take down the whole function Cvfloor, rounding function Cvround; A -pt1.x = Cvround (x0+ +* (-B));//1000 is to take the distance between two points, the amount of control; -Pt1.y = Cvround (y0+ +* (a));//Pt1 is a point on a higher; thept2.x = Cvround (x0- +* (-B));//Pt2 is a point at the lower of A; -Pt2.y = Cvround (y0- +*(a)); - -Line (Dstimage,pt1,pt2,scalar ( -, -,195),1, CV_AA); + } -Imshow ("Hough Detection Line chart", dstimage); + //waitkey (0);
Summary of functions commonly used in OPENCV image processing (2)