def shapeFiltering(img):
contours = cv2.findContours(img, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)[0]
if len(contours) == 0:
print "shapeFiltering: Error, no contours found"
return 1
good_shape = []
for c in contours:
x,y,w,h = cv2.boundingRect(c)
#if h == 0:
# continue
ratio = w / h
ratio_grade = ratio / (TMw / TMh)
if 0.2 < ratio_grade < 1.8:
good_shape.append(c)
return good_shape
Falafel Vision Processing.py 文件源码
python
阅读 33
收藏 0
点赞 0
评论 0
评论列表
文章目录