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)]
|
detections = detections[(detections.tracker_id != None)]
|
||||||
|
|
||||||
count += 1
|
count += 1
|
||||||
|
names = {}
|
||||||
for xyxy,_, confidence, class_id, tracker_id in detections:
|
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["tkid"] = int(tracker_id)
|
||||||
ball["conf"] = round(float(confidence), 2)
|
ball["conf"] = round(float(confidence), 2)
|
||||||
ball["xyxy"] = [int(xyxy[0]), int(xyxy[1]), int(xyxy[2]), int(xyxy[3])]
|
ball["xyxy"] = [int(xyxy[0]), int(xyxy[1]), int(xyxy[2]), int(xyxy[3])]
|
||||||
ball["count"] = ball.get("count",0) + 1
|
ball["count"] = ball.get("count",0) + 1
|
||||||
if region - count < 3:
|
if region - count < 3:
|
||||||
ball["final"] = ball.get("final",0) + 1
|
ball["final"] = ball.get("final",0) + 1
|
||||||
balls[model.model.names[class_id]] = ball
|
balls[name] = ball
|
||||||
|
names[name] = True
|
||||||
if count < region:
|
if count < region:
|
||||||
continue
|
continue
|
||||||
json_data = json.dumps({"table":id,"balls":balls,"time":int(time.time()*1000)})
|
json_data = json.dumps({"table":id,"balls":balls,"time":int(time.time()*1000)})
|
||||||
balls = {}
|
balls = {}
|
||||||
count = 0
|
count = 0
|
||||||
|
names = {}
|
||||||
if not stream:
|
if not stream:
|
||||||
yield json_data
|
yield json_data
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue