From d71b892e2899ec2a63693313ca453839c630b3a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E5=96=B5?= Date: Fri, 12 Jun 2026 14:09:44 +0800 Subject: [PATCH] =?UTF-8?q?2026.6.12=E5=B0=8F=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- infer_camera_modular.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/infer_camera_modular.py b/infer_camera_modular.py index 2079d66..1828c5a 100644 --- a/infer_camera_modular.py +++ b/infer_camera_modular.py @@ -687,7 +687,13 @@ def main(): # 追踪器锁定 → 绘制平滑框 if tracked and track_res.get("box") is not None: - bx1, by1, bx2, by2 = track_res["box"] + box = track_res.get("box") + # 使用 np.clip 限制坐标,防止其画到屏幕外出现其他问题 + h_img, w_img = orig_shape + bx1 = int(np.clip(box[0], 0, w_img-1)) + by1 = int(np.clip(box[1], 0, h_img-1)) + bx2 = int(np.clip(box[2], 0, w_img-1)) + by2 = int(np.clip(box[3], 0, h_img-1)) is_coast = track_res.get("is_predicted", False) box_color = (0, 255, 255) if is_coast else (0, 255, 0) # COAST=黄, MEAS=绿 label = f"ID:{track_res.get('primary_id','?')}"