These are the instructions inside the OPECV reference.
Image must be a 8-bit single-channel graph (can make grayscale, binary, edge, etc.)
Rho: Distance resolution, typically 1
Theta: Angular resolution, typically cv_pi/180
Threshold: Threshold, returns only pixels and lines greater than Threshold
Srn: (guessing) distance scaling
Stn: (guessing) angle scaling
Key notes
Lines:
-P: Distance from line to Origin (upper left corner)
-: Angle
Here the angle of the document is written vertical line~0°,horizontal line~90° But it doesn't say the direction is clockwise Ah!
Which leads me to wonder how the following angle is calculated.
An example using the Hough line detector can is found at opencv_source_code/samples/cpp/houghlines.cpp
You can draw two straight lines in the drawing.
#include"opencv2/highgui/highgui.hpp"#include"opencv2/imgproc/imgproc.hpp"#include<iostream>using namespaceCV;using namespacestd;Static voidHelp () {cout<<"\nthis program demonstrates line finding with the Hough transform.\n" "usage:\n" "./houghlines <image_name>, Default is pic1.png\n"<<Endl;}intMainintargcChar**argv) { Const Char* filename = argc >=2? argv[1] :"D:/vs/cardpic/w.png"; Mat src= Imread (filename,0); if(Src.empty ()) {Help (); cout<<"can not open"<< filename <<Endl; return-1; } Mat DST, CDST; Canny (SRC, DST, -, $,3); Cvtcolor (DST, CDST, COLOR_GRAY2BGR); Vector<Vec2f>lines; Houghlines (DST, lines,1, cv_pi/ the, the,0,0 ); for(size_t i =0; I < lines.size (); i++ ) { floatRho = lines[i][0], theta = lines[i][1]; cout<<i<<":"<<theta* the/cv_pi<<Endl; Point Pt1, Pt2; DoubleA = cos (theta), B =sin (theta); Doublex0 = A*rho, y0 = b*Rho; pt1.x= Cvround (x0 + +*(-b)); Pt1.y= Cvround (y0 + +*(a)); pt2.x= Cvround (X0- +*(-b)); Pt2.y= Cvround (Y0- +*(a)); Line (CDST, pt1, Pt2, Scalar (0,0,255),1, CV_AA); } imshow ("Source", SRC); Imshow ("detected lines", CDST); Waitkey (); return 0;}
A description of the Houghlines function angle problem