因此,我一直在尝试使用 HoughLinesP() 来检测边缘,但我的输出没有得到我需要的准确线及其端点。
image = cv2.imread('C:\\Users\\Jimit\\Desktop\\Project\\Original Images\\Original Capture.jpg')
#Hough Line Detection.
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
edges = cv2.Canny(gray, 100, 150)
minLineLength = 200
maxLineGap = 100
lines = cv2.HoughLinesP(edges, 1, np.pi/180, 30, minLineLength, maxLineGap)
for line in lines:
x1, y1, x2, y2 = line[0]
cv2.line(image, (x1, y1), (x2, y2), (0, 255, 0), 2)
print(line)
for theta in lines:
a = np.cos(theta)
b = np.sin(theta)
print(a)
print(b)
cv2.imshow('ab', image)
cv2.waitKey(0)
正如您从图像和 shell 输出中看到的那样,我无法接收到准确的行。此外,我的代码似乎无法捕获垂直线。