diff --git a/app.py b/app.py index dede655..abdc605 100644 --- a/app.py +++ b/app.py @@ -68,15 +68,22 @@ def worker(id,source,region=None,stream=False): detections = detections[(detections.tracker_id != None)] count += 1 + names = {} for xyxy,_, confidence, class_id, tracker_id in detections: - ball = balls.get(model.model.names[class_id],{}) + name = model.model.names[class_id] + if name in names: + print("Name duplicate",name) + continue + 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])] ball["count"] = ball.get("count",0) + 1 if region - count < 3: ball["final"] = ball.get("final",0) + 1 - balls[model.model.names[class_id]] = ball + balls[name] = ball + names[name] = True + names = {} if count < region: continue json_data = json.dumps({"table":id,"balls":balls,"time":int(time.time()*1000)})