Skip to content

Commit

Permalink
make the trajectories plotting toggleable
Browse files Browse the repository at this point in the history
  • Loading branch information
mikel.brostrom committed Mar 7, 2024
1 parent 03ab61e commit db048b8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions boxmot/trackers/basetracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def plot_trackers_trajectories(self, img: np.ndarray, observations: list, id: in
return img


def plot_trajectory(self, img: np.ndarray) -> np.ndarray:
def plot_results(self, img: np.ndarray, show_trajectories: bool) -> np.ndarray:
"""
Visualizes the trajectories of all active tracks on the image. For each track,
it draws the latest bounding box and the path of movement if the history of
Expand All @@ -161,7 +161,8 @@ def plot_trajectory(self, img: np.ndarray) -> np.ndarray:
if len(a.history_observations) > 2:
box = a.history_observations[-1]
img = self.plot_box_on_img(img, box, a.conf, a.cls, a.id)
img = self.plot_trackers_trajectories(img, a.history_observations, a.id)
if show_trajectories:
img = self.plot_trackers_trajectories(img, a.history_observations, a.id)

return img

4 changes: 3 additions & 1 deletion tracking/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def run(args):

for r in results:

img = yolo.predictor.trackers[0].plot_trajectory(r.orig_img)
img = yolo.predictor.trackers[0].plot_results(r.orig_img, args.show_trajectories)

if args.show is True:
cv2.imshow('BoxMOT', img)
Expand Down Expand Up @@ -148,6 +148,8 @@ def parse_opt():
help='either show all or only bboxes')
parser.add_argument('--show-conf', action='store_false',
help='hide confidences when show')
parser.add_argument('--show-trajectories', action='store_true',
help='show confidences')
parser.add_argument('--save-txt', action='store_true',
help='save tracking results in a txt file')
parser.add_argument('--save-id-crops', action='store_true',
Expand Down

0 comments on commit db048b8

Please sign in to comment.