What I've learnt so far:
This honestly looks like something to fix in the source code of OpenCV (or at the very least in the documentation).
Firstly, we see from the documentation that lines is the "Output vector of lines", which is a bit of a circular definition, hinting that it is to be the output of HoughLinesP.
This is reinforced by the fact that np.mat([])
or np.array([])
are valid values for this parameter, while trying list()
will result in an error:
TypeError: Expected cv::UMat for argument 'lines'
But then none of the valid parameter options have any effect on the object you pass as parameter (returns "[]" for the examples above). Even more confusingly, passing a number is accepted, while having no effect on the results.
This is very worrying, since even the official documentation gets it wrong. See this example they provide:
lines = cv2.HoughLinesP(edges,1,np.pi/180,100,minLineLength,maxLineGap)
But if you check the order of parameters in the code:
image, rho, theta, threshold, lines=None, minLineLength=None, maxLineGap=None
They are clearly passing minLineLength
as lines
, which does not result in an error because int
values are somehow ok. maxLineGap
is therefore working as the minimum line length, as you can actually check by looking at the results if you change this parameter!
This is as far as I've got it so far. Contributions and corrections are appreciated!