Python/OpenCV - Detect lines in a tennis court using two differents methods of Hough Line in OpenCV - Get differents results
I'm trying to detect lines in a tennis court using openCV and hough transform. I would like to find horizontal and vertical lines in order to find intersection and finally detect the corner of the tennis court. Here the original image. But i have some problems. 1)I tried to use HoughLineP . Here the code : gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) edges = cv2.Canny(gray,100,200,apertureSize = 3) lines = cv2.HoughLinesP(edges, 1, np.pi/2, 6, None, 50, 10); for line in lines[0]: pt1 = (line[0],line[1]) pt2 = (line[2],line[3]) cv2.line(img, pt1, pt2, (0,0,255), 2) cv2.imshow('dst',img) return res