I am new to computer vision. The goal is to detect the nearly vertical black lines in a lattice and rotate them to vertical. I applied a Hough line transform. However it is not seeing the obvious black lines.
Here is the code. What did I get wrong?
lines = cv2.HoughLinesP(binary_image, 50, np.pi/180, threshold=50, minLineLength=100, maxLineGap=500)
image_with_lines = binary_image.copy()
for line in lines:
x1, y1, x2, y2 = line[0]
angle_rad = np.arctan2(y2 - y1, x2 - x1)
angle_deg = np.degrees(angle_rad)
if 88 <= angle_deg <= 92:
cv2.line(image_with_lines, (x1, y1), (x2, y2), (0,0,255), 5)
Thank you for your help!
This is a workaround solution. I did the following steps