Python opencv很长的Hough线

时间:2018-03-08 08:40:19

标签: python opencv hough-transform

我正试图获得五角大楼,三角形和正方形的hough线。 这是从cv2.canny enter image description here

获得的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)

但结果太奇怪了。仅绘制正方形的完整边缘。 enter image description here

0 个答案:

没有答案