def imgSeg_contour(img, b,g,r, per):
lower = np.array([0, 0, 0])
upper = np.array([b,g,r])
shapeMask = cv2.inRange(img, lower, upper)
#http://stackoverflow.com/questions/27746089/python-computer-vision-contours-too-many-values-to-unpack
_, cnts, hierarchy = cv2.findContours(shapeMask.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
cnts = sorted(cnts, key = cv2.contourArea, reverse = True)[:4]
for c in cnts:
peri = cv2.arcLength(c, True)
approx = cv2.approxPolyDP(c, per * peri, True) ### 0.04 ###
if (len(approx) >= 4) and (len(approx) < 6):
break
return approx
logoSet.py 文件源码
python
阅读 39
收藏 0
点赞 0
评论 0
评论列表
文章目录