trackflow-python-tensorrt 0.7.0__cp310-abi3-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- Cargo.lock +132 -0
- LICENSE +202 -0
- README.md +364 -0
- trackflow/__init__.py +93 -0
- trackflow/_accel.py +36 -0
- trackflow/_native.pyd +0 -0
- trackflow/benchmark.py +266 -0
- trackflow/boosttrack.py +476 -0
- trackflow/cli.py +705 -0
- trackflow/detector.py +912 -0
- trackflow/homography.py +240 -0
- trackflow/inspector.py +479 -0
- trackflow/inspector_ui.html +538 -0
- trackflow/lines.py +125 -0
- trackflow/mask_fallback.py +1025 -0
- trackflow/models.py +491 -0
- trackflow/nltrack.py +1107 -0
- trackflow/ocsort.py +406 -0
- trackflow/pipeline.py +1473 -0
- trackflow/postprocess.py +2068 -0
- trackflow/privacy.py +266 -0
- trackflow/py.typed +1 -0
- trackflow/reid.py +985 -0
- trackflow/sam2_adapter.py +222 -0
- trackflow/sinks.py +440 -0
- trackflow/tracker.py +1331 -0
- trackflow/types.py +241 -0
- trackflow_python_tensorrt-0.7.0.dist-info/METADATA +421 -0
- trackflow_python_tensorrt-0.7.0.dist-info/RECORD +33 -0
- trackflow_python_tensorrt-0.7.0.dist-info/WHEEL +4 -0
- trackflow_python_tensorrt-0.7.0.dist-info/entry_points.txt +3 -0
- trackflow_python_tensorrt-0.7.0.dist-info/licenses/LICENSE +202 -0
- trackflow_python_tensorrt-0.7.0.dist-info/sboms/trackflow-native.cyclonedx.json +536 -0
trackflow/types.py
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
"""Core data models shared across detectors, trackers, Re-ID, spatial analytics, and sinks."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass, field
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
import numpy as np
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@dataclass(slots=True)
|
|
12
|
+
class Detection:
|
|
13
|
+
"""Single object detection in pixel coordinates (x1, y1, x2, y2)."""
|
|
14
|
+
|
|
15
|
+
bbox: tuple[float, float, float, float]
|
|
16
|
+
confidence: float
|
|
17
|
+
class_id: int
|
|
18
|
+
class_name: str
|
|
19
|
+
embedding: np.ndarray | None = field(default=None, repr=False)
|
|
20
|
+
|
|
21
|
+
@property
|
|
22
|
+
def width(self) -> float:
|
|
23
|
+
return max(0.0, self.bbox[2] - self.bbox[0])
|
|
24
|
+
|
|
25
|
+
@property
|
|
26
|
+
def height(self) -> float:
|
|
27
|
+
return max(0.0, self.bbox[3] - self.bbox[1])
|
|
28
|
+
|
|
29
|
+
@property
|
|
30
|
+
def area(self) -> float:
|
|
31
|
+
return self.width * self.height
|
|
32
|
+
|
|
33
|
+
@property
|
|
34
|
+
def center(self) -> tuple[float, float]:
|
|
35
|
+
return ((self.bbox[0] + self.bbox[2]) * 0.5, (self.bbox[1] + self.bbox[3]) * 0.5)
|
|
36
|
+
|
|
37
|
+
@property
|
|
38
|
+
def foot_point(self) -> tuple[float, float]:
|
|
39
|
+
"""Bottom-center ground contact point used for floorplan homography."""
|
|
40
|
+
return ((self.bbox[0] + self.bbox[2]) * 0.5, self.bbox[3])
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@dataclass(slots=True)
|
|
44
|
+
class Track:
|
|
45
|
+
"""Active tracked object at a specific frame."""
|
|
46
|
+
|
|
47
|
+
track_id: int
|
|
48
|
+
bbox: tuple[float, float, float, float]
|
|
49
|
+
confidence: float
|
|
50
|
+
class_id: int
|
|
51
|
+
class_name: str
|
|
52
|
+
age: int = 1
|
|
53
|
+
hits: int = 1
|
|
54
|
+
recovered: bool = False
|
|
55
|
+
coasting: bool = False # predicted position of a briefly-missed track (display only)
|
|
56
|
+
query_score: float | None = None
|
|
57
|
+
query_match: bool = True
|
|
58
|
+
world_xy: tuple[float, float] | None = None
|
|
59
|
+
zone: str | None = None
|
|
60
|
+
reid_merged_from: int | None = None
|
|
61
|
+
|
|
62
|
+
@property
|
|
63
|
+
def width(self) -> float:
|
|
64
|
+
return max(0.0, self.bbox[2] - self.bbox[0])
|
|
65
|
+
|
|
66
|
+
@property
|
|
67
|
+
def height(self) -> float:
|
|
68
|
+
return max(0.0, self.bbox[3] - self.bbox[1])
|
|
69
|
+
|
|
70
|
+
@property
|
|
71
|
+
def foot_point(self) -> tuple[float, float]:
|
|
72
|
+
return ((self.bbox[0] + self.bbox[2]) * 0.5, self.bbox[3])
|
|
73
|
+
|
|
74
|
+
def to_record(self, frame_idx: int, timestamp_s: float) -> dict[str, Any]:
|
|
75
|
+
x1, y1, x2, y2 = self.bbox
|
|
76
|
+
return {
|
|
77
|
+
"frame_idx": int(frame_idx),
|
|
78
|
+
"timestamp_s": round(float(timestamp_s), 4),
|
|
79
|
+
"track_id": int(self.track_id),
|
|
80
|
+
"class_id": int(self.class_id),
|
|
81
|
+
"class_name": str(self.class_name),
|
|
82
|
+
"confidence": round(float(self.confidence), 4),
|
|
83
|
+
"x1": round(float(x1), 2),
|
|
84
|
+
"y1": round(float(y1), 2),
|
|
85
|
+
"x2": round(float(x2), 2),
|
|
86
|
+
"y2": round(float(y2), 2),
|
|
87
|
+
"width": round(float(x2 - x1), 2),
|
|
88
|
+
"height": round(float(y2 - y1), 2),
|
|
89
|
+
"age": int(self.age),
|
|
90
|
+
"hits": int(self.hits),
|
|
91
|
+
"recovered": bool(self.recovered),
|
|
92
|
+
"query_score": None if self.query_score is None else round(float(self.query_score), 4),
|
|
93
|
+
"query_match": bool(self.query_match),
|
|
94
|
+
"world_x": None if self.world_xy is None else round(float(self.world_xy[0]), 3),
|
|
95
|
+
"world_y": None if self.world_xy is None else round(float(self.world_xy[1]), 3),
|
|
96
|
+
"zone": self.zone,
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
@dataclass(slots=True)
|
|
101
|
+
class FrameResult:
|
|
102
|
+
"""Per-frame tracking output and timing telemetry."""
|
|
103
|
+
|
|
104
|
+
frame_idx: int
|
|
105
|
+
timestamp_s: float
|
|
106
|
+
tracks: list[Track]
|
|
107
|
+
num_detections: int
|
|
108
|
+
inference_ms: float
|
|
109
|
+
tracking_ms: float
|
|
110
|
+
events: list[dict[str, Any]] = field(default_factory=list)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
@dataclass(slots=True)
|
|
114
|
+
class TrackCard:
|
|
115
|
+
"""Persistent entity summary for a tracked person/object across its lifetime."""
|
|
116
|
+
|
|
117
|
+
track_id: int
|
|
118
|
+
class_name: str
|
|
119
|
+
first_frame: int
|
|
120
|
+
last_frame: int
|
|
121
|
+
first_timestamp_s: float
|
|
122
|
+
last_timestamp_s: float
|
|
123
|
+
frame_count: int
|
|
124
|
+
best_confidence: float
|
|
125
|
+
best_frame: int
|
|
126
|
+
best_bbox: tuple[float, float, float, float]
|
|
127
|
+
thumbnail_relpath: str | None = None
|
|
128
|
+
embedding: list[float] | None = None
|
|
129
|
+
query_score: float | None = None
|
|
130
|
+
query_match: bool = True
|
|
131
|
+
merged_track_ids: list[int] = field(default_factory=list)
|
|
132
|
+
zones_visited: list[str] = field(default_factory=list)
|
|
133
|
+
dwell_seconds: dict[str, float] = field(default_factory=dict)
|
|
134
|
+
|
|
135
|
+
@property
|
|
136
|
+
def duration_s(self) -> float:
|
|
137
|
+
return max(0.0, self.last_timestamp_s - self.first_timestamp_s)
|
|
138
|
+
|
|
139
|
+
def to_dict(self, include_embedding: bool = True) -> dict[str, Any]:
|
|
140
|
+
data: dict[str, Any] = {
|
|
141
|
+
"track_id": self.track_id,
|
|
142
|
+
"class_name": self.class_name,
|
|
143
|
+
"first_frame": self.first_frame,
|
|
144
|
+
"last_frame": self.last_frame,
|
|
145
|
+
"first_timestamp_s": round(self.first_timestamp_s, 3),
|
|
146
|
+
"last_timestamp_s": round(self.last_timestamp_s, 3),
|
|
147
|
+
"duration_s": round(self.duration_s, 3),
|
|
148
|
+
"frame_count": self.frame_count,
|
|
149
|
+
"best_confidence": round(self.best_confidence, 4),
|
|
150
|
+
"best_frame": self.best_frame,
|
|
151
|
+
"best_bbox": [round(float(v), 2) for v in self.best_bbox],
|
|
152
|
+
"thumbnail": self.thumbnail_relpath,
|
|
153
|
+
"query_score": None if self.query_score is None else round(self.query_score, 4),
|
|
154
|
+
"query_match": self.query_match,
|
|
155
|
+
"merged_track_ids": list(self.merged_track_ids),
|
|
156
|
+
"zones_visited": list(self.zones_visited),
|
|
157
|
+
"dwell_seconds": {k: round(v, 3) for k, v in self.dwell_seconds.items()},
|
|
158
|
+
}
|
|
159
|
+
if include_embedding and self.embedding is not None:
|
|
160
|
+
data["embedding"] = self.embedding
|
|
161
|
+
return data
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
@dataclass(slots=True)
|
|
165
|
+
class HomographyPoint:
|
|
166
|
+
"""A 2D image-to-floorplan calibration correspondence."""
|
|
167
|
+
|
|
168
|
+
image_xy: tuple[float, float]
|
|
169
|
+
world_xy: tuple[float, float]
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
@dataclass(slots=True)
|
|
173
|
+
class RunSummary:
|
|
174
|
+
"""Aggregate summary of a completed Trackflow run."""
|
|
175
|
+
|
|
176
|
+
source: str
|
|
177
|
+
model: str
|
|
178
|
+
tracker: str
|
|
179
|
+
device: str
|
|
180
|
+
total_frames: int
|
|
181
|
+
processed_frames: int
|
|
182
|
+
source_fps: float
|
|
183
|
+
avg_fps: float
|
|
184
|
+
avg_inference_ms: float
|
|
185
|
+
avg_tracking_ms: float
|
|
186
|
+
total_detections: int
|
|
187
|
+
total_track_observations: int
|
|
188
|
+
unique_tracks: int
|
|
189
|
+
recovered_tracks: int
|
|
190
|
+
reid_merges: int
|
|
191
|
+
elapsed_s: float
|
|
192
|
+
frame_width: int
|
|
193
|
+
frame_height: int
|
|
194
|
+
classes: list[str]
|
|
195
|
+
query: str | None = None
|
|
196
|
+
anonymize_mode: str = "none"
|
|
197
|
+
output_files: dict[str, str] = field(default_factory=dict)
|
|
198
|
+
zone_dwell_totals_s: dict[str, float] = field(default_factory=dict)
|
|
199
|
+
line_counts: dict[str, dict[str, int]] = field(default_factory=dict)
|
|
200
|
+
frame_stride: int = 1
|
|
201
|
+
model_revision: str | None = None
|
|
202
|
+
precision: str | None = None
|
|
203
|
+
tracking_threshold: float | None = None
|
|
204
|
+
mask_fallback: dict[str, Any] | None = None
|
|
205
|
+
postprocessed: bool = False
|
|
206
|
+
|
|
207
|
+
def to_dict(self) -> dict[str, Any]:
|
|
208
|
+
out: dict[str, Any] = {
|
|
209
|
+
"source": self.source,
|
|
210
|
+
"model": self.model,
|
|
211
|
+
"model_revision": self.model_revision,
|
|
212
|
+
"precision": self.precision,
|
|
213
|
+
"tracking_threshold": self.tracking_threshold,
|
|
214
|
+
"tracker": self.tracker,
|
|
215
|
+
"postprocessed": self.postprocessed,
|
|
216
|
+
"device": self.device,
|
|
217
|
+
"total_frames": self.total_frames,
|
|
218
|
+
"processed_frames": self.processed_frames,
|
|
219
|
+
"source_fps": round(self.source_fps, 2),
|
|
220
|
+
"frame_stride": self.frame_stride,
|
|
221
|
+
"avg_fps": round(self.avg_fps, 2),
|
|
222
|
+
"avg_inference_ms": round(self.avg_inference_ms, 2),
|
|
223
|
+
"avg_tracking_ms": round(self.avg_tracking_ms, 2),
|
|
224
|
+
"total_detections": self.total_detections,
|
|
225
|
+
"total_track_observations": self.total_track_observations,
|
|
226
|
+
"unique_tracks": self.unique_tracks,
|
|
227
|
+
"recovered_tracks": self.recovered_tracks,
|
|
228
|
+
"reid_merges": self.reid_merges,
|
|
229
|
+
"elapsed_s": round(self.elapsed_s, 3),
|
|
230
|
+
"frame_width": self.frame_width,
|
|
231
|
+
"frame_height": self.frame_height,
|
|
232
|
+
"classes": self.classes,
|
|
233
|
+
"query": self.query,
|
|
234
|
+
"anonymize_mode": self.anonymize_mode,
|
|
235
|
+
"output_files": self.output_files,
|
|
236
|
+
"zone_dwell_totals_s": {k: round(v, 2) for k, v in self.zone_dwell_totals_s.items()},
|
|
237
|
+
"line_counts": self.line_counts,
|
|
238
|
+
}
|
|
239
|
+
if self.mask_fallback is not None:
|
|
240
|
+
out["mask_fallback"] = self.mask_fallback
|
|
241
|
+
return out
|