TRUNCATED_WIDTH_RATIOをコンフィグ化してdefault.yamlから変更できるように
This commit is contained in:
1 parent
31120e4c33
commit
837f969c77
3 files changed
+5
-3
No files matched your search
@@ -183,6 +183,7 @@ class FaceSettings:
|
||||
roi_expand_ratio: float
|
||||
roi_square: bool
|
||||
roi_upscale_target: int
|
||||
roi_truncated_width_ratio: float
|
||||
min_roi_width: int
|
||||
min_roi_height: int
|
||||
static_image_mode: bool
|
||||
@@ -578,6 +579,8 @@ def _validate(config: AppConfig) -> None:
|
||||
raise ConfigurationError("face minimum ROI dimensions must be positive")
|
||||
if face.roi_upscale_target < 0 or not isinstance(face.roi_square, bool):
|
||||
raise ConfigurationError("face roi_square/roi_upscale_target is invalid")
|
||||
if face.roi_truncated_width_ratio <= 0:
|
||||
raise ConfigurationError("face roi_truncated_width_ratio must be positive")
|
||||
if not 0.0 <= face.min_detection_confidence <= 1.0 or not 0.0 <= face.min_tracking_confidence <= 1.0:
|
||||
raise ConfigurationError("face confidence thresholds must be in [0, 1]")
|
||||
pose = config.head_pose
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
from .config_loader import FaceSettings
|
||||
from .models import FaceROI, TrackedPerson
|
||||
|
||||
TRUNCATED_WIDTH_RATIO = 0.45
|
||||
|
||||
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."""
|
||||
if config.require_confirmed_track and not person.is_confirmed:
|
||||
@@ -14,7 +12,7 @@ def create_face_roi(person: TrackedPerson, frame_width: int, frame_height: int,
|
||||
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)
|
||||
candidate_height = max(candidate_height, bbox.width * config.roi_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))
|
||||
|
||||
Reference in new issue
Block a user