fix the bug of HoughlinesSDIV#20763
Conversation
| for( size_t idx = 0; idx < lst.size(); idx++ ) | ||
| { | ||
| if( lst[idx].rho < 0 ) | ||
| continue; |
There was a problem hiding this comment.
This code assumes items with .rho < 0 anywhere in the list and they are not limited to one.
Added check verifies the last element only, so updated code logic doesn't look similar.
There was a problem hiding this comment.


Actually, through the sorting process, I think the elements pushed in the vector lst have the member variable rho > 0 expect the pivot with rho = -1. And the pivot is always in the end of the vector lst or poped by the sorting process. So I just check the last element.
This is indeed not consistent with the logic of the source code. Perhaps it is more convincing to remove all rho<0 elements in the vector lst.
There was a problem hiding this comment.
opencv/modules/imgproc/src/hough.cpp
Lines 413 to 433 in c1148c4
Ok
This PR fix the bug in HoughLinesSDIV reported in #20751.


Above is a test picture and test code.The results before and after modifying the code are shown in the figure below.
I also test more pictures and more parameters.The code works just fine.