小编Mex*_*Mex的帖子

在骨架图像OpenCV python中查找线

我有以下图片:

我想找到一些线来做一些计算,平均长度等...我试图使用HoughLinesP,但它找不到线条.我能怎么做?

这是我的代码:

sk=skeleton(mask);
rows, cols = sk.shape
imgOut=np.zeros((rows,cols,3),np.uint8)
imgOut[:,:,0]=0
imgOut[:,:,1]=0
imgOut[:,:,2]=0


minLineLength = 0
maxLineGap = 0

lines = cv2.HoughLinesP(sk,1,np.pi/180,100,minLineLength,maxLineGap)
for x1,y1,x2,y2 in lines[0]:
    cv2.line(imgOut,(x1,y1),(x2,y2),(0,255,0),2)

print len(lines[0])

cv2.imshow('skel',sk)
cv2.imshow('Line',imgOut)
cv2.imwrite('Out.bmp',imgOut)
Run Code Online (Sandbox Code Playgroud)

输出:

如果我更改HoughLinesPI 的参数只获得行的片段,而不是实线.

python opencv image-processing

3
推荐指数
1
解决办法
2362
查看次数

标签 统计

image-processing ×1

opencv ×1

python ×1