dnt 0.3.2.2__tar.gz → 0.3.2.4__tar.gz
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.
- {dnt-0.3.2.2/dnt.egg-info → dnt-0.3.2.4}/PKG-INFO +1 -1
- {dnt-0.3.2.2 → dnt-0.3.2.4}/pyproject.toml +5 -2
- {dnt-0.3.2.2 → dnt-0.3.2.4}/src/dnt/__init__.py +1 -1
- {dnt-0.3.2.2 → dnt-0.3.2.4}/src/dnt/detect/yolo/detector.py +17 -18
- {dnt-0.3.2.2 → dnt-0.3.2.4}/src/dnt/filter/filter.py +34 -29
- {dnt-0.3.2.2 → dnt-0.3.2.4}/src/dnt/track/__init__.py +8 -3
- {dnt-0.3.2.2 → dnt-0.3.2.4}/src/dnt/track/tracker.py +26 -12
- {dnt-0.3.2.2 → dnt-0.3.2.4/src/dnt.egg-info}/PKG-INFO +1 -1
- {dnt-0.3.2.2 → dnt-0.3.2.4/src}/dnt.egg-info/SOURCES.txt +5 -16
- dnt-0.3.2.4/src/dnt.egg-info/top_level.txt +1 -0
- dnt-0.3.2.2/dnt.egg-info/top_level.txt +0 -6
- dnt-0.3.2.2/examples/example.py +0 -43
- dnt-0.3.2.2/examples/example_batch.py +0 -42
- dnt-0.3.2.2/examples/example_extract_frames.py +0 -16
- dnt-0.3.2.2/examples/example_filter.py +0 -65
- dnt-0.3.2.2/examples/example_label.py +0 -73
- dnt-0.3.2.2/examples/example_post-tracklets.py +0 -51
- dnt-0.3.2.2/examples/example_post.py +0 -44
- dnt-0.3.2.2/examples/example_shapes.py +0 -26
- dnt-0.3.2.2/examples/example_shapes_v2.py +0 -34
- dnt-0.3.2.2/examples/example_stop.py +0 -50
- dnt-0.3.2.2/examples/example_track.py +0 -45
- {dnt-0.3.2.2 → dnt-0.3.2.4}/LICENSE.md +0 -0
- {dnt-0.3.2.2 → dnt-0.3.2.4}/MANIFEST.in +0 -0
- {dnt-0.3.2.2 → dnt-0.3.2.4}/README.md +0 -0
- {dnt-0.3.2.2 → dnt-0.3.2.4}/setup.cfg +0 -0
- {dnt-0.3.2.2 → dnt-0.3.2.4}/src/dnt/detect/__init__.py +0 -0
- {dnt-0.3.2.2 → dnt-0.3.2.4}/src/dnt/detect/signal/__init__.py +0 -0
- {dnt-0.3.2.2 → dnt-0.3.2.4}/src/dnt/detect/signal/detector.py +0 -0
- {dnt-0.3.2.2 → dnt-0.3.2.4}/src/dnt/detect/timestamp.py +0 -0
- {dnt-0.3.2.2 → dnt-0.3.2.4}/src/dnt/detect/yolo/__init__.py +0 -0
- {dnt-0.3.2.2 → dnt-0.3.2.4}/src/dnt/detect/yolo/segmentor.py +0 -0
- {dnt-0.3.2.2 → dnt-0.3.2.4}/src/dnt/engine/__init__.py +0 -0
- {dnt-0.3.2.2 → dnt-0.3.2.4}/src/dnt/engine/bbox_interp.py +0 -0
- {dnt-0.3.2.2 → dnt-0.3.2.4}/src/dnt/engine/bbox_iou.py +0 -0
- {dnt-0.3.2.2 → dnt-0.3.2.4}/src/dnt/engine/cluster.py +0 -0
- {dnt-0.3.2.2 → dnt-0.3.2.4}/src/dnt/engine/iob.py +0 -0
- {dnt-0.3.2.2 → dnt-0.3.2.4}/src/dnt/filter/__init__.py +0 -0
- {dnt-0.3.2.2 → dnt-0.3.2.4}/src/dnt/label/__init__.py +0 -0
- {dnt-0.3.2.2 → dnt-0.3.2.4}/src/dnt/label/labeler.py +0 -0
- {dnt-0.3.2.2 → dnt-0.3.2.4}/src/dnt/shared/__init__.py +0 -0
- {dnt-0.3.2.2 → dnt-0.3.2.4}/src/dnt/shared/download.py +0 -0
- {dnt-0.3.2.2 → dnt-0.3.2.4}/src/dnt/shared/files.py +0 -0
- {dnt-0.3.2.2 → dnt-0.3.2.4}/src/dnt/shared/filter.py +0 -0
- {dnt-0.3.2.2 → dnt-0.3.2.4}/src/dnt/shared/synhcro.py +0 -0
- {dnt-0.3.2.2 → dnt-0.3.2.4}/src/dnt/shared/util.py +0 -0
- {dnt-0.3.2.2 → dnt-0.3.2.4}/src/dnt/track/post_process.py +0 -0
- {dnt-0.3.2.2 → dnt-0.3.2.4}/src/dnt/track/re_class.py +0 -0
- {dnt-0.3.2.2 → dnt-0.3.2.4/src}/dnt.egg-info/dependency_links.txt +0 -0
- {dnt-0.3.2.2 → dnt-0.3.2.4/src}/dnt.egg-info/requires.txt +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "dnt"
|
|
7
|
-
version = "0.3.2.
|
|
7
|
+
version = "0.3.2.4"
|
|
8
8
|
description = "A Python tool for video-based traffic analytiscs"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.9"
|
|
@@ -81,8 +81,11 @@ Homepage = "https://github.com/wonstran/dnt"
|
|
|
81
81
|
[tool.setuptools]
|
|
82
82
|
include-package-data = true
|
|
83
83
|
|
|
84
|
+
[tool.setuptools.package-dir]
|
|
85
|
+
"" = "src"
|
|
86
|
+
|
|
84
87
|
[tool.setuptools.packages.find]
|
|
85
|
-
where = ["
|
|
88
|
+
where = ["src"]
|
|
86
89
|
|
|
87
90
|
[tool.ruff]
|
|
88
91
|
line-length = 100
|
|
@@ -213,7 +213,7 @@ class Detector:
|
|
|
213
213
|
end_frame: int | None = None,
|
|
214
214
|
verbose: bool = True,
|
|
215
215
|
show: bool = False,
|
|
216
|
-
|
|
216
|
+
message: str | None = None,
|
|
217
217
|
) -> pd.DataFrame:
|
|
218
218
|
"""Run object detection on a video and return per-frame detections.
|
|
219
219
|
|
|
@@ -235,8 +235,9 @@ class Detector:
|
|
|
235
235
|
Whether to show a progress bar. Default is True.
|
|
236
236
|
show : bool, optional
|
|
237
237
|
Whether to display the video frames with detections. Default is False.
|
|
238
|
-
|
|
239
|
-
|
|
238
|
+
message : str | None, optional
|
|
239
|
+
Optional message shown in the progress bar description.
|
|
240
|
+
Default is None.
|
|
240
241
|
|
|
241
242
|
Returns
|
|
242
243
|
-------
|
|
@@ -270,21 +271,18 @@ class Detector:
|
|
|
270
271
|
|
|
271
272
|
# Some codecs return 0 or -1 for frame count
|
|
272
273
|
if verbose:
|
|
273
|
-
if tot_frames <= 0:
|
|
274
|
-
pbar = tqdm(desc="Detecting", unit="frame")
|
|
275
|
-
else:
|
|
276
|
-
pbar = tqdm(total=frame_total, desc="Detecting", unit="frame")
|
|
277
|
-
|
|
278
274
|
if (video_index is not None) and (video_tot is not None):
|
|
279
275
|
desc = f"Detecting {video_index} of {video_tot}"
|
|
280
|
-
if disp_filename:
|
|
281
|
-
desc += f" - {Path(input_video).name}"
|
|
282
|
-
pbar.set_description_str(desc)
|
|
283
276
|
else:
|
|
284
277
|
desc = "Detecting"
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
278
|
+
|
|
279
|
+
if message is not None:
|
|
280
|
+
desc += f" {message}"
|
|
281
|
+
|
|
282
|
+
if tot_frames <= 0:
|
|
283
|
+
pbar = tqdm(desc=desc, unit="frame")
|
|
284
|
+
else:
|
|
285
|
+
pbar = tqdm(total=frame_total, desc=desc, unit="frame")
|
|
288
286
|
|
|
289
287
|
results: list[dict] = []
|
|
290
288
|
frame_idx = start_frame
|
|
@@ -508,7 +506,7 @@ class Detector:
|
|
|
508
506
|
is_overwrite: bool = False,
|
|
509
507
|
is_report: bool = True,
|
|
510
508
|
verbose: bool = True,
|
|
511
|
-
|
|
509
|
+
message: str | None = None,
|
|
512
510
|
) -> list[str]:
|
|
513
511
|
"""Run detection on multiple videos and optionally write per-video output files.
|
|
514
512
|
|
|
@@ -527,8 +525,9 @@ class Detector:
|
|
|
527
525
|
included in the returned list.
|
|
528
526
|
verbose : bool, optional
|
|
529
527
|
If True, prints progress messages. Default is True.
|
|
530
|
-
|
|
531
|
-
|
|
528
|
+
message : str | None, optional
|
|
529
|
+
Optional message shown in each progress bar description.
|
|
530
|
+
Default is None.
|
|
532
531
|
|
|
533
532
|
Returns
|
|
534
533
|
-------
|
|
@@ -564,7 +563,7 @@ class Detector:
|
|
|
564
563
|
video_index=idx,
|
|
565
564
|
video_tot=total_videos,
|
|
566
565
|
verbose=verbose,
|
|
567
|
-
|
|
566
|
+
message=message,
|
|
568
567
|
)
|
|
569
568
|
|
|
570
569
|
if iou_file is not None:
|
|
@@ -180,18 +180,21 @@ class Filter:
|
|
|
180
180
|
video_index: int | None = None,
|
|
181
181
|
video_tot: int | None = None,
|
|
182
182
|
) -> pd.DataFrame:
|
|
183
|
-
"""Filter tracks by zones.
|
|
183
|
+
"""Filter tracks by polygon zones using an aggregate ID match.
|
|
184
|
+
|
|
184
185
|
Inputs:
|
|
185
|
-
tracks
|
|
186
|
-
zones
|
|
187
|
-
method - 'include' (default)
|
|
188
|
-
ref_point -
|
|
189
|
-
|
|
190
|
-
offset -
|
|
191
|
-
video_index - video index
|
|
192
|
-
video_tot - total
|
|
193
|
-
|
|
194
|
-
|
|
186
|
+
tracks - input tracks.
|
|
187
|
+
zones - polygons used for matching.
|
|
188
|
+
method - 'include' (default) or 'exclude'.
|
|
189
|
+
ref_point - bbox reference point (default: 'bc'); options include
|
|
190
|
+
bl, bc, br, tl, tc, tr, cl, cc, cr.
|
|
191
|
+
offset - offset applied to the reference point, default is (0, 0).
|
|
192
|
+
video_index - video index for progress display.
|
|
193
|
+
video_tot - total video count for progress display.
|
|
194
|
+
|
|
195
|
+
Returns:
|
|
196
|
+
Filtered tracks.
|
|
197
|
+
|
|
195
198
|
"""
|
|
196
199
|
if offset is None:
|
|
197
200
|
offset = (0, 0)
|
|
@@ -299,17 +302,20 @@ class Filter:
|
|
|
299
302
|
video_index: int | None = None,
|
|
300
303
|
video_tot: int | None = None,
|
|
301
304
|
) -> pd.DataFrame:
|
|
302
|
-
"""Filter
|
|
305
|
+
"""Filter frame rows by polygon zones.
|
|
306
|
+
|
|
303
307
|
Inputs:
|
|
304
|
-
tracks - tracks
|
|
305
|
-
zones -
|
|
306
|
-
method - 'include' (default)
|
|
307
|
-
ref_point -
|
|
308
|
-
offset -
|
|
309
|
-
video_index - video index
|
|
310
|
-
video_tot - total
|
|
311
|
-
|
|
312
|
-
|
|
308
|
+
tracks - input tracks.
|
|
309
|
+
zones - polygons used for matching.
|
|
310
|
+
method - 'include' (default) keeps matching rows; 'exclude' drops them.
|
|
311
|
+
ref_point - bbox reference point (default: 'bc').
|
|
312
|
+
offset - offset applied to the reference point, default is (0, 0).
|
|
313
|
+
video_index - video index for progress display.
|
|
314
|
+
video_tot - total video count for progress display.
|
|
315
|
+
|
|
316
|
+
Returns:
|
|
317
|
+
Filtered frame rows.
|
|
318
|
+
|
|
313
319
|
"""
|
|
314
320
|
if offset is None:
|
|
315
321
|
offset = (0, 0)
|
|
@@ -427,7 +433,7 @@ class Filter:
|
|
|
427
433
|
'filter' - filter tracks within zones
|
|
428
434
|
'label' - label tracks with zone index
|
|
429
435
|
ref_point - the reference point of a track bbox,
|
|
430
|
-
br -
|
|
436
|
+
br - bottom_right,
|
|
431
437
|
bl - bottom_left
|
|
432
438
|
bc - bottom_center
|
|
433
439
|
cc - center_point,
|
|
@@ -437,11 +443,10 @@ class Filter:
|
|
|
437
443
|
tl - top_left,
|
|
438
444
|
tr - top_right,
|
|
439
445
|
offset - the offset to ref_point, default is (0, 0)
|
|
440
|
-
|
|
441
|
-
zone_name - if aggregate, the field name of zone variable, default is 'zone'
|
|
446
|
+
zone_name - field name used when method='label', default is 'zone'
|
|
442
447
|
video_index - video index
|
|
443
448
|
video_tot - total videos
|
|
444
|
-
|
|
449
|
+
Returns:
|
|
445
450
|
Filtered tracks
|
|
446
451
|
"""
|
|
447
452
|
if offset is None:
|
|
@@ -538,7 +543,7 @@ class Filter:
|
|
|
538
543
|
the lines, exclude - exclude tracks crossing the lines
|
|
539
544
|
video_index - the index of video for processing
|
|
540
545
|
video_tot - the total number of videos
|
|
541
|
-
|
|
546
|
+
Returns:
|
|
542
547
|
a DataFrame of [FRAME, TRACK_ID, TOPX, TOPY, WIDTH, LENGTH, RESERVED, RESERVED, RESERVED]
|
|
543
548
|
"""
|
|
544
549
|
track_ids = tracks[1].unique()
|
|
@@ -601,13 +606,13 @@ class Filter:
|
|
|
601
606
|
lines - a list of LineString
|
|
602
607
|
method - filtering method, include (default) - including tracks crossing the
|
|
603
608
|
lines, exclude - exclude tracks crossing the lines
|
|
604
|
-
tolerance - if a bbox
|
|
609
|
+
tolerance - if a bbox intersects the reference lines of (number of lanes -
|
|
605
610
|
tolerance), it is hit. default is 0.
|
|
606
611
|
force_line_indexes: the line indexes that a bbox must intersect for matching
|
|
607
|
-
bbox_size - the size of detection bbox, default is 0 - the
|
|
612
|
+
bbox_size - the size of detection bbox, default is 0 - the original bbox
|
|
608
613
|
video_index - the index of video for processing
|
|
609
614
|
video_tot - the total number of videos
|
|
610
|
-
|
|
615
|
+
Returns:
|
|
611
616
|
a DataFrame of [FRAME, TRACK_ID, TOPX, TOPY, WIDTH, LENGTH, RESERVED,
|
|
612
617
|
RESERVED, RESERVED]
|
|
613
618
|
"""
|
|
@@ -21,7 +21,7 @@ from .tracker import (
|
|
|
21
21
|
BoostTrackConfig as BoostTrackConfig,
|
|
22
22
|
)
|
|
23
23
|
from .tracker import (
|
|
24
|
-
BoTSORTConfig as
|
|
24
|
+
BoTSORTConfig as BoTSORTConfig,
|
|
25
25
|
)
|
|
26
26
|
from .tracker import (
|
|
27
27
|
ByteTrackConfig as ByteTrackConfig,
|
|
@@ -54,8 +54,12 @@ from .tracker import (
|
|
|
54
54
|
Tracker as Tracker,
|
|
55
55
|
)
|
|
56
56
|
|
|
57
|
+
# Backward-compat aliases for historical exported names.
|
|
58
|
+
BOTSORTConfig = BoTSORTConfig
|
|
59
|
+
SFSortConfig = SFSORTConfig
|
|
60
|
+
|
|
57
61
|
__all__ = [
|
|
58
|
-
"
|
|
62
|
+
"BoTSORTConfig",
|
|
59
63
|
"BoostTrackConfig",
|
|
60
64
|
"ByteTrackConfig",
|
|
61
65
|
"DeepOCSORTConfig",
|
|
@@ -66,7 +70,8 @@ __all__ = [
|
|
|
66
70
|
"ReClass",
|
|
67
71
|
"ReIDWeights",
|
|
68
72
|
"SFSORTConfig",
|
|
69
|
-
"SFSortConfig",
|
|
70
73
|
"StrongSORTConfig",
|
|
71
74
|
"Tracker",
|
|
75
|
+
"interpolate_tracks_rts",
|
|
76
|
+
"link_tracklets",
|
|
72
77
|
]
|
|
@@ -690,15 +690,16 @@ class Tracker:
|
|
|
690
690
|
video_file: str | None = None,
|
|
691
691
|
show: bool = False,
|
|
692
692
|
video_index: int | None = None,
|
|
693
|
-
|
|
693
|
+
video_tot: int | None = None,
|
|
694
|
+
message: str | None = None,
|
|
694
695
|
) -> pd.DataFrame:
|
|
695
696
|
"""Run tracking on a single detection file using BoxMOT.
|
|
696
697
|
|
|
697
698
|
Parameters
|
|
698
699
|
----------
|
|
699
700
|
det_file : str
|
|
700
|
-
Path to detection file
|
|
701
|
-
frame,
|
|
701
|
+
Path to detection file in DNT detection format
|
|
702
|
+
(frame, -, x, y, width, height, confidence, class_id).
|
|
702
703
|
out_file : str
|
|
703
704
|
Path to write tracking results. If empty string, results are not saved.
|
|
704
705
|
video_file : str, optional
|
|
@@ -709,8 +710,11 @@ class Tracker:
|
|
|
709
710
|
'q' to stop tracking early.
|
|
710
711
|
video_index : int, optional
|
|
711
712
|
Index of current video in batch (for progress bar display).
|
|
712
|
-
|
|
713
|
+
video_tot : int, optional
|
|
713
714
|
Total number of videos in batch (for complete progress context).
|
|
715
|
+
message : str | None, optional
|
|
716
|
+
Optional progress text shown in the progress bar. If None, the
|
|
717
|
+
video stem is used (default: None).
|
|
714
718
|
|
|
715
719
|
Returns
|
|
716
720
|
-------
|
|
@@ -752,7 +756,8 @@ class Tracker:
|
|
|
752
756
|
out_file=out_file,
|
|
753
757
|
show=show,
|
|
754
758
|
video_index=video_index,
|
|
755
|
-
|
|
759
|
+
video_tot=video_tot,
|
|
760
|
+
message=message,
|
|
756
761
|
)
|
|
757
762
|
|
|
758
763
|
def track_batch(
|
|
@@ -762,6 +767,7 @@ class Tracker:
|
|
|
762
767
|
output_path: str | None = None,
|
|
763
768
|
is_overwrite: bool = False,
|
|
764
769
|
is_report: bool = True,
|
|
770
|
+
message: str | None = None,
|
|
765
771
|
) -> list[str]:
|
|
766
772
|
"""Run tracking on multiple detection files sequentially.
|
|
767
773
|
|
|
@@ -781,6 +787,9 @@ class Tracker:
|
|
|
781
787
|
If False (default), skip tracking for videos with existing output files.
|
|
782
788
|
is_report : bool, optional
|
|
783
789
|
If True (default), include skipped files in returned list.
|
|
790
|
+
message : str | None, optional
|
|
791
|
+
Optional progress text shown in each tracking progress bar.
|
|
792
|
+
If None (default), each video's stem is used.
|
|
784
793
|
|
|
785
794
|
Returns
|
|
786
795
|
-------
|
|
@@ -829,7 +838,8 @@ class Tracker:
|
|
|
829
838
|
out_file=track_file if track_file else "", # track() expects a path
|
|
830
839
|
video_file=video_file,
|
|
831
840
|
video_index=idx,
|
|
832
|
-
|
|
841
|
+
video_tot=total_videos,
|
|
842
|
+
message=message,
|
|
833
843
|
)
|
|
834
844
|
|
|
835
845
|
if track_file:
|
|
@@ -1083,7 +1093,8 @@ class Tracker:
|
|
|
1083
1093
|
out_file: str,
|
|
1084
1094
|
show: bool = False,
|
|
1085
1095
|
video_index: int | None = None,
|
|
1086
|
-
|
|
1096
|
+
video_tot: int | None = None,
|
|
1097
|
+
message: str | None = None,
|
|
1087
1098
|
) -> pd.DataFrame:
|
|
1088
1099
|
"""Execute BoxMOT tracking on one video with corresponding detections.
|
|
1089
1100
|
|
|
@@ -1103,8 +1114,11 @@ class Tracker:
|
|
|
1103
1114
|
If True, display tracking preview (default: False).
|
|
1104
1115
|
video_index : int | None, optional
|
|
1105
1116
|
Index in batch progression (for UI display).
|
|
1106
|
-
|
|
1117
|
+
video_tot : int | None, optional
|
|
1107
1118
|
Total videos in batch (for UI display).
|
|
1119
|
+
message : str | None, optional
|
|
1120
|
+
Optional progress text shown in the progress bar. If None, the
|
|
1121
|
+
video stem is used.
|
|
1108
1122
|
|
|
1109
1123
|
Returns
|
|
1110
1124
|
-------
|
|
@@ -1112,7 +1126,6 @@ class Tracker:
|
|
|
1112
1126
|
Tracking results with TRACK_FIELDS columns.
|
|
1113
1127
|
|
|
1114
1128
|
"""
|
|
1115
|
-
"""Run BoxMOT tracking on one video/detection pair and return track records."""
|
|
1116
1129
|
detections = pd.read_csv(det_file, header=None).to_numpy()
|
|
1117
1130
|
if detections.size == 0 or len(detections) == 0:
|
|
1118
1131
|
return pd.DataFrame(columns=self.TRACK_FIELDS)
|
|
@@ -1134,10 +1147,11 @@ class Tracker:
|
|
|
1134
1147
|
half=self.half,
|
|
1135
1148
|
)
|
|
1136
1149
|
|
|
1137
|
-
|
|
1150
|
+
pbar_message = message if message is not None else Path(video_file).stem
|
|
1151
|
+
desc = f"Tracking {pbar_message}"
|
|
1138
1152
|
pbar = tqdm(total=total_frames, desc=desc, unit="frames")
|
|
1139
|
-
if video_index is not None and
|
|
1140
|
-
pbar.set_description_str(f"Tracking {video_index} of {
|
|
1153
|
+
if video_index is not None and video_tot is not None:
|
|
1154
|
+
pbar.set_description_str(f"Tracking {video_index} of {video_tot} - {pbar_message}")
|
|
1141
1155
|
|
|
1142
1156
|
results: list[list[float | int]] = []
|
|
1143
1157
|
cap.set(cv2.CAP_PROP_POS_FRAMES, start_frame)
|
|
@@ -2,23 +2,12 @@ LICENSE.md
|
|
|
2
2
|
MANIFEST.in
|
|
3
3
|
README.md
|
|
4
4
|
pyproject.toml
|
|
5
|
-
dnt.egg-info/PKG-INFO
|
|
6
|
-
dnt.egg-info/SOURCES.txt
|
|
7
|
-
dnt.egg-info/dependency_links.txt
|
|
8
|
-
dnt.egg-info/requires.txt
|
|
9
|
-
dnt.egg-info/top_level.txt
|
|
10
|
-
examples/example.py
|
|
11
|
-
examples/example_batch.py
|
|
12
|
-
examples/example_extract_frames.py
|
|
13
|
-
examples/example_filter.py
|
|
14
|
-
examples/example_label.py
|
|
15
|
-
examples/example_post-tracklets.py
|
|
16
|
-
examples/example_post.py
|
|
17
|
-
examples/example_shapes.py
|
|
18
|
-
examples/example_shapes_v2.py
|
|
19
|
-
examples/example_stop.py
|
|
20
|
-
examples/example_track.py
|
|
21
5
|
src/dnt/__init__.py
|
|
6
|
+
src/dnt.egg-info/PKG-INFO
|
|
7
|
+
src/dnt.egg-info/SOURCES.txt
|
|
8
|
+
src/dnt.egg-info/dependency_links.txt
|
|
9
|
+
src/dnt.egg-info/requires.txt
|
|
10
|
+
src/dnt.egg-info/top_level.txt
|
|
22
11
|
src/dnt/detect/__init__.py
|
|
23
12
|
src/dnt/detect/timestamp.py
|
|
24
13
|
src/dnt/detect/signal/__init__.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
dnt
|
dnt-0.3.2.2/examples/example.py
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import pathlib
|
|
2
|
-
import sys
|
|
3
|
-
|
|
4
|
-
root = pathlib.Path(__file__).resolve().parents[1]
|
|
5
|
-
sys.path.insert(0, str(root / "src"))
|
|
6
|
-
|
|
7
|
-
from dnt.detect import Detector # noqa: E402
|
|
8
|
-
from dnt.label.labeler import Labeler # noqa: E402
|
|
9
|
-
from dnt.track import Config, Tracker # noqa: E402
|
|
10
|
-
|
|
11
|
-
video_file = "/mnt/d/videos/sample/traffic.mp4"
|
|
12
|
-
det_file = "/mnt/d/videos/sample/dets/traffic_det.txt"
|
|
13
|
-
track_file = "/mnt/d/videos/sample/tracks/traffic_track.txt"
|
|
14
|
-
label_file = "/mnt/d/videos/sample/labels/traffic.mp4"
|
|
15
|
-
|
|
16
|
-
"""
|
|
17
|
-
video_file = "/mnt/d/videos/samples/traffic_short.mp4"
|
|
18
|
-
mot_file = "/mnt/d/videos/samples/traffic_short_mot.txt"
|
|
19
|
-
iou_file = "/mnt/d/videos/samples/dets/traffic_short_iou.txt"
|
|
20
|
-
iou_file_filtered = "/mnt/d/videos/samples/dets/traffic_short_iou_filtered.txt"
|
|
21
|
-
track_file = "/mnt/d/videos/samples/tracks/traffic_short_track.txt"
|
|
22
|
-
label_file = "/mnt/d/videos/samples/labels/traffic_short_track.mp4"
|
|
23
|
-
label_file_2 = "/mnt/d/videos/samples/labels/traffic_short_det.mp4"
|
|
24
|
-
"""
|
|
25
|
-
detector = Detector()
|
|
26
|
-
ious = detector.detect(video_file, iou_file=det_file, show_filename=True)
|
|
27
|
-
# ious = detector.detect_frames(input_video=video_file, frames=list(range(1, 100)))
|
|
28
|
-
|
|
29
|
-
# tracker = Tracker(cfg=Config.get_cfg_dsort())
|
|
30
|
-
tracker = Tracker(cfg=Config.get_cfg_botsort())
|
|
31
|
-
tracker.track(det_file, track_file, video_file)
|
|
32
|
-
"""
|
|
33
|
-
class_list = [0, 1, 2, 3, 5, 7]
|
|
34
|
-
filter_class_iou(iou_file, iou_file_filtered, class_list)
|
|
35
|
-
|
|
36
|
-
tracker = Tracker(cfg=Config.get_cfg_botsort())
|
|
37
|
-
tracker.track(iou_file_filtered, track_file, video_file, video_index=1, total_videos=1)
|
|
38
|
-
"""
|
|
39
|
-
labeler = Labeler()
|
|
40
|
-
# labeler.draw_dets(input_video=video_file, output_video=label_file, det_file=det_file)
|
|
41
|
-
labeler.draw_tracks(track_file=track_file, input_video=video_file, output_video=label_file, tail=100, class_name=True)
|
|
42
|
-
|
|
43
|
-
print("ok")
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import sys
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
|
|
4
|
-
# add project src/ to import path
|
|
5
|
-
ROOT = Path(__file__).resolve().parents[1]
|
|
6
|
-
sys.path.insert(0, str(ROOT / "src"))
|
|
7
|
-
|
|
8
|
-
from dnt.detect import Detector # noqa: E402
|
|
9
|
-
|
|
10
|
-
video_path = Path("/mnt/d/videos/sample")
|
|
11
|
-
det_path = Path("/mnt/d/videos/samples/dets")
|
|
12
|
-
track_path = Path("/mnt/d/videos/samples/tracks")
|
|
13
|
-
label_path = Path("/mnt/d/videos/samples/labels")
|
|
14
|
-
|
|
15
|
-
# collect mp4s
|
|
16
|
-
input_videos = list(video_path.glob("*.mp4"))
|
|
17
|
-
|
|
18
|
-
# create output folder if it doesn't exist
|
|
19
|
-
det_path.mkdir(parents=True, exist_ok=True)
|
|
20
|
-
|
|
21
|
-
detector = Detector(half=True, weights="n")
|
|
22
|
-
dets = detector.detect_batch(
|
|
23
|
-
[str(p) for p in input_videos],
|
|
24
|
-
output_path=str(det_path),
|
|
25
|
-
is_overwrite=True,
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
'''
|
|
29
|
-
print('Tracking ...')
|
|
30
|
-
cfg = Tracker.export_default_cfg("dsort")
|
|
31
|
-
cfg['max_age'] = 5
|
|
32
|
-
cfg['nn_budget'] = 30
|
|
33
|
-
cfg['nms_max_overlap'] = 1
|
|
34
|
-
|
|
35
|
-
tracker = Tracker(method='dsort', deepsort_cfg=cfg)
|
|
36
|
-
tracks = tracker.track_batch(dets, input_videos, track_path, is_overwrite=True)
|
|
37
|
-
|
|
38
|
-
print('Labeling ...')
|
|
39
|
-
labeler = Labeler()
|
|
40
|
-
labeler.draw_batch(tracks, input_videos, label_path, is_overwrite=True)
|
|
41
|
-
'''
|
|
42
|
-
print("ok")
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
|
|
3
|
-
from dnt.label.labeler import Labeler
|
|
4
|
-
|
|
5
|
-
input_path = "/mnt/d/videos/benesch/24-120161 (Tampa)/Cam 1 (EB view)"
|
|
6
|
-
out_path = "/mnt/d/videos/benesch/24-120161 (Tampa)/frames/eb"
|
|
7
|
-
videos = os.listdir(input_path)
|
|
8
|
-
|
|
9
|
-
labeler = Labeler()
|
|
10
|
-
for video in videos:
|
|
11
|
-
labeler.export_frames(
|
|
12
|
-
input_video=os.path.join(input_path, video), frames=[0], output_path=out_path, prefix=os.path.splitext(video)[0]
|
|
13
|
-
)
|
|
14
|
-
print(os.path.join(input_path, video))
|
|
15
|
-
|
|
16
|
-
print("okay")
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
from dnt.analysis import StopAnalyzer
|
|
2
|
-
from dnt.label import Labeler
|
|
3
|
-
from dnt.detect import Detector
|
|
4
|
-
from dnt.filter import Filter
|
|
5
|
-
import pandas as pd
|
|
6
|
-
from shapely import geometry
|
|
7
|
-
from geopandas import gpd
|
|
8
|
-
import datetime, os, tqdm
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
lines = pd.read_csv("/mnt/d/videos/hfst_nb/frame/before_lines.csv")
|
|
12
|
-
lines_v = lines.loc[lines['h']==0][['x1', 'y1', 'x2', 'y2']].values.tolist()
|
|
13
|
-
lines_h = lines.loc[lines['h']==1][['x1', 'y1', 'x2', 'y2']].values.tolist()
|
|
14
|
-
|
|
15
|
-
v_coords = []
|
|
16
|
-
for line in lines_v:
|
|
17
|
-
v_coords.append([(line[0], line[1]), (line[2], line[3])])
|
|
18
|
-
|
|
19
|
-
h_coords = []
|
|
20
|
-
for line in lines_h:
|
|
21
|
-
h_coords.append([(line[0], line[1]), (line[2], line[3])])
|
|
22
|
-
|
|
23
|
-
event_dict = {
|
|
24
|
-
0: [0], # Stop
|
|
25
|
-
1: [1], # Pass
|
|
26
|
-
2: [2] # Invade
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
rt_zones = [[(116, 209), (175, 204), (188, 332), (113, 340)]]
|
|
30
|
-
|
|
31
|
-
video_file = "/mnt/d/videos/hfst_nb/labels/Standard_SCU7VM_2022-09-13_1600.003_lines.mp4"
|
|
32
|
-
track_file = "/mnt/d/videos/hfst_nb/dets/Standard_SCU7VM_2022-09-13_1600.003_track.txt"
|
|
33
|
-
track_file_filtered = "/mnt/d/videos/hfst_nb/dets/Standard_SCU7VM_2022-09-13_1600.003_track_filtered.txt"
|
|
34
|
-
track_file2 = "/mnt/d/videos/hfst_nb/stops/Standard_SCU7VM_2022-09-13_1600.003_track2.txt"
|
|
35
|
-
result_file = "/mnt/d/videos/hfst_nb/stops/Standard_SCU7VM_2022-09-13_1600.003_result.txt"
|
|
36
|
-
label_file = "/mnt/d/videos/hfst_nb/stops/Standard_SCU7VM_2022-09-13_1600.003_label.txt"
|
|
37
|
-
label_video = "/mnt/d/videos/hfst_nb/stops/Standard_SCU7VM_2022-09-13_1600.003_stop.mp4"
|
|
38
|
-
|
|
39
|
-
init_time_str = "2022-09-13 6:00:01 PM"
|
|
40
|
-
|
|
41
|
-
tracks = pd.read_csv(track_file, header=None)
|
|
42
|
-
|
|
43
|
-
z = []
|
|
44
|
-
for zone in rt_zones:
|
|
45
|
-
z.append(geometry.Polygon(zone))
|
|
46
|
-
geo_zones = geometry.MultiPolygon(z)
|
|
47
|
-
|
|
48
|
-
tracks = Filter.filter_tracks(tracks, exclude_zones=geo_zones)
|
|
49
|
-
tracks.to_csv(track_file_filtered, header=None, index=False)
|
|
50
|
-
|
|
51
|
-
analyzer = StopAnalyzer(h_coords=h_coords, v_coords=v_coords, event_dict=event_dict)
|
|
52
|
-
analyzer.analysis(track_file=track_file_filtered, result_file=result_file, output_file=track_file2)
|
|
53
|
-
results = pd.read_csv(result_file)
|
|
54
|
-
results = results.loc[results['LANE']!=-1]
|
|
55
|
-
results.to_csv(result_file, index=False)
|
|
56
|
-
|
|
57
|
-
if init_time_str:
|
|
58
|
-
init_time=datetime.datetime.strptime(init_time_str, '%Y-%m-%d %I:%M:%S %p')
|
|
59
|
-
fps = Detector.get_fps(video_file)
|
|
60
|
-
StopAnalyzer.add_timestamp(result_file, result_file, init_time, fps)
|
|
61
|
-
|
|
62
|
-
StopAnalyzer.export_label(track_file2, result_file, label_file, label_field=6, event_label=['STOP', 'PASS', 'INVADE'], vid_disp=False)
|
|
63
|
-
|
|
64
|
-
labeler = Labeler(compress_message=False, label_fields=[6], zoom_factor=0.5)
|
|
65
|
-
labeler.draw(label_file, video_file, label_video, video_index=1, video_tot=1)
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"""Example script for labeling video tracks using the Labeler class."""
|
|
2
|
-
|
|
3
|
-
import os
|
|
4
|
-
import pathlib
|
|
5
|
-
import sys
|
|
6
|
-
|
|
7
|
-
root = pathlib.Path(__file__).resolve().parents[1]
|
|
8
|
-
sys.path.insert(0, str(root / "src"))
|
|
9
|
-
|
|
10
|
-
from dnt.label import Encoder, Labeler, LabelMethod, TrackClipMethod
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def main() -> None:
|
|
14
|
-
"""Label video tracks using the Labeler class with FFMPEG method."""
|
|
15
|
-
input_video = "/mnt/d/videos/sample/traffic.mp4"
|
|
16
|
-
det_file = "/mnt/d/videos/sample/dets/traffic_det.txt"
|
|
17
|
-
track_file = "/mnt/d/videos/sample/tracks/traffic_track.txt"
|
|
18
|
-
track_label = "/mnt/d/videos/sample/tracks/traffic_label.txt"
|
|
19
|
-
det_video = "/mnt/d/videos/sample/labels/traffic_det.mp4"
|
|
20
|
-
track_video = "/mnt/d/videos/sample/labels/traffic_track.mp4"
|
|
21
|
-
clip_video = "/mnt/d/videos/sample/traffic_clip.mp4"
|
|
22
|
-
|
|
23
|
-
track_clip_output = "/mnt/d/videos/sample/labels/track_clips"
|
|
24
|
-
os.makedirs(track_clip_output, exist_ok=True)
|
|
25
|
-
|
|
26
|
-
labeler = Labeler(method=LabelMethod.CHROME_SAFE, encoder=Encoder.LIBX265)
|
|
27
|
-
"""
|
|
28
|
-
labeler.draw_tracks(
|
|
29
|
-
input_video=input_video,
|
|
30
|
-
output_video=track_video,
|
|
31
|
-
track_file=track_file,
|
|
32
|
-
label_class_name=True,
|
|
33
|
-
thick=1,
|
|
34
|
-
size=0.8,
|
|
35
|
-
)
|
|
36
|
-
"""
|
|
37
|
-
# labeler.draw_dets(input_video, det_video, det_file=det_file, label_score=True, thick=1, size=0.8)
|
|
38
|
-
shapes = [
|
|
39
|
-
{
|
|
40
|
-
"type": "polygon",
|
|
41
|
-
"geometry": [(200, 200), (400, 200), (400, 400)],
|
|
42
|
-
"fill": True,
|
|
43
|
-
"color": (255, 0, 0),
|
|
44
|
-
"alpha": 0.2,
|
|
45
|
-
"size": 20,
|
|
46
|
-
"thick": 1,
|
|
47
|
-
},
|
|
48
|
-
]
|
|
49
|
-
|
|
50
|
-
labeler.draw_track_clips(
|
|
51
|
-
input_video=input_video,
|
|
52
|
-
output_path=track_clip_output,
|
|
53
|
-
track_file=track_file,
|
|
54
|
-
method=TrackClipMethod.RANDOM,
|
|
55
|
-
random_number=5,
|
|
56
|
-
tail_length=0,
|
|
57
|
-
label_class=True,
|
|
58
|
-
label_prefix=True,
|
|
59
|
-
thick=1,
|
|
60
|
-
size=0.8,
|
|
61
|
-
fill=True,
|
|
62
|
-
alpha=0.2,
|
|
63
|
-
color="random",
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
# labeler.clip_by_time(input_video=input_video, output_video=clip_video, clip_len_sec=5.0, method=LabelMethod.FFMPEG)
|
|
67
|
-
# frames = range(800,1000)
|
|
68
|
-
# labeler.export_frames(input_video, frames, "/mnt/d/videos/ped2stage/frames")
|
|
69
|
-
print("ok")
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if __name__ == "__main__":
|
|
73
|
-
main()
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"""Example script for object tracking using DNT library."""
|
|
2
|
-
|
|
3
|
-
import os
|
|
4
|
-
import sys
|
|
5
|
-
from pathlib import Path
|
|
6
|
-
|
|
7
|
-
# Allow running this script directly from the repository root.
|
|
8
|
-
ROOT = Path(__file__).resolve().parents[1]
|
|
9
|
-
SRC = ROOT / "src"
|
|
10
|
-
if str(SRC) not in sys.path:
|
|
11
|
-
sys.path.insert(0, str(SRC))
|
|
12
|
-
|
|
13
|
-
from dnt.detect import Detector, DetectorModel
|
|
14
|
-
from dnt.label import Labeler, LabelMethod
|
|
15
|
-
from dnt.label.labeler import Labeler, LabelMethod
|
|
16
|
-
from dnt.track import BOTSORTConfig, ReIDWeights, Tracker, interpolate_tracks_rts, link_tracklets
|
|
17
|
-
|
|
18
|
-
base_dir = "/mnt/e/videos/tmc/before/009/View_South/videos/4-19-23"
|
|
19
|
-
input_video = f"{base_dir}/4-19-23-hiv00307.mp4"
|
|
20
|
-
det_file = f"{base_dir}/dets/4-19-23-hiv00307_iou.txt"
|
|
21
|
-
track_file = f"{base_dir}/tracks/4-19-23-hiv00307_ped_track_bot.txt"
|
|
22
|
-
track_interp_file = f"{base_dir}/tracks/4-19-23-hiv00307_ped_track_bot_interp.txt"
|
|
23
|
-
tracks_linked_file = f"{base_dir}/tracks/4-19-23-hiv00307_ped_track_bot_linked.txt"
|
|
24
|
-
label_dir = f"{base_dir}/labels/track_clips"
|
|
25
|
-
os.makedirs(label_dir, exist_ok=True)
|
|
26
|
-
|
|
27
|
-
detector = Detector(model=DetectorModel.RTDETRx, device="auto")
|
|
28
|
-
# detector.detect(input_video, det_file)
|
|
29
|
-
|
|
30
|
-
cfg = BOTSORTConfig(ReIDWeights.CLIP_VEHICLEID)
|
|
31
|
-
tracker = Tracker(cfg, device="auto")
|
|
32
|
-
# tracks = tracker.track(det_file, track_file, input_video)
|
|
33
|
-
|
|
34
|
-
labeler = Labeler(LabelMethod.CHROME_SAFE)
|
|
35
|
-
|
|
36
|
-
labeler.draw_track_clips(
|
|
37
|
-
track_file=track_file, input_video=input_video, output_path=label_dir, label_prefix=False, fill=True, alpha=0.2
|
|
38
|
-
)
|
|
39
|
-
tracks_linked = link_tracklets(track_file=track_file, output_file=tracks_linked_file, max_gap=30)
|
|
40
|
-
tracks_interp = interpolate_tracks_rts(track_file=track_file, output_file=track_interp_file, verbose=True)
|
|
41
|
-
|
|
42
|
-
labeler.draw_track_clips(
|
|
43
|
-
track_file=tracks_linked_file,
|
|
44
|
-
input_video=input_video,
|
|
45
|
-
output_path=label_dir,
|
|
46
|
-
label_prefix=True,
|
|
47
|
-
fill=True,
|
|
48
|
-
alpha=0.2,
|
|
49
|
-
)
|
|
50
|
-
|
|
51
|
-
print("ok")
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"""Example script for object tracking using DNT library."""
|
|
2
|
-
|
|
3
|
-
import sys
|
|
4
|
-
from pathlib import Path
|
|
5
|
-
|
|
6
|
-
# Allow running this script directly from the repository root.
|
|
7
|
-
ROOT = Path(__file__).resolve().parents[1]
|
|
8
|
-
SRC = ROOT / "src"
|
|
9
|
-
if str(SRC) not in sys.path:
|
|
10
|
-
sys.path.insert(0, str(SRC))
|
|
11
|
-
|
|
12
|
-
from dnt.detect import Detector, DetectorModel
|
|
13
|
-
from dnt.label import Labeler, LabelMethod
|
|
14
|
-
from dnt.label.labeler import Labeler, LabelMethod
|
|
15
|
-
from dnt.track import BOTSORTConfig, ReIDWeights, Tracker, interpolate_tracks_rts
|
|
16
|
-
|
|
17
|
-
input_video = "/mnt/d/videos/sample/short-off-ramp.mp4"
|
|
18
|
-
det_file = "/mnt/d/videos/sample/dets/short-off-ramp_det.txt"
|
|
19
|
-
track_file = "/mnt/d/videos/sample/tracks/short-off-ramp_track.txt"
|
|
20
|
-
track_interp_file = "/mnt/d/videos/sample/tracks/short-off-ramp_track_interp.txt"
|
|
21
|
-
label_file = "/mnt/d/videos/sample/labels/short-off-ramp_track.mp4"
|
|
22
|
-
label_interp_file = "/mnt/d/videos/sample/labels/short-off-ramp_track_interp.mp4"
|
|
23
|
-
label_dir = "/mnt/d/videos/sample/labels/track_clips"
|
|
24
|
-
|
|
25
|
-
detector = Detector(model=DetectorModel.RTDETRx, device="auto")
|
|
26
|
-
# detector.detect(input_video, det_file)
|
|
27
|
-
|
|
28
|
-
cfg = BOTSORTConfig(ReIDWeights.CLIP_VEHICLEID)
|
|
29
|
-
tracker = Tracker(cfg, device="auto")
|
|
30
|
-
tracks = tracker.track(det_file, track_file, input_video)
|
|
31
|
-
|
|
32
|
-
labeler = Labeler(LabelMethod.CHROME_SAFE)
|
|
33
|
-
labeler.draw_tracks(track_file=track_file, input_video=input_video, output_video=label_file, fill=True, alpha=0.2)
|
|
34
|
-
|
|
35
|
-
tracks_interp = interpolate_tracks_rts(track_file=track_file, output_file=track_interp_file, verbose=True)
|
|
36
|
-
labeler.draw_tracks(
|
|
37
|
-
track_file=track_interp_file,
|
|
38
|
-
input_video=input_video,
|
|
39
|
-
output_video=label_interp_file,
|
|
40
|
-
fill=True,
|
|
41
|
-
alpha=0.2,
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
print("ok")
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
from dnt.label import Labeler
|
|
2
|
-
|
|
3
|
-
video_file = "/mnt/d/videos/hfst/Standard_SCU7WH_2022-09-13_1600.004.mp4"
|
|
4
|
-
ouput_file = "/mnt/d/videos/hfst/labels/shapes.mp4"
|
|
5
|
-
|
|
6
|
-
points = [[256, 228],[408, 337],
|
|
7
|
-
[334, 212],[515, 297],
|
|
8
|
-
[403, 197],[596, 268],
|
|
9
|
-
[455, 187],[651, 247],
|
|
10
|
-
[507, 174],[693, 231]]
|
|
11
|
-
|
|
12
|
-
lines = [[256, 228, 408, 337],
|
|
13
|
-
[334, 212, 515, 297],
|
|
14
|
-
[403, 197, 596, 268],
|
|
15
|
-
[455, 187, 651, 247],
|
|
16
|
-
[507, 174, 693, 231]]
|
|
17
|
-
|
|
18
|
-
polygons = [[[256, 228], [408, 337], [515, 297], [334, 212]],
|
|
19
|
-
[[334, 212], [515, 297], [596, 268], [403, 197]],
|
|
20
|
-
[[403, 197], [596, 268], [651, 247], [455, 187]],
|
|
21
|
-
[[455, 187], [651, 247], [693, 231], [507, 174]]]
|
|
22
|
-
|
|
23
|
-
labeler = Labeler()
|
|
24
|
-
labeler.draw_shapes(input_video=video_file, output_video=ouput_file, points = points, polygons=polygons,
|
|
25
|
-
point_color=(0,0,255), polygon_color=(0, 255, 0))
|
|
26
|
-
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import pandas as pd
|
|
2
|
-
|
|
3
|
-
from dnt.label.labeler import Labeler
|
|
4
|
-
|
|
5
|
-
video_file = "/mnt/d/videos/hfst/Standard_SCU7WH_2022-09-13_1600.004.mp4"
|
|
6
|
-
ouput_file = "/mnt/d/videos/hfst/labels/shapes_v2.mp4"
|
|
7
|
-
|
|
8
|
-
points = [
|
|
9
|
-
[256, 228],
|
|
10
|
-
[408, 337],
|
|
11
|
-
[334, 212],
|
|
12
|
-
[515, 297],
|
|
13
|
-
[403, 197],
|
|
14
|
-
[596, 268],
|
|
15
|
-
[455, 187],
|
|
16
|
-
[651, 247],
|
|
17
|
-
[507, 174],
|
|
18
|
-
[693, 231],
|
|
19
|
-
]
|
|
20
|
-
|
|
21
|
-
lines = [[256, 228, 408, 337], [334, 212, 515, 297], [403, 197, 596, 268], [455, 187, 651, 247], [507, 174, 693, 231]]
|
|
22
|
-
|
|
23
|
-
polygons = [[25, 70], [25, 160], [110, 200], [200, 160], [200, 70], [110, 20]]
|
|
24
|
-
|
|
25
|
-
polygons2 = [(25, 70), (25, 160), (110, 200), (200, 160), (200, 70), (110, 20)]
|
|
26
|
-
|
|
27
|
-
results = []
|
|
28
|
-
for i in range(1000):
|
|
29
|
-
results.append([i, "polylines", polygons2, (0, 255, 0), 1, 2, ""])
|
|
30
|
-
|
|
31
|
-
df = pd.DataFrame(results, columns=["frame", "type", "coords", "color", "size", "thick", "desc"])
|
|
32
|
-
|
|
33
|
-
labeler = Labeler()
|
|
34
|
-
labeler.draw(video_file, output_video=ouput_file, draws=df)
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
from dnt.analysis.stop import StopAnalyzer
|
|
2
|
-
from dnt.label import Labeler
|
|
3
|
-
from dnt.detect import Detector
|
|
4
|
-
import pandas as pd
|
|
5
|
-
import datetime
|
|
6
|
-
|
|
7
|
-
v_coords = [[(256, 228),(408, 337)],
|
|
8
|
-
[(334, 212),(515, 297)],
|
|
9
|
-
[(403, 197),(596, 268)],
|
|
10
|
-
[(455, 187),(651, 247)],
|
|
11
|
-
[(507, 174),(693, 231)]]
|
|
12
|
-
|
|
13
|
-
h_coords = [[(256, 228),(506, 175)],
|
|
14
|
-
[(290, 256),(557, 188)],
|
|
15
|
-
[(345, 291),(635, 211)],
|
|
16
|
-
[(380, 313),(672, 225)],
|
|
17
|
-
[(408, 337),(691, 232)]]
|
|
18
|
-
|
|
19
|
-
event_dict = {
|
|
20
|
-
0: [0, 1, 2], # Stop
|
|
21
|
-
1: [3] # Pass
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
track_file = "/mnt/d/videos/hfst/tracks/Standard_SCU7WH_2022-09-16_0630.02.001_track.txt"
|
|
25
|
-
label_file = "/mnt/d/videos/hfst/tracks/Standard_SCU7WH_2022-09-16_0630.02.001_label.txt"
|
|
26
|
-
result_file = "/mnt/d/videos/hfst/tracks/Standard_SCU7WH_2022-09-16_0630.02.001_result.txt"
|
|
27
|
-
result_file2 = "/mnt/d/videos/hfst/tracks/Standard_SCU7WH_2022-09-16_0630.02.001_result2.txt"
|
|
28
|
-
label_video = "/mnt/d/videos/hfst/labels/Standard_SCU7WH_2022-09-16_0630.02.001_label.mp4"
|
|
29
|
-
video_file = "/mnt/d/videos/hfst/labels/Standard_SCU7WH_2022-09-16_0630.02.001_lines_3.mp4"
|
|
30
|
-
|
|
31
|
-
analyzer = StopAnalyzer(h_coords=h_coords, v_coords=v_coords, event_dict=event_dict)
|
|
32
|
-
analyzer.analysis(track_file=track_file, result_file=result_file, video_index=1, video_tot=1)
|
|
33
|
-
|
|
34
|
-
results = pd.read_csv(result_file)
|
|
35
|
-
results = results.loc[results['LANE']!=-1]
|
|
36
|
-
results.to_csv(result_file, index=False)
|
|
37
|
-
|
|
38
|
-
fps = Detector.get_fps(video_file)
|
|
39
|
-
init_time = datetime.datetime.strptime('2022-09-16 10:47:08 AM', '%Y-%m-%d %I:%M:%S %p')
|
|
40
|
-
StopAnalyzer.add_timestamp(result_file, result_file2, init_time=init_time, fps=fps)
|
|
41
|
-
|
|
42
|
-
results = pd.read_csv(result_file2)
|
|
43
|
-
results = results.loc[results['DURATION']>=1]
|
|
44
|
-
results.to_csv(result_file2, index=False)
|
|
45
|
-
|
|
46
|
-
StopAnalyzer.export_label(track_file, result_file2, label_file, label_field=6, event_label=['STOP', 'PASS'], vid_disp=False)
|
|
47
|
-
|
|
48
|
-
labeler = Labeler(compress_message=False, label_fields=[6], nodraw_empty=True, zoom_factor=0.5)
|
|
49
|
-
labeler.draw(label_file, video_file, label_video)
|
|
50
|
-
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"""Example script for object tracking using DNT library."""
|
|
2
|
-
|
|
3
|
-
import sys
|
|
4
|
-
import time
|
|
5
|
-
from pathlib import Path
|
|
6
|
-
|
|
7
|
-
# Allow running this script directly from the repository root.
|
|
8
|
-
ROOT = Path(__file__).resolve().parents[1]
|
|
9
|
-
SRC = ROOT / "src"
|
|
10
|
-
if str(SRC) not in sys.path:
|
|
11
|
-
sys.path.insert(0, str(SRC))
|
|
12
|
-
|
|
13
|
-
from dnt.label.labeler import Labeler
|
|
14
|
-
from dnt.track import BOTSORTConfig, Tracker
|
|
15
|
-
|
|
16
|
-
"""
|
|
17
|
-
input_video = "/mnt/d/videos/samples/ped_veh.mp4"
|
|
18
|
-
det_file = "/mnt/d/videos/samples/dets/ped_veh_iou.txt"
|
|
19
|
-
track_file = "/mnt/d/videos/samples/tracks/ped_veh_track.txt"
|
|
20
|
-
label_video = "/mnt/d/videos/samples/labels/ped_veh_track.mp4"
|
|
21
|
-
|
|
22
|
-
input_video = "/mnt/d/videos/samples/traffic.mp4"
|
|
23
|
-
det_file = "/mnt/d/videos/samples/dets/traffic_iou.txt"
|
|
24
|
-
track_file = "/mnt/d/videos/samples/tracks/traffic_track_dsort.txt"
|
|
25
|
-
label_video = "/mnt/d/videos/samples/labels/traffic_track.mp4"
|
|
26
|
-
"""
|
|
27
|
-
input_video = "/mnt/d/videos/sample/traffic.mp4"
|
|
28
|
-
det_file = "/mnt/d/videos/sample/dets/traffic_det.txt"
|
|
29
|
-
track_file = "/mnt/d/videos/sample/tracks/traffic_track.txt"
|
|
30
|
-
label_file = "/mnt/d/videos/sample/labels/traffic_track.mp4"
|
|
31
|
-
|
|
32
|
-
tic = time.time()
|
|
33
|
-
cfg = BOTSORTConfig()
|
|
34
|
-
|
|
35
|
-
print(cfg)
|
|
36
|
-
tracker = Tracker(cfg, device="auto")
|
|
37
|
-
tracker.track(det_file, track_file, input_video)
|
|
38
|
-
|
|
39
|
-
toc = time.time()
|
|
40
|
-
print("Time:", int(toc - tic))
|
|
41
|
-
|
|
42
|
-
labeler = Labeler()
|
|
43
|
-
# labeler.draw_tracks(track_file=track_file, input_video=input_video, output_video=label_file, tail=100)
|
|
44
|
-
|
|
45
|
-
print("ok")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|