cvzone是一个计算机视觉工具包,可方便的图像处理和实现视觉AI功能。核心是使用OpenCV和Mediapipe库。安装使用都十分简单方便。
开源:https://Github.com/cvzone/cvzone
安装:
pip install cvzone
代码样例:
# 人脸检测
from cvzone.FaceDetectionModule import FaceDetector
import cv2
cap = cv2.VideoCapture(0)
detector = FaceDetector()
while True:
success, img = cap.read()
img, bboxs = detector.findFaces(img)
if bboxs:
# bboxInfo - "id","bbox","score","center"
center = bboxs[0]["center"]
cv2.circle(img, center, 5, (255, 0, 255), cv2.FILLED)
cv2.imshow("Image", img)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllwindows()