1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 00:03:03 +04:00

Merge pull request #27992 from asmorkalov:as/HoughLines_bias

Fixed standard HoughLines output shift for rho. #27992

Closes: https://github.com/opencv/opencv/issues/25038
Replaces: https://github.com/opencv/opencv/pull/25043

Merge with https://github.com/opencv/opencv_extra/pull/1288

The original implementation introduces systematic shift (-rho/2) for odd indexes. Integer division just gives proper rounding.

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [ ] The PR is proposed to the proper branch
- [ ] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
Alexander Smorkalov
2025-11-12 11:30:14 +03:00
committed by GitHub
parent adaa369bb1
commit a31a52adef
3 changed files with 65 additions and 2 deletions
+1 -1
View File
@@ -228,7 +228,7 @@ HoughLinesStandard( InputArray src, OutputArray lines, int type,
int idx = _sort_buf[i];
int n = cvFloor(idx*scale) - 1;
int r = idx - (n+1)*(numrho+2) - 1;
line.rho = (r - (numrho - 1)*0.5f) * rho;
line.rho = (r - (numrho - 1)/2) * rho;
line.angle = static_cast<float>(min_theta) + n * theta;
if (type == CV_32FC2)
{
+1 -1
View File
@@ -162,7 +162,7 @@ __kernel void get_lines(__global uchar * accum_ptr, int accum_step, int accum_of
if (index < linesMax)
{
float radius = (x - (accum_cols - 3) * 0.5f) * rho;
float radius = (x - (accum_cols - 3) / 2) * rho;
float angle = y * theta;
lines[index] = (float2)(radius, angle);