1

It is written in the documentation:

lines – Output vector of lines. Each line is represented by a 4-element vector (x_1, y_1, x_2, y_2) , where (x_1,y_1) and (x_2, y_2) are the ending points of each detected line segment.

What is the value of this parameter? lines=?

skaljic1
  • 13
  • 3
  • 2
    I think it is quite explanatory... a vector of 4 element tuples (maybe lists), with two points of a line segment.... so something like `[(x1,y1,x2,y2), ...., (x1,y1,x2,y2)]`, in other words a list of line segments – api55 Feb 11 '18 at 20:52
  • When I use cv2.HoughLinesP(), output looks like this [[ x1, y1, x2, y2]]. I can put lines=1 or lines=15.. does not make any difference. I just want to know what is this parameter for. – skaljic1 Feb 12 '18 at 09:51
  • it is the output parameter – Micka Feb 12 '18 at 09:52
  • Possible duplicate of [OpenCV houghLinesP parameters](https://stackoverflow.com/questions/35609719/opencv-houghlinesp-parameters) – beaker Feb 12 '18 at 21:41

1 Answers1

0

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!

Pablo
  • 1,373
  • 16
  • 36