1 Star 0 Fork 0

杨雪锋/opencv-python-5

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
c8-11.py 363 Bytes
一键复制 编辑 原始数据 按行查看 历史
杨雪锋 提交于 2023-04-14 21:51 +08:00 . update ch8
import numpy as np
import cv2 as cv
img = cv.imread('lightning.png')
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
ret,thresh = cv.threshold(gray,127,255,0)
contours,hierarchy = cv.findContours(thresh,1,2)
cnt = contours[0]
# 等效直径计算
area = cv.contourArea(cnt)
equi_diameter = np.sqrt(4*area/np.pi)
# 输出结果
print('等效直径:',equi_diameter )
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/hopeasy/opencv-python-5.git
git@gitee.com:hopeasy/opencv-python-5.git
hopeasy
opencv-python-5
opencv-python-5
master

搜索帮助