From ba880402add528d2a96a06c8fafc349eee1b2def Mon Sep 17 00:00:00 2001 From: SkalskiP Date: Mon, 7 Aug 2023 14:20:36 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20more=20cleanup=20-=20remove=20un?= =?UTF-8?q?used=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- supervision/tracker/byte_tracker/core.py | 38 +----------------------- 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/supervision/tracker/byte_tracker/core.py b/supervision/tracker/byte_tracker/core.py index 2890094a..6a23e918 100644 --- a/supervision/tracker/byte_tracker/core.py +++ b/supervision/tracker/byte_tracker/core.py @@ -3,7 +3,6 @@ from typing import List, Tuple import numpy as np from supervision import Detections -from supervision.detection.utils import box_iou_batch from supervision.tracker.byte_tracker import matching from supervision.tracker.byte_tracker.basetrack import BaseTrack, TrackState from supervision.tracker.byte_tracker.kalman_filter import KalmanFilter @@ -164,41 +163,6 @@ def detections2boxes(detections: Detections) -> np.ndarray: ) -# converts List[strack] into format that can be consumed by match_detections_with_tracks function -def tracks2boxes(tracks: List[STrack]) -> np.ndarray: - return np.array([track.tlbr for track in tracks], dtype=float) - - -# matches our bounding boxes with predictions -def match_detections_with_tracks( - detections: Detections, tracks: List[STrack] -) -> Detections: - """ - Match bounding boxes from detections with existing strack objects. - - Parameters: - detections (Detections): An object representing the detected bounding boxes. - tracks (List[strack]): A list of strack objects to match with the detections. - - Returns: - Detections: An object representing the matched tracker IDs for the detections. - """ - if not np.any(detections.xyxy) or len(tracks) == 0: - return np.empty((0,)) - - tracks_boxes = tracks2boxes(tracks=tracks) - iou = box_iou_batch(tracks_boxes, detections.xyxy) - track2detection = np.argmax(iou, axis=1) - - tracker_ids = [None] * len(detections) - - for tracker_index, detection_index in enumerate(track2detection): - if iou[tracker_index, detection_index] != 0: - tracker_ids[detection_index] = tracks[tracker_index].track_id - - return tracker_ids - - class ByteTrack: """ Initialize the ByteTrack object. @@ -254,7 +218,7 @@ class ByteTrack: return detections - def update_with_numpy(self, output_results) -> List[STrack]: + def update_with_numpy(self, output_results: np.ndarray) -> List[STrack]: """ Update a matched strack. It uses the numpy results.