我正试图获得五角大楼,三角形和正方形的hough线。 这是从cv2.canny
获得的Edge图像环境:Python 2.7,Opencv 2.4.11
img = cv2.imread("shapes.png")
grayimg = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
cannygrayimgBlur = cv2.Canny(grayimg, 50, 150)
minLineLength = 100
maxLineGap = 10
lines =cv2.HoughLinesP(cannygrayimgBlur,1,np.pi/180,100,minLineLength,maxLineGap)
for x1,y1,x2,y2 in lines[0]:
cv2.line(img,(x1,y1),(x2,y2),(0,255,0),2)
cv2.imshow('img',img)
cv2.waitKey(0)