Emi*_*tti 5
很好的案例,根据OpenCV 文档,一旦你有了轮廓,你应该能够使用方法计算你想要的东西cv.arcLength()
。
也称为弧长。可以使用 cv.arcLength() 函数找到它。第二个参数指定 shape 是闭合轮廓(如果传递 True),还是只是曲线。
来自官方文档的示例:
import numpy as np
import cv2 as cv
img = cv.imread('star.jpg',0)
ret, thresh = cv.threshold(img,127,255,0)
contours, hierarchy = cv.findContours(thresh, 1, 2)
t = contours[0]
area = cv.contourArea() # Area of first contour
perimeter = cv.arcLength(t, True) # Perimeter of first contour
因此,在您的情况下,您应该按如下方式更新代码:
def pute_mean_stddev(contours_of_images):
for contours_of_image in contours_of_images:
count = len(contours_of_image)
sum_list = []
for tr in contours_of_image:
area = cv2.contourArea(tr)
perimeter = cv.arcLength(tr, True)
average = np.mean(sum_list)
standard_deviation = np.std(sum_list)
我希望这行得通!
更多推荐
周长,轮廓,Python,OpenCV
发布评论