检测效果还不错,就是追踪有点难做
import cv2
import mediapipe as mp
import os
from collections import defaultdict# pip install msvc-runtime# 初始化OpenCV的MultiTracker
# multi_tracker = cv2.MultiTracker_create()
# multi_tracker = cv2.legacy.MultiTracker_create()
# trackers = []# 创建Mediapipe人脸检测模型
mp_face_detection = mp.solutions.face_detection
face_detection = mp_face_detection.FaceDetection(model_selection=1 , min_detection_confidence=0.9)
# face_detection = mp_face_detection.FaceDetection()# 创建输出文件夹
output_dir = "detected_faces"
if not os.path.exists(output_dir):os.makedirs(