When a given image with lines is passed to OpenCV's HoughLine transform, it returns a list of rho and theta pairs, each pair defining an individual line. What is the order in which lines are listed in this list of rho,theta pairs.
for eg, when this image with 8 lines was uses in python, image with 8 line
following, rho,theta matrix was returned for the eight lines.
[[ 461. 1.48352981]
[ 380. 1.48352981]
[ 212. 1.48352981]
[ 112. 1.48352981]
[ 65. 1.48352981]
[ 334. 1.48352981]
[ 269. 1.48352981]
[ 508. 1.48352981]]
How is the order in which lines are listed here in this matrix, is determined by openCV?
From the OpenCV source code https://github.com/opencv/opencv/blob/master/modules/imgproc/src/hough.cpp
function HoughLinesStandard implements the standard hough transform starting at line 80.
If we scroll a bit further down (line 166) we find:
Now the list of lines is sorted ascending by accumulator value. And the best
linesMax
results are put into the output buffer.In case you don't know what the accumulator value is, please read how the Hough Transform works. https://en.wikipedia.org/wiki/Hough_transform
It basically says how many pixels contributed to that rho theta pair.