From a35167bf8ac8cd99104f4b3eddd31960bf899543 Mon Sep 17 00:00:00 2001 From: luanhailiang Date: Mon, 6 Nov 2023 18:13:05 +0800 Subject: [PATCH] xyxy --- app.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index fd885b5..758ba93 100644 --- a/app.py +++ b/app.py @@ -122,6 +122,9 @@ def worker(id,source,region=None,stream=False): count += 1 names = {} + # 检查 "xyxy" 键是否为 None + if ball.get("xyxy") is None: + ball["xyxy"] = [] for xyxy,_, confidence, class_id,tracker_id in detections: name = model.model.names[class_id] if name in names: @@ -130,7 +133,8 @@ def worker(id,source,region=None,stream=False): ball = balls.get(name,{}) # ball["tkid"] = int(tracker_id) ball["conf"] = round(float(confidence), 2) - ball["xyxy"] = [int(xyxy[0]), int(xyxy[1]), int(xyxy[2]), int(xyxy[3])] + site = [int(xyxy[0]), int(xyxy[1]), int(xyxy[2]), int(xyxy[3])] + ball["xyxy"].append(site) ball["count"] = ball.get("count",0) + 1 if region - count < 3: ball["final"] = ball.get("final",0) + 1