Skip to content

Commit d308b26

Browse files
fix(pre_commit): 🎨 auto format pre-commit hooks
1 parent d56f9cb commit d308b26

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

trackers/core/botsort/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
# ------------------------------------------------------------------------
66
from .tracker import BoTSORTTracker
77

8-
__all__ = ["BoTSORTTracker"]
8+
__all__ = ["BoTSORTTracker"]

trackers/core/botsort/cmc.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66

77
from __future__ import annotations
88

9+
import copy
910
from dataclasses import dataclass
1011
from typing import Optional
1112

12-
import copy
13-
import numpy as np
1413
import cv2
14+
import numpy as np
1515

1616

1717
@dataclass
@@ -48,7 +48,9 @@ def reset(self) -> None:
4848
self._prev_kps = None
4949
self._prev_desc = None
5050

51-
def estimate(self, frame_bgr: np.ndarray, dets_xyxy: Optional[np.ndarray] = None) -> np.ndarray:
51+
def estimate(
52+
self, frame_bgr: np.ndarray, dets_xyxy: Optional[np.ndarray] = None
53+
) -> np.ndarray:
5254
if frame_bgr is None:
5355
return np.eye(2, 3, dtype=np.float32)
5456

@@ -105,7 +107,9 @@ def estimate(self, frame_bgr: np.ndarray, dets_xyxy: Optional[np.ndarray] = None
105107
self._prev_desc = copy.copy(desc)
106108
return H_aff
107109

108-
max_spatial = self.cfg.max_spatial_distance_frac * np.array([W, H], dtype=np.float32)
110+
max_spatial = self.cfg.max_spatial_distance_frac * np.array(
111+
[W, H], dtype=np.float32
112+
)
109113

110114
prev_pts = []
111115
curr_pts = []
@@ -173,7 +177,9 @@ def apply_to_tracks(tracks: list, H: np.ndarray) -> None:
173177
A8[0:4, 0:4] = A4
174178
A8[4:8, 4:8] = A4
175179

176-
trans4 = np.array([t[0, 0], t[1, 0], t[0, 0], t[1, 0]], dtype=np.float32).reshape(4, 1)
180+
trans4 = np.array(
181+
[t[0, 0], t[1, 0], t[0, 0], t[1, 0]], dtype=np.float32
182+
).reshape(4, 1)
177183

178184
for trk in tracks:
179185
trk.state = (A8 @ trk.state).astype(np.float32)

trackers/core/botsort/kalman_box_tracker.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import numpy as np
88

9+
910
class BoTSORTKalmanBoxTracker:
1011
"""
1112
The `BoTSORTKalmanBoxTracker` class represents the internals of a single

trackers/core/botsort/tracker.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212
from scipy.optimize import linear_sum_assignment
1313

1414
from trackers.core.base import BaseTracker
15+
from trackers.core.botsort.cmc import CMC, CMCConfig
1516
from trackers.core.botsort.kalman_box_tracker import BoTSORTKalmanBoxTracker
1617
from trackers.utils.sort_utils import (
1718
get_alive_trackers,
1819
get_iou_matrix,
1920
)
20-
from trackers.core.botsort.cmc import CMC, CMCConfig
21+
2122

2223
class BoTSORTTracker(BaseTracker):
2324
def __init__(
@@ -28,8 +29,7 @@ def __init__(
2829
minimum_consecutive_frames: int = 2,
2930
minimum_iou_threshold: float = 0.1,
3031
high_conf_det_threshold: float = 0.6,
31-
enable_cmc: bool = True
32-
32+
enable_cmc: bool = True,
3333
) -> None:
3434
# Calculate maximum frames without update based on lost_track_buffer and
3535
# frame_rate. This scales the buffer based on the frame rate to ensure
@@ -94,7 +94,9 @@ def update(
9494

9595
# CMC (ORB) apply to all predicted tracks before association
9696
if self.enable_cmc and self.cmc is not None and frame is not None:
97-
mask_boxes = high_prob_detections.xyxy if len(high_prob_detections) > 0 else None
97+
mask_boxes = (
98+
high_prob_detections.xyxy if len(high_prob_detections) > 0 else None
99+
)
98100
H = self.cmc.estimate(frame, mask_boxes)
99101
self.cmc.apply_to_tracks(self.tracks, H)
100102

0 commit comments

Comments
 (0)