Reputation: 1
'apply canny'
edges = cv2.Canny(gray, 200, 200)
plt.rcParams["figure.figsize"] = (100, 100)
plt.imshow(edges)
result = img.copy()
lines= cv2.HoughLines(edges, 1, math.pi/180.0, 170, np.array([]), 0, 0)
a,b,c = lines.shape
for i in range(0, (a)):
rho = lines[i][0][0]
theta = lines[i][0][1]
a = math.cos(theta)
b = math.sin(theta)
x0, y0 = a*rho, b*rho
pt1 = ( int(x0+1000*(-b)), int(y0+1000*(a)) )
pt2 = ( int(x0-1000*(-b)), int(y0-1000*(a)) )
cv2.line(result, pt1, pt2, (0, 0, 255), 2, cv2.LINE_AA)
plt.imshow(result)
plt.rcParams["figure.figsize"] = (100, 100)
plt.show()
This is the code I have used for detecting the lines. I used it for vertical lines as well and It performed better.
Result after increasing the threshold
Upvotes: 0
Views: 70