webcam working

This commit is contained in:
Siwat Sirichai 2025-02-24 14:21:43 +07:00
parent e1da9a6dca
commit 7911245ff9
2 changed files with 30 additions and 10 deletions

View file

@ -106,7 +106,8 @@ def run_pipeline(frame, node: dict, return_bbox: bool = False):
best_box = box_cpu
bbox = None
if detection and node.get("crop", False) and best_box is not None:
# Modified bounding box calculation: always compute bbox if best_box exists
if detection and best_box is not None:
coords = best_box.xyxy[0]
x1, y1, x2, y2 = map(int, coords)
h, w = frame.shape[:2]
@ -114,7 +115,8 @@ def run_pipeline(frame, node: dict, return_bbox: bool = False):
x2, y2 = min(w, x2), min(h, y2)
if x2 > x1 and y2 > y1:
bbox = (x1, y1, x2, y2)
frame = frame[y1:y2, x1:x2]
if node.get("crop", False):
frame = frame[y1:y2, x1:x2]
if detection is not None:
for branch in node["branches"]: