From 9a4631a9f32f2f068eb41605fe7d82389aff1304 Mon Sep 17 00:00:00 2001 From: KoyoNoguchi Date: Tue, 29 Sep 2026 15:47:38 +0900 Subject: [PATCH] =?UTF-8?q?=E8=BF=91=E8=B7=9D=E9=9B=A2=E3=81=AB=E3=81=8A?= =?UTF-8?q?=E3=81=84=E3=81=A6=E9=A1=94=E6=A4=9C=E5=87=BAROI=E3=81=8C?= =?UTF-8?q?=E4=B8=8A=E9=83=A8=E3=81=AB=E8=A1=8C=E3=81=8D=E9=81=8E=E3=81=8E?= =?UTF-8?q?=E3=81=A6=E3=81=97=E3=81=BE=E3=81=86=E5=95=8F=E9=A1=8C=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/face_geometry.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/face_geometry.py b/src/face_geometry.py index 377518b..c838053 100644 --- a/src/face_geometry.py +++ b/src/face_geometry.py @@ -3,6 +3,7 @@ from .config_loader import FaceSettings from .models import FaceROI, TrackedPerson +TRUNCATED_WIDTH_RATIO = 0.8 def create_face_roi(person: TrackedPerson, frame_width: int, frame_height: int, config: FaceSettings) -> FaceROI | None: """Create a clipped upper-body ROI or return None when the track is ineligible.""" @@ -12,12 +13,14 @@ def create_face_roi(person: TrackedPerson, frame_width: int, frame_height: int, return None bbox = person.bbox candidate_height = bbox.height * config.roi_height_ratio + if bbox.y2 >= frame_height - 2: + candidate_height = max(candidate_height, bbox.width * TRUNCATED_WIDTH_RATIO) expand_x = bbox.width * config.roi_expand_ratio expand_y = candidate_height * config.roi_expand_ratio y1 = max(0, round(bbox.y1 - expand_y)) y2 = min(frame_height, round(bbox.y1 + candidate_height + expand_y)) if config.roi_square: - half = (y2 - y1) / 2.0 # 縦幅と同じ幅の正方形 + half = (y2 - y1) / 2.0 x1 = max(0, round(bbox.center_x - half)) x2 = min(frame_width, round(bbox.center_x + half)) else: