cvzone是一個(gè)計(jì)算機(jī)視覺工具包,可方便的圖像處理和實(shí)現(xiàn)視覺AI功能。核心是使用OpenCV和Mediapipe庫(kù)。安裝使用都十分簡(jiǎn)單方便。
開源:https://github.com/cvzone/cvzone
安裝:
pip install cvzone
代碼樣例:
# 人臉檢測(cè)
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()