duplicate
parent
95e420689a
commit
f66dc12d5e
10
app.py
10
app.py
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue