duplicate

main
luanhailiang 2023-08-17 12:19:13 +08:00
parent 95e420689a
commit f66dc12d5e
1 changed files with 8 additions and 2 deletions

10
app.py
View File

@ -68,20 +68,26 @@ 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)
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
if count < region:
continue
json_data = json.dumps({"table":id,"balls":balls,"time":int(time.time()*1000)})
balls = {}
count = 0
names = {}
if not stream:
yield json_data
else: