0

我使用 MediaPipe 和烧瓶编写了这段代码用于人脸检测。编译代码时没有错误,但网站继续加载但没有显示结果。我不知道这里有什么问题。

mp_drawing = mp.solutions.drawing_utils 
mp_holistic = mp.solutions.holistic 
cap = cv2.VideoCapture(0) def generate_frames():
        while True:
            success, frame = cap.read()
            if not success:
                break
            else:
                with mp_holistic.Holistic(min_detection_confidence=0.5, min_tracking_confidence=0.5) as holistic:
                    image = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
                    results = holistic.process(image)
                    image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
                    mp_drawing.draw_landmarks(image, results.face_landmarks, mp_holistic.FACE_CONNECTIONS)
                ret, buffer = cv2.imencode('.jpg', image)
                image = buffer.tobytes()
    
                yield (b'--image\r\n'
                   b'Content-Type: image/jpeg\r\n\r\n' + image + b'\r\n')
4

0 回答 0