嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元微信扫码支付:2 元
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
智能计数
计算机视觉 opencv 物体数数.ipynb
import cv2
import imutils
image = cv2.imread("D:/jupyter file/image/29.png")
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
blurred = cv2.GaussianBlur(gray, (3, 3), 0)
edged = cv2.Canny(blurred, 50, 130)
cnts = cv2.findContours(edged.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
cnts = imutils.grab_contours(cnts)
total = 0
for c in cnts:
if cv2.contourArea(c) < 25: #这个值要调参数
continue
cv2.drawContours(image, [c], -1, (204, 0, 255), 2)
total = 1
print("[INFO] found {} shapes".format(total))
cv2.imshow("Image", image)
cv2.waitKey(0)
cv2.waitKey(0)
cv2.destroyAllWindows()