import cv2
import numpy as np
# .高宽比
img = cv2.imread('zhua.jpg',0)
ret,thresh = cv2.threshold(img,100,255,0)
image,contours,hierarchy = cv2.findContours(thresh, 1, 2)
cnt = contours[0]
# 函数cv2.moments()会给你一个字典,包含所有矩值
M = cv2.moments(cnt)
# 这是目标的边界矩形的宽高比
x,y,w,h=cv2.boundingRect(cnt)
aspect_ratio=float
python opencv 轮廓属性
最新推荐文章于 2024-08-16 09:00:00 发布