智识第二版 250205班级 人工智能项目
dks
2025-06-10 c64815b9abdaad8713e964429891d3f477204357
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from flask import Flask, jsonify
from face_detector import FaceDetector
import cv2
 
app = Flask(__name__)
 
@app.route('/perform_face_detection', methods=['GET'])
def perform_face_detection():
    cap = cv2.VideoCapture(0)
    win_width = 640
    win_height = 480
    detector = FaceDetector(cap, win_width, win_height)
    result = detector.detect_face_local()
    cap.release()
    return jsonify({"is_live": result})
 
if __name__ == '__main__':
    app.run(debug=False, host='127.0.0.1', port=5000)