We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HoughLinesPointSet not producing correct results
OpenCVSharp.Extensions and OpenCVSharp.Windows: 4.9.0.20240103 .Net TargetFramework: 8.0 OpenCV-Python: 4.10.0
double rhoMin = 0.0, rhoMax = 360.0, rhoStep = 1.0; double thetaMin = 0.0, thetaMax = Math.PI / 2.0, thetaStep = Math.PI / 180.0; double range = 20; double minAngle = 180 - range; double maxAngle = 0 + range; if (StepLines == "Vertical") { minAngle = 90 - range; maxAngle = 90 + range; } Mat lines = new Mat(); Mat pointsMat = new Mat(points.Count, 1, MatType.CV_32FC2); for (int i = 0; i < points.Count; i++) { pointsMat.Set(i, new Vec2f((float)(points[i].X - X0), (float)(points[i].Y - Y0))); } Cv2.HoughLinesPointSet(pointsMat, lines, 10, 1, rhoMin, rhoMax, rhoStep, thetaMin, thetaMax, thetaStep); # Plot each point on the blank image for point in points: x, y = int(point[0][0]), int(point[0][1]) cv2.circle(image, (x, y), radius=3, color=(255, 0, 0), thickness=-1) # Run HoughLinesPointSet if available lines = cv2.HoughLinesPointSet(points, 1, 1, rho_min, rho_max, rho_step, theta_min, theta_max, theta_step) for (int i = 0; i < lines.Rows; i++) { Vec3f line = lines.Get<Vec3f>(i); float detectedVotes = line.Item0; float detectedRho = line.Item1; float detectedTheta = line.Item2; }
The line variable has three values: [a float value (depends on points), 0, 0]
In documentation, it says the output will be [votes, rho, theta]. But in my result, votes can be a decimal number, and rho and theta are always = 0.
The text was updated successfully, but these errors were encountered:
Sorry for the late reply. I checked the HoughLinesPointSet with the following code and it seemed to work fine.
Vec2f[] points = [ new(0.0f, 369.0f), new(10.0f, 364.0f), new(20.0f, 358.0f), new(30.0f, 352.0f), new(40.0f, 346.0f), new(50.0f, 341.0f), new(60.0f, 335.0f), new(70.0f, 329.0f), new(80.0f, 323.0f), new(90.0f, 318.0f), new(100.0f, 312.0f), new(110.0f, 306.0f), new(120.0f, 300.0f), new(130.0f, 295.0f), new(140.0f, 289.0f), new(150.0f, 284.0f), new(160.0f, 277.0f), new(170.0f, 271.0f), new(180.0f, 266.0f), new(190.0f, 260.0f) ]; const int linesMax = 20, threshold = 1; const double rhoMin = 0.0f, rhoMax = 360.0f, rhoStep = 1, thetaMin = 0.0f, thetaMax = Cv2.PI / 2.0f, thetaStep = Cv2.PI / 180.0f; using var pointsMat = new Mat(points.Length, 1, MatType.CV_32FC2); pointsMat.SetArray(points); using var linesMat = new Mat(); Cv2.HoughLinesPointSet(pointsMat, linesMat, linesMax, threshold, rhoMin, rhoMax, rhoStep, thetaMin, thetaMax, thetaStep); linesMat.GetArray(out Vec3d[] lines); var (votes, rho, theta) = lines[0]; Console.WriteLine("votes={0}, rho={1}, theta={2}", votes, rho, theta); // votes=19, rho=320, theta=1.0471975803375244
Please check if you are handling the output Mat type correctly (the type of lines is 64FC3 instead of 32FC3).
lines
Sorry, something went wrong.
No branches or pull requests
Summary of your issue
HoughLinesPointSet not producing correct results
Environment
OpenCVSharp.Extensions and OpenCVSharp.Windows: 4.9.0.20240103
.Net TargetFramework: 8.0
OpenCV-Python: 4.10.0
Example code:
Output
The line variable has three values: [a float value (depends on points), 0, 0]
In documentation, it says the output will be [votes, rho, theta].
But in my result, votes can be a decimal number, and rho and theta are always = 0.
The text was updated successfully, but these errors were encountered: