import cv2
import numpy as np
import matplotlib.pylab as plt
import scipy.misc as misc
'''
'''
img = cv2.imread('images/11.jpg')
ret,thresh = cv2.threshold(cv2.cvtColor(img,cv2.COLOR_BGR2GRAY),127,255,0)
_,contours,hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_NONE)#得到轮廓信息
cnt = contours[1]#取第一条轮廓
M = cv2.moments(cnt)#计算第一条轮廓的各阶矩,字典形式
opencv学习——计算轮廓中心点、周长、面积及近似
最新推荐文章于 2024-09-07 13:50:18 发布