imgproc: fix HoughLines OpenCL min_theta/max_theta handling #28322
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a bug where the OpenCL-accelerated implementation of
cv::HoughLinesignoredmin_thetaandmax_thetaparameters, always computing angles from 0 instead of the specified range.Problem Description
When calling
cv::HoughLineswith OpenCL acceleration and specifyingmin_theta/max_thetaparameters (e.g., to detect only horizontal lines with theta ∈ [80°, 100°]), the function would fail to find any lines. This is because:numanglebased on the theta rangemin_thetaChanges Made
C++ code (
hough.cpp):min_thetaparameter toocl_fillAccumfunction signatureocl_fillAccuminocl_HoughLines(passesmin_theta) andocl_HoughLinesP(passes0.0for default [0, π] range)getLinesKernel.argsto passmin_thetato the kernelOpenCL kernels (
hough_lines.cl):fill_accum_globalandfill_accum_localkernels to acceptmin_thetaparametertheta * theta_idxtomin_theta + theta * theta_idxget_lineskernel to correctly compute detected line angles asmin_theta + y * thetaTesting
The fix resolves the issue described in #28036 where horizontal line detection with
min_theta=80°, max_theta=100°failed with OpenCL but worked without it.Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Fixes #28036