diff --git a/boxmot/trackers/basetracker.py b/boxmot/trackers/basetracker.py index c5cd6d6a2b..633861819c 100644 --- a/boxmot/trackers/basetracker.py +++ b/boxmot/trackers/basetracker.py @@ -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 @@ -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 diff --git a/tracking/track.py b/tracking/track.py index 311aca84d8..385ababe5e 100644 --- a/tracking/track.py +++ b/tracking/track.py @@ -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) @@ -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',