🧹 more cleanup - remove unused code

This commit is contained in:
SkalskiP committed 2023-08-07 14:20:36 +02:00
1 parent 62e097b559
commit ba880402ad
1 file changed
+1 -37
+1 -37
View File
@@ -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.