Closed gigasurgeon closed 3 months ago
You should keep updating the tracker, as I will make predictions to compensate for the missing detections. This will ensure that the tracks can catch up with the detections once they resume.
How should I update the tracker if there are no detection in that frame? I tried tracker_dets = tracker.update(None, None)
and also tracker_dets = tracker.update(np.array([[]], None)
, and both are giving errors. Is there a way to update tracker with no dets?
Here comes an example 😄
from pathlib import Path
from boxmot import DeepOCSORT
import cv2
import numpy as np
tracker = DeepOCSORT(
model_weights=Path('osnet_x0_25_msmt17.pt'), # which ReID model to use
device='cpu',
fp16=False,
)
vid = cv2.VideoCapture(0)
while True:
ret, im = vid.read()
# empty N X (x, y, x, y, conf, cls)
dets = np.empty((0, 6))
tracker.update(dets, im) # --> M X (x, y, x, y, id, conf, cls, ind)
tracker.plot_results(im, show_trajectories=True)
print("UPDATED!")
# break on pressing q or space
cv2.imshow('BoxMOT detection', im)
key = cv2.waitKey(1) & 0xFF
if key == ord(' ') or key == ord('q'):
break
vid.release()
cv2.destroyAllWindows()
thanks for the example. dets = np.empty((0, 6))
did the trick.
Added this to the detection example under README. Thanks for pointing this out @gigasurgeon!
Search before asking
Question
I am tracking players in basketball using bytetracker. In few frames of the video, there are no players. Should I still update the tracker? Or should I only update the tracker when there are detections?