0

I have an image with some intersecting lines where I need to find the point of intersection. I am using cv2.goodFeaturesToTrack to find strong corners, and working on the assumption that intersections are 'strong' corners so they will get detected. But it's not a sure fire way of getting the intersection points of the two lines. Another approach is that I can get the equations of the lines and calculate the line-line intersection... or any other suggestion.

import matplotlib.pyplot as plt
import cv2
import numpy as np
img = cv2.imread('test_lines.png')
new = img.copy()
#invert 
imagem = cv2.bitwise_not(img)
gray = cv2.cvtColor(imagem, cv2.COLOR_BGR2GRAY)


corners = cv2.goodFeaturesToTrack(gray, 4, 0.01, 10, blockSize = 5)
corners = np.int0(corners)
for i in corners:
    import pdb; pdb.set_trace()
    x, y = i.ravel()
    cv2.circle(imagem, (x,y),3,255,-1)
plt.imshow(imagem)
cv2.imwrite('hough_img.png',imagem)

enter image description here

r4bb1t
  • 1,033
  • 2
  • 13
  • 36

1 Answers1

0

How to detect lines in OpenCV?

This answer was helpful in giving me some good results to begin working with. I followed the steps there to get the following result.

enter image description here

r4bb1t
  • 1,033
  • 2
  • 13
  • 36