Skip to content

Commit

Permalink
clearer complete example
Browse files Browse the repository at this point in the history
  • Loading branch information
mikel-brostrom authored Jun 20, 2023
1 parent 3c9d9cb commit 0180264
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,23 +279,29 @@ while True:
[425, 281, 576, 472, 0.56, 65]])

ts = tracker.update(dets, im) # --> (x, y, x, y, id, conf, cls)

xyxys = ts[:, 0:4].astype('int') # float64 to int
ids = ts[:, 4].astype('int') # float64 to int
confs = ts[:, 5]
clss = ts[:, 6]

# print bboxes with their associated id, cls and conf
if ts.shape[0] != 0:
color = (0, 0, 255) # BGR
thickness = 2
fontscale = 0.5
for t in ts:
for xyxy, id, conf, cls in zip(xyxys, ids, confs, clss):
im = cv2.rectangle(
im,
(int(t[0]), int(t[1])),
(int(t[2]), int(t[3])),
(xyxy[0], xyxy[1]),
(xyxy[2], xyxy[3]),
color,
thickness
)
cv2.putText(
im,
f'id: {t[4]}, conf: {t[5]}, c: {t[6]}', (int(t[0]), int(t[1]-10)),
f'id: {id}, conf: {conf}, c: {cls}',
(xyxy[0], xyxy[1]-10),
cv2.FONT_HERSHEY_SIMPLEX,
fontscale,
color,
Expand Down

0 comments on commit 0180264

Please sign in to comment.