title: Finding Coordinates of Line in HoughLineP() in OpenCV using Python
body: <p>I'm working on a edge-detection/line-drawing vision project (using OpenCV and Python).<br>
  I'm able to find the edges I want in an image, using cv2.Canny(), and draw lines on those edges, using HoughLinesP().<br>
  I'm trying to figure out how to find the "end points" of the lines drawn using HoughLinesP() so that I can compare slopes of the lines to a value range (basically, I'm trying to see if those lines are vertical-enough to be "good").<br>
  I'm a little stuck on the finding the points of the lines drawn using HoughLinesP() though.<br>
  My code that's drawing the lines is  </p>
  
  <pre><code>lines = cv2.HoughLinesP(img, RHO, THETA, minLineLength, maxLineGap)  
  a, b, c = lines.shape  
  for i in range(a):  
       cv2.line(img, (lines[i][0][0], lines[i][0][1], lines[i][0][2], lines[i][0][3], (0,255,0), 3, cv2.LINE_AA)
  </code></pre>
  
  <p>now, I can find the "shape" of the array, lines, but I'm not sure what the values mean... basically, where do I go from here?  </p>
  
  <pre><code>&gt;&gt;x = lines.shape
  &gt;&gt;print(x)
  </code></pre>
  
  <p>returns (1038, 1, 4)  . </p>
  
  <p>I understand that it's a 3D array. But how do I determine which points in the image correspond to which elements in the array?<br>
  Is there a way to correlate an element in 'line' to a pixel on the image?</p>
  
  <p>Thank you!  </p>
  
  <p>EDIT:  </p>
  
  <p><code>print([lines[0]])</code><br>
  returns:<br>
  <code>[array([[348, 159, 348, 159]])]</code>  </p>
  
  <p>Which I <em>think</em> corresponds to (x_start, y_start),(x_end,y_end) points of a single line (the particular point above seems to be for a single point, ie the same start and end coordinates).  If I'm understanding everything properly.  </p>
  
  <p>But, when trying to find the maximum x and y coordinates (the "top" and "bottom" of the line), I'm getting weird results.  </p>
  
  <p>This is what I'm doing:  </p>
  
  <p><code>a,b,c = lines.shape
  for i in range(a):
         max_y = np.maximum(lines[i][0][1], lines[i][0][3])
         min_y = np.minimum(lines[i][0][1], lines[i][0][3])</code>  </p>
  
  <p>Now, when I go back and print and show the results of the those statements... I don't get the points on the lines... what gives?  </p>