4
lines = cv2.HoughLinesP(edges,1,np.pi/180,100,minLineLength,maxLineGap,cv2.THRESH_BINARY)

I am using this code to detect line in a PNG image, and the function returns a numpy array :

array([[[124, 235, 393, 235]],

       [[124, 233, 393, 233]]])

I wanted to know what these values mean in order to get the length and direction of the line detected.

*The image used contains only one horizontal line.

Jeru Luke
  • 20,118
  • 13
  • 80
  • 87
MSD
  • 154
  • 2
  • 12
  • The openCV documentation contains enough information to answer your question - https://docs.opencv.org/3.0-beta/doc/py_tutorials/py_imgproc/py_houghlines/py_houghlines.html – Ganesh Tata Mar 03 '18 at 08:43
  • OK got it...1st one is for starting point and 3rd is for end point – MSD Mar 03 '18 at 11:05
  • but in case of many lines the returned array is like : array([[[169, 270, 357, 270]], [[169, 268, 357, 268]], [[357, 267, 357, 101]], [[359, 268, 359, 102]], [[358, 100, 465, 100]], [[360, 102, 465, 102]]]) But how to identify which one is for which line ? – MSD Mar 03 '18 at 11:06
  • What do you mean by "which one is for which line"? – Ganesh Tata Mar 03 '18 at 11:07
  • 2
    The [documentation](https://docs.opencv.org/2.4/modules/imgproc/doc/feature_detection.html#cv2.HoughLinesP) is quite explicit... ` 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.` the only difference is that in python is a list. but basically it is a list of line segments. Sometimes you may get almost the same line (look the first 2 in your comment) they are both one next to each other, just that one is 2 pixels higher, probably a thick line have this effect – api55 Mar 03 '18 at 11:23

0 Answers0