added number to the frame id
This commit is contained in:
parent
46177f166a
commit
b3d2fa0ee6
@ -131,11 +131,15 @@ def run(weights=ROOT / 'yolov3.pt', # model.pt path(s)
|
||||
# Rescale boxes from img_size to im0 size
|
||||
det[:, :4] = scale_coords(im.shape[2:], det[:, :4], im0.shape).round()
|
||||
# Print results
|
||||
number_of_uniq_det = {}
|
||||
for c in det[:, -1].unique():
|
||||
n = (det[:, -1] == c).sum() # detections per class
|
||||
s += f"{n} {names[int(c)]}{'s' * (n > 1)}, " # add to string
|
||||
number_of_uniq_det[names[int(c)]] = int(n)
|
||||
|
||||
# Write results
|
||||
append_count = 0
|
||||
last_name = ""
|
||||
for *xyxy, conf, cls in reversed(det):
|
||||
bounding_box = BoundingBox()
|
||||
c = int(cls) # integer class
|
||||
@ -147,7 +151,15 @@ def run(weights=ROOT / 'yolov3.pt', # model.pt path(s)
|
||||
bounding_box.xmax = int(xyxy[2])
|
||||
bounding_box.ymax = int(xyxy[3])
|
||||
bounding_box.id = c
|
||||
bounding_box.class_id = names[c]
|
||||
if last_name != names[c]:
|
||||
append_count = 0
|
||||
if number_of_uniq_det[names[c]] > 1:
|
||||
bounding_box.class_id = names[c] + "_" + str(append_count)
|
||||
append_count+=1
|
||||
last_name = names[c]
|
||||
else:
|
||||
bounding_box.class_id = names[c]
|
||||
append_count = 0
|
||||
bounding_boxes_msg.bounding_boxes.append(bounding_box)
|
||||
# Print time (inference-only)
|
||||
LOGGER.info(f'{s}Done. ({t3 - t2:.3f}s)')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user