From c3fc220135d9cb70b7ec4a5bf9d7effa90f24d5e Mon Sep 17 00:00:00 2001 From: j <123@qq.com> Date: Wed, 4 Jun 2025 22:57:23 +0800 Subject: [PATCH] =?UTF-8?q?fix(file:recognition=5Fcamera.py):=20=20=20=20?= =?UTF-8?q?=201=E3=80=81=E4=BF=AE=E5=A4=8D=E7=9B=AE=E6=A0=87=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E7=9F=A9=E5=BD=A2=E6=A1=86=E5=9D=90=E6=A0=87=E8=B6=85?= =?UTF-8?q?=E5=87=BA=E5=AF=BC=E8=87=B4cv2.resize=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/recognition_camera.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/recognition_camera.py b/src/recognition_camera.py index 27199709..8904cb87 100644 --- a/src/recognition_camera.py +++ b/src/recognition_camera.py @@ -81,6 +81,10 @@ def predict_expression(): # 如果检测到人脸 if faces is not None and len(faces) > 0: for (x, y, w, h) in faces: + x = max(0, x) + y = max(0, y) + w = min(w, frame_gray.shape[1] - x) + h = min(h, frame_gray.shape[0] - y) face = frame_gray[y: y + h, x: x + w] # 脸部图片 faces = generate_faces(face) results = model.predict(faces)