-
Notifications
You must be signed in to change notification settings - Fork 2
/
ioutrack.pyi
222 lines (205 loc) · 7.4 KB
/
ioutrack.pyi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
import numpy as np
import numpy.typing as npt
from typing import Union
class BaseTracker:
def __new__(self) -> BaseTracker: ...
def update(
self, boxes: npt.NDArray[Union[np.float32, np.float64]], return_all: bool
) -> npt.NDArray[np.float32]: ...
def get_current_track_boxes(
self, return_all: bool = False
) -> npt.NDArray[np.float32]: ...
def clear_trackers(self) -> None: ...
def remove_tracker(self, track_id: int) -> None: ...
class Sort(BaseTracker):
max_age: int
min_hits: int
iou_threshold: float
init_tracker_min_score: float
tracklets: dict[int, KalmanBoxTracker]
n_steps: int
def __new__(
self,
max_age: int = 1,
min_hits: int = 3,
iou_threshold: float = 0.3,
init_tracker_min_score: float = 0.0,
measurement_noise: tuple[float, float, float, float] = (1.0, 1.0, 10.0, 0.05),
process_noise: tuple[float, float, float, float, float, float, float] = (
1.0,
1.0,
1.0,
0.001,
0.01,
0.01,
0.0001,
),
) -> Sort:
"""Create a new SORT bbox tracker
Parameters
----------
max_age
maximum frames a tracklet is kept alive without matching detections
min_hits
minimum number of successive detections before a tracklet is set to alive
iou_threshold
minimum IOU to assign detection to tracklet
init_tracker_min_score
minimum score to create a new tracklet from unmatched detection box
measurement_noise
Diagonal of the measurement noise covariance matrix
i.e. uncertainties of (x, y, s, r) measurements
defaults should be reasonable in most cases
process_noise
Diagonal of the process noise covariance matrix
i.e. uncertainties of (x, y, s, r, dx, dy, ds) during each step
defaults should be reasonable in most cases
"""
...
def update(
self, boxes: npt.NDArray[Union[np.float32, np.float64]], return_all: bool
) -> npt.NDArray[np.float32]:
"""Update the tracker with new boxes and return position of current tracklets
Parameters
----------
boxes
array of boxes of shape (n_boxes, 5)
of the form [[xmin1, ymin1, xmax1, ymax1, score1], [xmin2,...],...]
return_all
if true return all living trackers, including inactive (but not dead) ones
otherwise return only active trackers (those that got at least min_hits
matching boxes in a row)
Returns
-------
array of tracklet boxes with shape (n_tracks, 5)
of the form [[xmin1, ymin1, xmax1, ymax1, track_id1], [xmin2,...],...]
"""
...
def get_current_track_boxes(
self, return_all: bool = False
) -> npt.NDArray[np.float32]:
"""Return current track boxes
Parameters
----------
return_all
if true return all living trackers, including inactive (but not dead) ones
otherwise return only active trackers (those that got at least min_hits
matching boxes in a row)
Returns
-------
array of tracklet boxes with shape (n_tracks, 5)
of the form [[xmin1, ymin1, xmax1, ymax1, track_id1], [xmin2,...],...]
"""
...
def clear_trackers(self) -> None:
"""Remove all tracklets"""
...
def remove_tracker(self, track_id: int) -> None:
"""Remove tracklet with the given track_id,
do nothing if it doesn't exist"""
...
class ByteTrack(BaseTracker):
max_age: int
min_hits: int
iou_threshold: float
init_tracker_min_score: float
tracklets: dict[int, KalmanBoxTracker]
n_steps: int
def __new__(
self,
max_age: int = 1,
min_hits: int = 3,
iou_threshold: float = 0.3,
init_tracker_min_score: float = 0.8,
high_score_threshold: float = 0.7,
low_score_threshold: float = 0.1,
measurement_noise: tuple[float, float, float, float] = (1.0, 1.0, 10.0, 0.05),
process_noise: tuple[float, float, float, float, float, float, float] = (
1.0,
1.0,
1.0,
0.001,
0.01,
0.01,
0.0001,
),
) -> ByteTrack:
"""Create a new SORT bbox tracker
Parameters
----------
max_age
maximum frames a tracklet is kept alive without matching detections
min_hits
minimum number of successive detections before a tracklet is set to alive
iou_threshold
minimum IOU to assign detection to tracklet
init_tracker_min_score
minimum score to create a new tracklet from unmatched detection box
high_score_threshold
boxes with higher scores than this will be used in the first round of association
low_score_threshold
boxes with score between low_score_threshold and high_score_threshold
will be used in the second round of association
measurement_noise
Diagonal of the measurement noise covariance matrix
i.e. uncertainties of (x, y, s, r) measurements
defaults should be reasonable in most cases
process_noise
Diagonal of the process noise covariance matrix
i.e. uncertainties of (x, y, s, r, dx, dy, ds) during each step
defaults should be reasonable in most cases
"""
...
def update(
self, boxes: npt.NDArray[Union[np.float32, np.float64]], return_all: bool
) -> npt.NDArray[np.float32]:
"""Update the tracker with new boxes and return position of current tracklets
Parameters
----------
boxes
array of boxes of shape (n_boxes, 5)
of the form [[xmin1, ymin1, xmax1, ymax1, score1], [xmin2,...],...]
return_all
if true return all living trackers, including inactive (but not dead) ones
otherwise return only active trackers (those that got at least min_hits
matching boxes in a row)
Returns
-------
array of tracklet boxes with shape (n_tracks, 5)
of the form [[xmin1, ymin1, xmax1, ymax1, track_id1], [xmin2,...],...]
"""
...
def get_current_track_boxes(
self, return_all: bool = False
) -> npt.NDArray[np.float32]:
"""Return current track boxes
Parameters
----------
return_all
if true return all living trackers, including inactive (but not dead) ones
otherwise return only active trackers (those that got at least min_hits
matching boxes in a row)
Returns
-------
array of tracklet boxes with shape (n_tracks, 5)
of the form [[xmin1, ymin1, xmax1, ymax1, track_id1], [xmin2,...],...]
"""
...
def clear_trackers(self) -> None:
"""Remove all tracklets"""
...
def remove_tracker(self, track_id: int) -> None:
"""Remove tracklet with the given track_id,
do nothing if it doesn't exist"""
...
class Bbox:
xmin: float
ymin: float
xmax: float
ymax: float
class KalmanBoxTracker:
id: int
age: int
hits: int
hit_streak: int
steps_since_hit: int