dnt 0.2.4__tar.gz → 0.3.1.3__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.
Potentially problematic release.
This version of dnt might be problematic. Click here for more details.
- dnt-0.3.1.3/MANIFEST.in +6 -0
- {dnt-0.2.4/dnt.egg-info → dnt-0.3.1.3}/PKG-INFO +28 -10
- {dnt-0.2.4 → dnt-0.3.1.3}/README.md +6 -1
- dnt-0.3.1.3/dnt/__init__.py +5 -0
- dnt-0.3.1.3/dnt/analysis/__init__.py +8 -0
- dnt-0.3.1.3/dnt/analysis/interaction.py +503 -0
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt/analysis/speed.py +0 -0
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt/analysis/stop.py +22 -17
- dnt-0.3.1.3/dnt/analysis/stop2.py +289 -0
- dnt-0.3.1.3/dnt/analysis/stop3.py +754 -0
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt/detect/__init__.py +0 -0
- dnt-0.3.1.3/dnt/detect/signal/detector.py +317 -0
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt/detect/yolov8/__init__.py +0 -0
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt/detect/yolov8/detector.py +116 -16
- dnt-0.3.1.3/dnt/engine/__init__.py +8 -0
- dnt-0.3.1.3/dnt/engine/bbox_interp.py +83 -0
- dnt-0.3.1.3/dnt/engine/bbox_iou.py +20 -0
- dnt-0.3.1.3/dnt/engine/cluster.py +31 -0
- dnt-0.3.1.3/dnt/engine/iob.py +66 -0
- dnt-0.3.1.3/dnt/filter/filter.py +455 -0
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt/label/__init__.py +0 -0
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt/label/labeler.py +4 -4
- dnt-0.3.1.3/dnt/label/labeler2.py +502 -0
- {dnt-0.2.4/dnt/analysis → dnt-0.3.1.3/dnt/shared}/__init__.py +1 -3
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt/shared/convert.py +0 -0
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt/shared/data/coco.names +0 -0
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt/shared/data/openimages.names +0 -0
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt/shared/data/voc.names +0 -0
- dnt-0.3.1.3/dnt/shared/download.py +12 -0
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt/shared/files.py +0 -0
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt/shared/filter.py +0 -0
- dnt-0.3.1.3/dnt/shared/synhcro.py +150 -0
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt/shared/util.py +17 -4
- dnt-0.3.1.3/dnt/third_party/fast-reid/__init__.py +1 -0
- {dnt-0.2.4/dnt/track/dsort/deep_sort/deep → dnt-0.3.1.3/dnt/third_party/fast-reid/checkpoint}/__init__.py +0 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/Base-AGW.yml +19 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/Base-MGN.yml +12 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/Base-SBS.yml +63 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/Base-bagtricks.yml +76 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/DukeMTMC/AGW_R101-ibn.yml +12 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/DukeMTMC/AGW_R50-ibn.yml +11 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/DukeMTMC/AGW_R50.yml +7 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/DukeMTMC/AGW_S50.yml +11 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_R101-ibn.yml +12 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_R50-ibn.yml +11 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_R50.yml +7 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_S50.yml +11 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/DukeMTMC/mgn_R50-ibn.yml +11 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/DukeMTMC/sbs_R101-ibn.yml +12 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/DukeMTMC/sbs_R50-ibn.yml +11 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/DukeMTMC/sbs_R50.yml +7 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/DukeMTMC/sbs_S50.yml +11 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MOT17/AGW_R101-ibn.yml +12 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MOT17/AGW_R50-ibn.yml +11 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MOT17/AGW_R50.yml +7 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MOT17/AGW_S50.yml +11 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MOT17/bagtricks_R101-ibn.yml +12 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MOT17/bagtricks_R50-ibn.yml +11 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MOT17/bagtricks_R50.yml +7 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MOT17/bagtricks_S50.yml +11 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MOT17/mgn_R50-ibn.yml +11 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MOT17/sbs_R101-ibn.yml +12 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MOT17/sbs_R50-ibn.yml +11 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MOT17/sbs_R50.yml +7 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MOT17/sbs_S50.yml +11 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MOT20/AGW_R101-ibn.yml +12 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MOT20/AGW_R50-ibn.yml +11 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MOT20/AGW_R50.yml +7 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MOT20/AGW_S50.yml +11 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MOT20/bagtricks_R101-ibn.yml +12 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MOT20/bagtricks_R50-ibn.yml +11 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MOT20/bagtricks_R50.yml +7 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MOT20/bagtricks_S50.yml +11 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MOT20/mgn_R50-ibn.yml +11 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MOT20/sbs_R101-ibn.yml +12 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MOT20/sbs_R50-ibn.yml +11 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MOT20/sbs_R50.yml +7 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MOT20/sbs_S50.yml +11 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MSMT17/AGW_R101-ibn.yml +12 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MSMT17/AGW_R50-ibn.yml +11 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MSMT17/AGW_R50.yml +7 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MSMT17/AGW_S50.yml +11 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MSMT17/bagtricks_R101-ibn.yml +13 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MSMT17/bagtricks_R50-ibn.yml +12 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MSMT17/bagtricks_R50.yml +7 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MSMT17/bagtricks_S50.yml +12 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MSMT17/mgn_R50-ibn.yml +11 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MSMT17/sbs_R101-ibn.yml +12 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MSMT17/sbs_R50-ibn.yml +11 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MSMT17/sbs_R50.yml +7 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/MSMT17/sbs_S50.yml +11 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/Market1501/AGW_R101-ibn.yml +12 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/Market1501/AGW_R50-ibn.yml +11 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/Market1501/AGW_R50.yml +7 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/Market1501/AGW_S50.yml +11 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/Market1501/bagtricks_R101-ibn.yml +12 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/Market1501/bagtricks_R50-ibn.yml +11 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/Market1501/bagtricks_R50.yml +7 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/Market1501/bagtricks_S50.yml +11 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/Market1501/bagtricks_vit.yml +88 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/Market1501/mgn_R50-ibn.yml +11 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/Market1501/sbs_R101-ibn.yml +12 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/Market1501/sbs_R50-ibn.yml +11 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/Market1501/sbs_R50.yml +7 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/Market1501/sbs_S50.yml +11 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/VERIWild/bagtricks_R50-ibn.yml +35 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/VeRi/sbs_R50-ibn.yml +35 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/configs/VehicleID/bagtricks_R50-ibn.yml +36 -0
- {dnt-0.2.4/dnt/track/dsort/deep_sort/sort → dnt-0.3.1.3/dnt/third_party/fast-reid/configs}/__init__.py +0 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fast_reid_interfece.py +175 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/__init__.py +6 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/config/__init__.py +15 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/config/config.py +319 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/config/defaults.py +329 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/__init__.py +17 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/build.py +194 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/common.py +58 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/data_utils.py +202 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/datasets/AirportALERT.py +50 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/datasets/__init__.py +43 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/datasets/bases.py +183 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/datasets/caviara.py +44 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/datasets/cuhk03.py +274 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/datasets/cuhk_sysu.py +58 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/datasets/dukemtmcreid.py +70 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/datasets/grid.py +44 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/datasets/iLIDS.py +45 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/datasets/lpw.py +49 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/datasets/market1501.py +89 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/datasets/msmt17.py +114 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/datasets/pes3d.py +44 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/datasets/pku.py +44 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/datasets/prai.py +43 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/datasets/prid.py +41 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/datasets/saivt.py +47 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/datasets/sensereid.py +47 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/datasets/shinpuhkan.py +48 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/datasets/sysu_mm.py +47 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/datasets/thermalworld.py +43 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/datasets/vehicleid.py +126 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/datasets/veri.py +69 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/datasets/veriwild.py +140 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/datasets/viper.py +45 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/datasets/wildtracker.py +59 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/samplers/__init__.py +18 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/samplers/data_sampler.py +85 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/samplers/imbalance_sampler.py +67 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/samplers/triplet_sampler.py +260 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/transforms/__init__.py +11 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/transforms/autoaugment.py +806 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/transforms/build.py +100 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/transforms/functional.py +180 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/data/transforms/transforms.py +161 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/engine/__init__.py +15 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/engine/defaults.py +490 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/engine/hooks.py +534 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/engine/launch.py +103 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/engine/train_loop.py +357 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/evaluation/__init__.py +6 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/evaluation/clas_evaluator.py +81 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/evaluation/evaluator.py +176 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/evaluation/query_expansion.py +46 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/evaluation/rank.py +200 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/evaluation/rank_cylib/__init__.py +20 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/evaluation/rank_cylib/setup.py +32 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/evaluation/rank_cylib/test_cython.py +106 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/evaluation/reid_evaluation.py +143 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/evaluation/rerank.py +73 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/evaluation/roc.py +90 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/evaluation/testing.py +88 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/layers/__init__.py +19 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/layers/activation.py +59 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/layers/any_softmax.py +80 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/layers/batch_norm.py +205 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/layers/context_block.py +113 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/layers/drop.py +161 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/layers/frn.py +199 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/layers/gather_layer.py +30 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/layers/helpers.py +31 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/layers/non_local.py +54 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/layers/pooling.py +124 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/layers/se_layer.py +25 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/layers/splat.py +109 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/layers/weight_init.py +122 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/__init__.py +23 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/__init__.py +18 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/build.py +27 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/mobilenet.py +195 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/mobilenetv3.py +283 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/osnet.py +525 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/__init__.py +4 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/config.py +396 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B0_dds_8gpu.yaml +27 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B1_dds_8gpu.yaml +27 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B2_dds_8gpu.yaml +27 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B3_dds_8gpu.yaml +27 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B4_dds_8gpu.yaml +27 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B5_dds_8gpu.yaml +27 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet.py +281 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnet.py +596 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-1.6GF_dds_8gpu.yaml +26 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-12GF_dds_8gpu.yaml +26 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-16GF_dds_8gpu.yaml +26 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-200MF_dds_8gpu.yaml +26 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-3.2GF_dds_8gpu.yaml +26 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-32GF_dds_8gpu.yaml +26 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-4.0GF_dds_8gpu.yaml +26 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-400MF_dds_8gpu.yaml +26 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-6.4GF_dds_8gpu.yaml +26 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-600MF_dds_8gpu.yaml +26 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-8.0GF_dds_8gpu.yaml +26 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-800MF_dds_8gpu.yaml +26 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-1.6GF_dds_8gpu.yaml +27 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-12GF_dds_8gpu.yaml +27 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-16GF_dds_8gpu.yaml +27 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-200MF_dds_8gpu.yaml +26 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-3.2GF_dds_8gpu.yaml +27 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-32GF_dds_8gpu.yaml +27 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-4.0GF_dds_8gpu.yaml +27 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-400MF_dds_8gpu.yaml +27 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-6.4GF_dds_8gpu.yaml +27 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-600MF_dds_8gpu.yaml +27 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-8.0GF_dds_8gpu.yaml +27 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-800MF_dds_8gpu.yaml +27 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/repvgg.py +309 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/resnest.py +365 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/resnet.py +364 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/resnext.py +335 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/shufflenet.py +203 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/backbones/vision_transformer.py +399 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/heads/__init__.py +11 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/heads/build.py +25 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/heads/clas_head.py +36 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/heads/embedding_head.py +151 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/losses/__init__.py +12 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/losses/circle_loss.py +71 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/losses/cross_entroy_loss.py +54 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/losses/focal_loss.py +92 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/losses/triplet_loss.py +113 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/losses/utils.py +48 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/meta_arch/__init__.py +14 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/meta_arch/baseline.py +188 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/meta_arch/build.py +26 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/meta_arch/distiller.py +140 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/meta_arch/mgn.py +394 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/modeling/meta_arch/moco.py +126 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/solver/__init__.py +8 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/solver/build.py +348 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/solver/lr_scheduler.py +66 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/solver/optim/__init__.py +10 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/solver/optim/lamb.py +123 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/solver/optim/radam.py +149 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/solver/optim/swa.py +246 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/utils/__init__.py +6 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/utils/checkpoint.py +503 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/utils/collect_env.py +158 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/utils/comm.py +255 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/utils/compute_dist.py +200 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/utils/env.py +119 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/utils/events.py +461 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/utils/faiss_utils.py +127 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/utils/file_io.py +520 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/utils/history_buffer.py +71 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/utils/logger.py +211 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/utils/params.py +103 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/utils/precision_bn.py +94 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/utils/registry.py +66 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/utils/summary.py +120 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/utils/timer.py +68 -0
- dnt-0.3.1.3/dnt/third_party/fast-reid/fastreid/utils/visualizer.py +278 -0
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt/track/__init__.py +2 -0
- {dnt-0.2.4/dnt → dnt-0.3.1.3/dnt/track/botsort}/__init__.py +1 -1
- dnt-0.3.1.3/dnt/track/botsort/bot_tracker/__init__.py +3 -0
- dnt-0.3.1.3/dnt/track/botsort/bot_tracker/basetrack.py +60 -0
- dnt-0.3.1.3/dnt/track/botsort/bot_tracker/bot_sort.py +473 -0
- dnt-0.3.1.3/dnt/track/botsort/bot_tracker/gmc.py +316 -0
- dnt-0.3.1.3/dnt/track/botsort/bot_tracker/kalman_filter.py +269 -0
- dnt-0.3.1.3/dnt/track/botsort/bot_tracker/matching.py +194 -0
- dnt-0.3.1.3/dnt/track/botsort/bot_tracker/mc_bot_sort.py +505 -0
- {dnt-0.2.4/dnt/track/dsort/utils → dnt-0.3.1.3/dnt/track/botsort/bot_tracker/tracking_utils}/evaluation.py +14 -4
- {dnt-0.2.4/dnt/track/dsort/utils → dnt-0.3.1.3/dnt/track/botsort/bot_tracker/tracking_utils}/io.py +19 -36
- dnt-0.3.1.3/dnt/track/botsort/bot_tracker/tracking_utils/timer.py +37 -0
- dnt-0.3.1.3/dnt/track/botsort/inference.py +96 -0
- dnt-0.3.1.3/dnt/track/config.py +120 -0
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt/track/dsort/__init__.py +0 -0
- dnt-0.3.1.3/dnt/track/dsort/configs/bagtricks_R50.yml +7 -0
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt/track/dsort/configs/deep_sort.yaml +0 -0
- dnt-0.3.1.3/dnt/track/dsort/configs/fastreid.yaml +3 -0
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt/track/dsort/deep_sort/__init__.py +0 -0
- {dnt-0.2.4/dnt/track/dsort/utils → dnt-0.3.1.3/dnt/track/dsort/deep_sort/deep}/__init__.py +0 -0
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt/track/dsort/deep_sort/deep/checkpoint/ckpt.t7 +0 -0
- dnt-0.3.1.3/dnt/track/dsort/deep_sort/deep/feature_extractor.py +134 -0
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt/track/dsort/deep_sort/deep/model.py +0 -0
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt/track/dsort/deep_sort/deep_sort.py +28 -18
- dnt-0.3.1.3/dnt/track/dsort/deep_sort/sort/__init__.py +0 -0
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt/track/dsort/deep_sort/sort/detection.py +0 -0
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt/track/dsort/deep_sort/sort/iou_matching.py +0 -2
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt/track/dsort/deep_sort/sort/kalman_filter.py +0 -0
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt/track/dsort/deep_sort/sort/linear_assignment.py +0 -3
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt/track/dsort/deep_sort/sort/nn_matching.py +5 -5
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt/track/dsort/deep_sort/sort/preprocessing.py +1 -2
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt/track/dsort/deep_sort/sort/track.py +0 -0
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt/track/dsort/deep_sort/sort/tracker.py +0 -0
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt/track/dsort/dsort.py +21 -28
- dnt-0.3.1.3/dnt/track/re_class.py +94 -0
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt/track/sort/__init__.py +0 -0
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt/track/sort/sort.py +5 -1
- dnt-0.3.1.3/dnt/track/tracker.py +257 -0
- {dnt-0.2.4 → dnt-0.3.1.3/dnt.egg-info}/PKG-INFO +28 -10
- dnt-0.3.1.3/dnt.egg-info/SOURCES.txt +318 -0
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt.egg-info/requires.txt +27 -9
- {dnt-0.2.4 → dnt-0.3.1.3}/setup.py +29 -11
- dnt-0.2.4/MANIFEST.in +0 -4
- dnt-0.2.4/dnt/analysis/yield.py +0 -9
- dnt-0.2.4/dnt/filter/filter.py +0 -135
- dnt-0.2.4/dnt/shared/__init__.py +0 -4
- dnt-0.2.4/dnt/track/dsort/configs/fastreid.yaml +0 -3
- dnt-0.2.4/dnt/track/dsort/deep_sort/deep/evaluate.py +0 -15
- dnt-0.2.4/dnt/track/dsort/deep_sort/deep/feature_extractor.py +0 -55
- dnt-0.2.4/dnt/track/dsort/deep_sort/deep/original_model.py +0 -106
- dnt-0.2.4/dnt/track/dsort/deep_sort/deep/test.py +0 -77
- dnt-0.2.4/dnt/track/dsort/deep_sort/deep/train.py +0 -189
- dnt-0.2.4/dnt/track/dsort/utils/asserts.py +0 -13
- dnt-0.2.4/dnt/track/dsort/utils/draw.py +0 -36
- dnt-0.2.4/dnt/track/dsort/utils/json_logger.py +0 -383
- dnt-0.2.4/dnt/track/dsort/utils/log.py +0 -17
- dnt-0.2.4/dnt/track/dsort/utils/parser.py +0 -35
- dnt-0.2.4/dnt/track/dsort/utils/tools.py +0 -39
- dnt-0.2.4/dnt/track/tracker.py +0 -80
- dnt-0.2.4/dnt.egg-info/SOURCES.txt +0 -68
- {dnt-0.2.4 → dnt-0.3.1.3}/LICENSE +0 -0
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt/analysis/count.py +0 -0
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt/analysis/position.py +0 -0
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt/detect/yolov8/segmentor.py +0 -0
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt/filter/__init__.py +0 -0
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt.egg-info/dependency_links.txt +0 -0
- {dnt-0.2.4 → dnt-0.3.1.3}/dnt.egg-info/top_level.txt +0 -0
- {dnt-0.2.4 → dnt-0.3.1.3}/setup.cfg +0 -0
dnt-0.3.1.3/MANIFEST.in
ADDED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: dnt
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.1.3
|
|
4
4
|
Summary: A Python tool for video-based traffic analytiscs
|
|
5
5
|
Home-page: https://its.cutr.usf.edu/dnt/
|
|
6
6
|
Author: Zhenyu Wang
|
|
@@ -13,24 +13,42 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
13
13
|
Classifier: Programming Language :: Python :: 3
|
|
14
14
|
Requires-Python: >=3.9
|
|
15
15
|
License-File: LICENSE
|
|
16
|
-
Requires-Dist: numpy
|
|
17
|
-
Requires-Dist: pandas
|
|
18
|
-
Requires-Dist: matplotlib
|
|
19
16
|
Requires-Dist: torch
|
|
20
17
|
Requires-Dist: torchvision
|
|
21
18
|
Requires-Dist: torchaudio
|
|
22
|
-
Requires-Dist: ultralytics
|
|
19
|
+
Requires-Dist: ultralytics>=8.2
|
|
20
|
+
Requires-Dist: cython
|
|
21
|
+
Requires-Dist: cython_bbox
|
|
23
22
|
Requires-Dist: easydict
|
|
23
|
+
Requires-Dist: faiss-cpu
|
|
24
|
+
Requires-Dist: faiss-gpu
|
|
24
25
|
Requires-Dist: filterpy
|
|
26
|
+
Requires-Dist: gdown
|
|
27
|
+
Requires-Dist: geopandas
|
|
28
|
+
Requires-Dist: h5py
|
|
29
|
+
Requires-Dist: lap
|
|
30
|
+
Requires-Dist: loguru
|
|
25
31
|
Requires-Dist: matplotlib
|
|
32
|
+
Requires-Dist: motmetrics
|
|
33
|
+
Requires-Dist: ninja
|
|
34
|
+
Requires-Dist: numpy
|
|
26
35
|
Requires-Dist: numpy_indexed
|
|
27
|
-
Requires-Dist: opencv-python
|
|
28
36
|
Requires-Dist: opencv-contrib-python
|
|
37
|
+
Requires-Dist: opencv-python
|
|
29
38
|
Requires-Dist: pandas
|
|
30
|
-
Requires-Dist:
|
|
31
|
-
Requires-Dist:
|
|
32
|
-
Requires-Dist:
|
|
33
|
-
Requires-Dist:
|
|
39
|
+
Requires-Dist: Pillow
|
|
40
|
+
Requires-Dist: prettytable
|
|
41
|
+
Requires-Dist: pycocotools
|
|
42
|
+
Requires-Dist: pyyaml
|
|
34
43
|
Requires-Dist: scikit-image
|
|
44
|
+
Requires-Dist: scikit-learn
|
|
45
|
+
Requires-Dist: scipy
|
|
46
|
+
Requires-Dist: shapely
|
|
47
|
+
Requires-Dist: sympy
|
|
48
|
+
Requires-Dist: tabulate
|
|
49
|
+
Requires-Dist: tensorboard
|
|
50
|
+
Requires-Dist: termcolor
|
|
51
|
+
Requires-Dist: thop
|
|
35
52
|
Requires-Dist: tqdm
|
|
36
53
|
Requires-Dist: vidgear
|
|
54
|
+
Requires-Dist: yacs
|
|
@@ -15,8 +15,13 @@ This tool can generate vehicel trajectories using real-time object detection and
|
|
|
15
15
|
* Libarary: pytorch (>=1.12 with cuda), pandas, tqdm, numpy, scipy, matplotlib, ultralytics
|
|
16
16
|
|
|
17
17
|
### Installing
|
|
18
|
-
|
|
19
18
|
```
|
|
19
|
+
Setup enviroment:
|
|
20
|
+
|
|
21
|
+
python3.x -m venv dnt (you may replace dnt with you specified name; python version >3.9)
|
|
22
|
+
sudo apt-get install python3.x-dev
|
|
23
|
+
pip install python-dev-tools
|
|
24
|
+
|
|
20
25
|
pip install torch==1.12.0+cu116 torchvision==0.13.0+cu116 torchaudio==0.12.0 --extra-index-url https://download.pytorch.org/whl/cu116
|
|
21
26
|
pip install dnt
|
|
22
27
|
```
|
|
@@ -0,0 +1,503 @@
|
|
|
1
|
+
from shapely.geometry import Point, Polygon, LineString, box
|
|
2
|
+
from shapely import intersection, distance, intersects
|
|
3
|
+
from shapelysmooth import taubin_smooth, chaikin_smooth, catmull_rom_smooth
|
|
4
|
+
import geopandas as gpd, pandas as pd
|
|
5
|
+
from tqdm import tqdm
|
|
6
|
+
import numpy as np
|
|
7
|
+
from matplotlib import pyplot as plt
|
|
8
|
+
from dnt.label.labeler2 import Labeler
|
|
9
|
+
import os
|
|
10
|
+
from ..track import Tracker
|
|
11
|
+
|
|
12
|
+
class YieldAnalyzer:
|
|
13
|
+
def __init__(self, waiting_dist_p:int=600, waiting_dist_y:int=300,
|
|
14
|
+
leading_p:bool=False, leading_axis_p:str='y',
|
|
15
|
+
leading_y:bool=True, leading_axis_y:str='x',
|
|
16
|
+
yield_gap:int=10, fps:int=30, ref_point='bc',
|
|
17
|
+
ref_offset:tuple=(0,0), filter_buffer:int=0,
|
|
18
|
+
p_zone:Polygon=None, y_zone:Polygon=None) -> None:
|
|
19
|
+
'''
|
|
20
|
+
Parameters:
|
|
21
|
+
threshold: the hyperparameter to determine if a yield event (frame difference <=yield_gap*fps), default is 3 seconds
|
|
22
|
+
fps: frames per sencond, default is 30
|
|
23
|
+
ref_point: the reference point for lane recognition
|
|
24
|
+
br (buttom-right, default), bl (bottom-left), bc (bottom-center)
|
|
25
|
+
tl (top-left), tr (top-right), tc (top-center)
|
|
26
|
+
cc (center-center), cl (center-left), cr (center-right)
|
|
27
|
+
ref_offset: the offset (x, y) for reference point, default is (0, 0)
|
|
28
|
+
filter_buffer: the buffer between two track frames, default is 0 means tracks will be paired only if two tracks are overlapped in time
|
|
29
|
+
'''
|
|
30
|
+
self.waiting_dist_p = waiting_dist_p
|
|
31
|
+
self.waiting_dist_y = waiting_dist_y
|
|
32
|
+
self.leading_p = leading_p
|
|
33
|
+
self.leading_axis_p = leading_axis_p
|
|
34
|
+
self.leading_y = leading_y
|
|
35
|
+
self.leading_axis_y = leading_axis_y
|
|
36
|
+
self.yield_gap = yield_gap
|
|
37
|
+
self.fps = fps
|
|
38
|
+
self.ref_point = ref_point
|
|
39
|
+
self.ref_offset = ref_offset
|
|
40
|
+
self.filter_buffer = filter_buffer
|
|
41
|
+
self.p_zone = p_zone
|
|
42
|
+
self.y_zone = y_zone
|
|
43
|
+
|
|
44
|
+
def analyze(self, tracks_p:pd.DataFrame, tracks_y:pd.DataFrame, name_p:str='', name_y:str=''):
|
|
45
|
+
'''
|
|
46
|
+
Parameters:
|
|
47
|
+
tracks_p: tracks with priority
|
|
48
|
+
tracks_y: tracks should yield to tracks_p
|
|
49
|
+
'''
|
|
50
|
+
tracks_p = YieldAnalyzer.add_field_names(tracks_p)
|
|
51
|
+
tracks_y = YieldAnalyzer.add_field_names(tracks_y)
|
|
52
|
+
|
|
53
|
+
tracks_p = self.gen_ref(tracks_p, info=name_p)
|
|
54
|
+
tracks_y = self.gen_ref(tracks_y, info=name_y)
|
|
55
|
+
|
|
56
|
+
trajectories_p = self.gen_trajectory(tracks_p, info=name_p)
|
|
57
|
+
trajectories_y = self.gen_trajectory(tracks_y, info=name_y)
|
|
58
|
+
|
|
59
|
+
intersect_pairs = self.scan_intersections(trajectories_p, trajectories_y)
|
|
60
|
+
if (self.p_zone is not None) and (self.y_zone is not None):
|
|
61
|
+
intersect_pairs = self.scan_yield_events_byzone(intersect_pairs, tracks_p, tracks_y)
|
|
62
|
+
else:
|
|
63
|
+
intersect_pairs = self.scan_yield_events(intersect_pairs, tracks_p, tracks_y)
|
|
64
|
+
|
|
65
|
+
return intersect_pairs
|
|
66
|
+
|
|
67
|
+
def gen_ref(self, tracks:pd.DataFrame, info:str='', video_index:int=None, video_tot:int=None)->pd.DataFrame:
|
|
68
|
+
if video_index and video_tot:
|
|
69
|
+
tqdm.pandas(desc='Generating ref {}, {} of {}'.format(info, video_index, video_tot), unit='frames')
|
|
70
|
+
else:
|
|
71
|
+
tqdm.pandas(desc='Generating ref {}'.format(info), unit='frames')
|
|
72
|
+
|
|
73
|
+
if self.ref_point == 'cc':
|
|
74
|
+
tracks[['ref_x', 'ref_y']] = tracks.progress_apply(lambda track: pd.Series([track['x'] + track['w']//2 + self.ref_offset[0],
|
|
75
|
+
track['y'] + track['h']//2 + self.ref_offset[1]]), axis=1)
|
|
76
|
+
elif self.ref_point == 'tc':
|
|
77
|
+
tracks[['ref_x', 'ref_y']] = tracks.progress_apply(lambda track: pd.Series([track['x'] + track['w']//2 + self.ref_offset[0],
|
|
78
|
+
track['y'] + self.ref_offset[1]]), axis=1)
|
|
79
|
+
elif self.ref_point == 'bc':
|
|
80
|
+
tracks[['ref_x', 'ref_y']] = tracks.progress_apply(lambda track: pd.Series([track['x'] + track['w']//2 + self.ref_offset[0],
|
|
81
|
+
track['y'] + track['h'] + self.ref_offset[1]]), axis=1)
|
|
82
|
+
elif self.ref_point == 'cl':
|
|
83
|
+
tracks[['ref_x', 'ref_y']] = tracks.progress_apply(lambda track: pd.Series([track['x'] + self.ref_offset[0],
|
|
84
|
+
track['y'] + track['h']//2 + self.ref_offset[1]]), axis=1)
|
|
85
|
+
elif self.ref_point == 'cr':
|
|
86
|
+
tracks[['ref_x', 'ref_y']] = tracks.progress_apply(lambda track: pd.Series([track['x'] + track['w'] + self.ref_offset[0],
|
|
87
|
+
track['y'] + track['h']//2 + self.ref_offset[1]]), axis=1)
|
|
88
|
+
elif self.ref_point == 'tl':
|
|
89
|
+
tracks[['ref_x', 'ref_y']] = tracks.progress_apply(lambda track: pd.Series([track['x'] + self.ref_offset[0],
|
|
90
|
+
track['y'] + self.ref_offset[1]]), axis=1)
|
|
91
|
+
elif self.ref_point == 'tr':
|
|
92
|
+
tracks[['ref_x', 'ref_y']] = tracks.progress_apply(lambda track: pd.Series([track['x'] + track['w'] + self.ref_offset[0],
|
|
93
|
+
track['y'] + self.ref_offset[1]]), axis=1)
|
|
94
|
+
elif self.ref_point == 'bl':
|
|
95
|
+
tracks[['ref_x', 'ref_y']] = tracks.progress_apply(lambda track: pd.Series([track['x'] + self.ref_offset[0],
|
|
96
|
+
track['y'] + tracks['h'] + self.ref_offset[1]]), axis=1)
|
|
97
|
+
elif self.ref_point == 'br':
|
|
98
|
+
tracks[['ref_x', 'ref_y']] = tracks.progress_apply(lambda track: pd.Series([track['x'] + track['w'] + self.ref_offset[0],
|
|
99
|
+
track['y'] + track['h'] + self.ref_offset[1]]), axis=1)
|
|
100
|
+
else:
|
|
101
|
+
tracks[['ref_x', 'ref_y']] = tracks.progress_apply(lambda track: pd.Series([track['x'] + track['w']//2 + self.ref_offset[0],
|
|
102
|
+
track['y'] + track['h'] + self.ref_offset[1]]), axis=1)
|
|
103
|
+
|
|
104
|
+
return tracks
|
|
105
|
+
|
|
106
|
+
def gen_trajectory(self, tracks:pd.DataFrame, info:str='', video_index:int=None, video_tot:int=None)->gpd.GeoDataFrame:
|
|
107
|
+
|
|
108
|
+
ids = tracks['track'].unique()
|
|
109
|
+
results = []
|
|
110
|
+
lines = []
|
|
111
|
+
pbar = tqdm(total=len(ids), unit='track')
|
|
112
|
+
if video_index and video_tot:
|
|
113
|
+
pbar.desc = 'Generating trajectory {}, {} of {}'.format(info, video_index, video_tot)
|
|
114
|
+
else:
|
|
115
|
+
pbar.desc = 'Generating trajectory {}'.format(info)
|
|
116
|
+
|
|
117
|
+
for id in ids:
|
|
118
|
+
frames = tracks[tracks['track']==id].sort_values(by=['frame'])
|
|
119
|
+
line = LineString(list(zip(frames['ref_x'].values.tolist(), frames['ref_y'].values.tolist())))
|
|
120
|
+
results.append([id, frames['frame'].values, frames['ref_x'].values, frames['ref_y'].values])
|
|
121
|
+
lines.append(line)
|
|
122
|
+
pbar.update()
|
|
123
|
+
pbar.close()
|
|
124
|
+
|
|
125
|
+
df = pd.DataFrame(results, columns=['track', 'frames', 'ref_x', 'ref_y'])
|
|
126
|
+
return gpd.GeoDataFrame(df, geometry=lines)
|
|
127
|
+
|
|
128
|
+
def scan_intersections(self, trajectories_p:gpd.GeoDataFrame, trajectories_y:gpd.GeoDataFrame,
|
|
129
|
+
video_index:int=None, video_tot:int=None):
|
|
130
|
+
|
|
131
|
+
results = []
|
|
132
|
+
points = []
|
|
133
|
+
buffer = self.filter_buffer*self.fps
|
|
134
|
+
|
|
135
|
+
pbar = tqdm(total=len(trajectories_p)*len(trajectories_y), unit=' pair')
|
|
136
|
+
if video_index and video_tot:
|
|
137
|
+
pbar.desc = 'Scan intesections {} of {}'.format(video_index, video_tot)
|
|
138
|
+
else:
|
|
139
|
+
pbar.desc = 'Scan intesections'
|
|
140
|
+
for index1, trj_p in trajectories_p.iterrows():
|
|
141
|
+
for index2, trj_y in trajectories_y.iterrows():
|
|
142
|
+
'''
|
|
143
|
+
if (trj_p['track'] == 511) and (trj_y['track'] == 132590):
|
|
144
|
+
print(trj_p['frames'].min(), trj_p['frames'].max())
|
|
145
|
+
print(trj_y['frames'].min(), trj_y['frames'].max())
|
|
146
|
+
input('...')
|
|
147
|
+
'''
|
|
148
|
+
|
|
149
|
+
if ((trj_p['frames'].min() > (trj_y['frames'].max() + buffer)) or
|
|
150
|
+
(trj_y['frames'].min() > (trj_p['frames'].max() + buffer))):
|
|
151
|
+
pass
|
|
152
|
+
else:
|
|
153
|
+
geo_intersect = intersection(trj_p.geometry, trj_y.geometry)
|
|
154
|
+
if not geo_intersect.is_empty:
|
|
155
|
+
point = self.__recursion(geo_intersect)
|
|
156
|
+
point_xy = np.array([point.x, point.y])
|
|
157
|
+
'''
|
|
158
|
+
if (trj_p['track'] == 2414) & (trj_y['track'] == 386456):
|
|
159
|
+
plt.gca().invert_yaxis()
|
|
160
|
+
plt.plot(*trj_p.geometry.xy, color='red')
|
|
161
|
+
plt.plot(*trj_y.geometry.xy, color='green')
|
|
162
|
+
plt.scatter(*point.xy)
|
|
163
|
+
plt.savefig('/mnt/d/a.jpg')
|
|
164
|
+
|
|
165
|
+
import cv2
|
|
166
|
+
img = cv2.imread('/mnt/d/b.png')
|
|
167
|
+
for x, y in list(zip(trj_p['ref_x'], trj_p['ref_y'])):
|
|
168
|
+
img = cv2.circle(img, (x, y), 1, (0, 0, 255))
|
|
169
|
+
for x, y in list(zip(trj_y['ref_x'], trj_y['ref_y'])):
|
|
170
|
+
img = cv2.circle(img, (x, y), 1, (0, 255, 0))
|
|
171
|
+
img = cv2.circle(img, (int(point.x), int(point.y)), 5, (255, 255, 255), thickness=-1)
|
|
172
|
+
print(int(point.x), int(point.y))
|
|
173
|
+
cv2.imwrite('/mnt/d/c.jpg', img)
|
|
174
|
+
input('...')
|
|
175
|
+
'''
|
|
176
|
+
ref_pxy = np.array(list(zip(trj_p['ref_x'], trj_p['ref_y'])))
|
|
177
|
+
index_p = self.__get_closest_index(ref_pxy, point_xy)
|
|
178
|
+
frame_p = trj_p['frames'][index_p]
|
|
179
|
+
|
|
180
|
+
ref_yxy = np.array(list(zip(trj_y['ref_x'], trj_y['ref_y'])))
|
|
181
|
+
index_y = self.__get_closest_index(ref_yxy, point_xy)
|
|
182
|
+
frame_y = trj_y['frames'][index_y]
|
|
183
|
+
|
|
184
|
+
results.append([trj_p['track'], frame_p, trj_y['track'], frame_y, frame_y-frame_p])
|
|
185
|
+
points.append(point)
|
|
186
|
+
pbar.update()
|
|
187
|
+
|
|
188
|
+
pbar.close()
|
|
189
|
+
|
|
190
|
+
df = pd.DataFrame(results, columns=['track_p', 'frame_p', 'track_y', 'frame_y', 'frame_gap'])
|
|
191
|
+
return gpd.GeoDataFrame(df, geometry=points)
|
|
192
|
+
|
|
193
|
+
def scan_yield_events(self, pairs:gpd.GeoDataFrame, tracks_p:gpd.GeoDataFrame, tracks_y:gpd.GeoDataFrame,
|
|
194
|
+
video_index:int=None, video_tot:int=None)->pd.DataFrame:
|
|
195
|
+
|
|
196
|
+
pbar = tqdm(total=len(pairs), unit=' pair')
|
|
197
|
+
if video_index and video_tot:
|
|
198
|
+
pbar.desc = 'Scan events {} of {}'.format(video_index, video_tot)
|
|
199
|
+
else:
|
|
200
|
+
pbar.desc = 'Scan events'
|
|
201
|
+
for index, pair in pairs.iterrows():
|
|
202
|
+
|
|
203
|
+
if pair['frame_p'] < pair['frame_y']:
|
|
204
|
+
|
|
205
|
+
selected = tracks_y[(tracks_y['track']==pair['track_y']) & (tracks_y['frame']<=pair['frame_y'])].copy() # find the frames for track_y before reaching conflict point
|
|
206
|
+
selected['dif'] = selected['frame'].apply(lambda f: abs(f - pair['frame_p'])) # calculate the frame difference between each before frame and the conflict frame
|
|
207
|
+
selected = selected[selected['dif']<=self.yield_gap] # the frame difference should <= self.yield_gap
|
|
208
|
+
closest = selected[selected['dif']==selected['dif'].min()] # find the closest frame
|
|
209
|
+
if len(closest)>0:
|
|
210
|
+
closest_point = Point(closest['x'].iloc[0]+closest['w'].iloc[0]/2,
|
|
211
|
+
closest['y'].iloc[0]+closest['h'].iloc[0]) # find the cloest point
|
|
212
|
+
dist = distance(closest_point, pair.geometry) # calculate the distance
|
|
213
|
+
pairs.at[index, 'dist_y'] = dist
|
|
214
|
+
inwaiting = 1 if dist<=self.waiting_dist_y else 0
|
|
215
|
+
|
|
216
|
+
if self.leading_y:
|
|
217
|
+
isleading = 1 if self.__is_leading(pair['track_y'], closest['frame'].iloc[0], closest['x'].iloc[0],
|
|
218
|
+
closest['y'].iloc[0], pair.geometry.x, pair.geometry.y, tracks_y, self.leading_axis_y) else 0
|
|
219
|
+
else:
|
|
220
|
+
isleading = 1
|
|
221
|
+
|
|
222
|
+
if (inwaiting == 1) and (isleading == 1):
|
|
223
|
+
pairs.at[index, 'event'] = 'yield'
|
|
224
|
+
|
|
225
|
+
pairs.at[index, 'closest_frame'] = closest['frame'].iloc[0]
|
|
226
|
+
|
|
227
|
+
elif pair['frame_p'] >= pair['frame_y']:
|
|
228
|
+
selected = tracks_p[(tracks_p['track']==pair['track_p']) & (tracks_p['frame']<=pair['frame_p'])].copy()
|
|
229
|
+
selected['dif'] = selected['frame'].apply(lambda f: abs(f - pair['frame_y']))
|
|
230
|
+
selected = selected[selected['dif']<=self.yield_gap]
|
|
231
|
+
closest = selected[selected['dif']==selected['dif'].min()]
|
|
232
|
+
if len(closest)>0:
|
|
233
|
+
closest_point = Point(closest['x'].iloc[0]+closest['w'].iloc[0]/2,
|
|
234
|
+
closest['y'].iloc[0]+closest['h'].iloc[0])
|
|
235
|
+
dist = distance(closest_point, pair.geometry)
|
|
236
|
+
inwaiting = 1 if dist<=self.waiting_dist_p else 0
|
|
237
|
+
pairs.at[index, 'dist_p'] = dist
|
|
238
|
+
if self.leading_p:
|
|
239
|
+
isleading = 1 if self.__is_leading(pair['track_p'], closest['frame'].iloc[0], closest['x'].iloc[0],
|
|
240
|
+
closest['y'].iloc[0], pair.geometry.x, pair.geometry.y, tracks_p, self.leading_axis_p) else 0
|
|
241
|
+
else:
|
|
242
|
+
isleading = 1
|
|
243
|
+
|
|
244
|
+
if (inwaiting == 1) and (isleading == 1):
|
|
245
|
+
pairs.at[index, 'event'] = 'not_yield'
|
|
246
|
+
|
|
247
|
+
pairs.at[index, 'closest_frame'] = closest['frame'].iloc[0]
|
|
248
|
+
|
|
249
|
+
pbar.update()
|
|
250
|
+
|
|
251
|
+
pbar.close()
|
|
252
|
+
|
|
253
|
+
return self.__export(pairs)
|
|
254
|
+
|
|
255
|
+
def scan_yield_events_byzone(self, pairs:gpd.GeoDataFrame, tracks_p:gpd.GeoDataFrame, tracks_y:gpd.GeoDataFrame,
|
|
256
|
+
video_index:int=None, video_tot:int=None)->pd.DataFrame:
|
|
257
|
+
|
|
258
|
+
pbar = tqdm(total=len(pairs), unit=' pair')
|
|
259
|
+
if video_index and video_tot:
|
|
260
|
+
pbar.desc = 'Scan events {} of {}'.format(video_index, video_tot)
|
|
261
|
+
else:
|
|
262
|
+
pbar.desc = 'Scan events'
|
|
263
|
+
for index, pair in pairs.iterrows():
|
|
264
|
+
|
|
265
|
+
if pair['frame_p'] < pair['frame_y']:
|
|
266
|
+
|
|
267
|
+
selected = tracks_y[(tracks_y['track']==pair['track_y']) & (tracks_y['frame']<=pair['frame_y'])].copy() # find the frames for track_y before reaching conflict point
|
|
268
|
+
selected['dif'] = selected['frame'].apply(lambda f: abs(f - pair['frame_p'])) # calculate the frame difference between each before frame and the conflict frame
|
|
269
|
+
selected = selected[selected['dif']<=self.yield_gap] # the frame difference should <= self.yield_gap
|
|
270
|
+
closest = selected[selected['dif']==selected['dif'].min()] # find the closest frame
|
|
271
|
+
if len(closest)>0:
|
|
272
|
+
x, y, w, h = closest['x'].iloc[0], closest['y'].iloc[0], closest['w'].iloc[0], closest['h'].iloc[0]
|
|
273
|
+
closest_bbox = Polygon([(x, y), (x + w, y), (x + w, y + h), (x, y + h)])
|
|
274
|
+
|
|
275
|
+
inwaiting = 1 if intersects(closest_bbox, self.y_zone) else 0
|
|
276
|
+
pairs.at[index, 'dist_y'] = -1
|
|
277
|
+
if self.leading_y:
|
|
278
|
+
isleading = 1 if self.__is_leading(pair['track_y'], closest['frame'].iloc[0], closest['x'].iloc[0],
|
|
279
|
+
closest['y'].iloc[0], pair.geometry.x, pair.geometry.y, tracks_y, self.leading_axis_y) else 0
|
|
280
|
+
else:
|
|
281
|
+
isleading = 1
|
|
282
|
+
|
|
283
|
+
if (inwaiting == 1) and (isleading == 1):
|
|
284
|
+
pairs.at[index, 'event'] = 'yield'
|
|
285
|
+
|
|
286
|
+
pairs.at[index, 'closest_frame'] = closest['frame'].iloc[0]
|
|
287
|
+
|
|
288
|
+
elif pair['frame_p'] >= pair['frame_y']:
|
|
289
|
+
selected = tracks_p[(tracks_p['track']==pair['track_p']) & (tracks_p['frame']<=pair['frame_p'])].copy()
|
|
290
|
+
selected['dif'] = selected['frame'].apply(lambda f: abs(f - pair['frame_y']))
|
|
291
|
+
selected = selected[selected['dif']<=self.yield_gap]
|
|
292
|
+
closest = selected[selected['dif']==selected['dif'].min()]
|
|
293
|
+
if len(closest)>0:
|
|
294
|
+
x, y, w, h = closest['x'].iloc[0], closest['y'].iloc[0], closest['w'].iloc[0], closest['h'].iloc[0]
|
|
295
|
+
closest_bbox = Polygon([(x, y), (x + w, y), (x + w, y + h), (x, y + h)])
|
|
296
|
+
|
|
297
|
+
inwaiting = 1 if intersects(closest_bbox, self.p_zone) else 0
|
|
298
|
+
pairs.at[index, 'dist_p'] = -1
|
|
299
|
+
if self.leading_p:
|
|
300
|
+
isleading = 1 if self.__is_leading(pair['track_p'], closest['frame'].iloc[0], closest['x'].iloc[0],
|
|
301
|
+
closest['y'].iloc[0], pair.geometry.x, pair.geometry.y, tracks_p, self.leading_axis_p) else 0
|
|
302
|
+
else:
|
|
303
|
+
isleading = 1
|
|
304
|
+
|
|
305
|
+
if (inwaiting == 1) and (isleading == 1):
|
|
306
|
+
pairs.at[index, 'event'] = 'not_yield'
|
|
307
|
+
|
|
308
|
+
pairs.at[index, 'closest_frame'] = closest['frame'].iloc[0]
|
|
309
|
+
|
|
310
|
+
pbar.update()
|
|
311
|
+
|
|
312
|
+
pbar.close()
|
|
313
|
+
|
|
314
|
+
return self.__export(pairs)
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
def __export(self, pairs:gpd.GeoDataFrame):
|
|
318
|
+
pairs['int_x'] = pairs.geometry.x
|
|
319
|
+
pairs['int_y'] = pairs.geometry.y
|
|
320
|
+
return pd.DataFrame(pairs.drop(columns=['geometry']))
|
|
321
|
+
|
|
322
|
+
def __recursion(self, intersect):
|
|
323
|
+
if intersect.geom_type == 'Point':
|
|
324
|
+
return Point(intersect.coords[0])
|
|
325
|
+
|
|
326
|
+
elif intersect.geom_type == 'MultiPoint':
|
|
327
|
+
return Point(intersect.geoms[0].x, intersect.geoms[0].y)
|
|
328
|
+
|
|
329
|
+
elif intersect.geom_type == 'LineString':
|
|
330
|
+
return Point(intersect.coords[0])
|
|
331
|
+
|
|
332
|
+
elif intersect.geom_type == 'MultiLineString':
|
|
333
|
+
return Point(intersect.geoms[0].coords[0])
|
|
334
|
+
|
|
335
|
+
else:
|
|
336
|
+
for geom in intersect.geoms:
|
|
337
|
+
return self.__recursion(geom)
|
|
338
|
+
|
|
339
|
+
def __get_closest_index(self, ref:np.array, point:np.array) -> int:
|
|
340
|
+
return np.argmin(np.sqrt(np.sum(np.square(ref - point), axis=1)))
|
|
341
|
+
|
|
342
|
+
def __is_leading(self, track_id:int, frame_close:int, close_x:int, close_y:int, int_x:int, int_y:int,
|
|
343
|
+
tracks:gpd.GeoDataFrame, leading_axis:str):
|
|
344
|
+
|
|
345
|
+
min_x = min(close_x, int_x)
|
|
346
|
+
max_x = max(close_x, int_x)
|
|
347
|
+
min_y = min(close_y, int_y)
|
|
348
|
+
max_y = max(close_y, int_y)
|
|
349
|
+
if leading_axis == 'x':
|
|
350
|
+
leadings = tracks[(tracks['track']!=track_id) & (tracks['frame']==frame_close) &
|
|
351
|
+
(tracks['ref_x']>=min_x) & (tracks['ref_x']<=max_x)]
|
|
352
|
+
elif leading_axis == 'y':
|
|
353
|
+
leadings = tracks[(tracks['track']!=track_id) & (tracks['frame']==frame_close) &
|
|
354
|
+
(tracks['ref_y']>=min_y) & (tracks['ref_y']<=max_y)]
|
|
355
|
+
elif leading_axis == 'xy':
|
|
356
|
+
leadings = tracks[(tracks['track']!=track_id) & (tracks['frame']==frame_close) &
|
|
357
|
+
(tracks['ref_x']>=min_x) & (tracks['ref_x']<=max_x) &
|
|
358
|
+
(tracks['ref_y']>=min_y) & (tracks['ref_y']<=max_y)]
|
|
359
|
+
|
|
360
|
+
if len(leadings) > 0:
|
|
361
|
+
return False
|
|
362
|
+
else:
|
|
363
|
+
return True
|
|
364
|
+
|
|
365
|
+
def __get_waiting_trj_y(self, track_id:int, frame_id_p:int, frame_id_y:int, intersect_point:Point, trajectories:gpd.GeoDataFrame) -> any:
|
|
366
|
+
|
|
367
|
+
result = -1
|
|
368
|
+
if frame_id_p < frame_id_y:
|
|
369
|
+
selected = trajectories[trajectories['track']==track_id]
|
|
370
|
+
df = pd.DataFrame(np.vstack((selected['frames'].tolist(), selected['ref_x'].tolist(), selected['ref_y'].tolist())).T,
|
|
371
|
+
columns=['frame', 'x', 'y'])
|
|
372
|
+
df = df.loc[df['frame']<=frame_id_y]
|
|
373
|
+
df['dif'] = df['frame'].apply(lambda f: abs((f - frame_id_p)))
|
|
374
|
+
closest = df[df['dif']==df['dif'].min()]
|
|
375
|
+
closest_point = Point(closest['x'].ioc[0], closest['y'].ioc[0])
|
|
376
|
+
dist = distance(closest, intersect_point)
|
|
377
|
+
|
|
378
|
+
return result
|
|
379
|
+
|
|
380
|
+
@staticmethod
|
|
381
|
+
def add_field_names(tracks: pd.DataFrame)->pd.DataFrame:
|
|
382
|
+
if len(tracks.columns)==10:
|
|
383
|
+
tracks.columns = ['frame', 'track', 'x', 'y', 'w', 'h', 'score', 'cls', 'r3','r4']
|
|
384
|
+
tracks['ref_x'] = -1
|
|
385
|
+
tracks['ref_y'] = -1
|
|
386
|
+
elif len(tracks.columns) == 12:
|
|
387
|
+
tracks.columns = ['frame', 'track', 'x', 'y', 'w', 'h', 'score', 'cls', 'r3','r4',
|
|
388
|
+
'ref_x', 'ref_y']
|
|
389
|
+
else:
|
|
390
|
+
raise Exception('The number of fields is invalid.')
|
|
391
|
+
return tracks
|
|
392
|
+
|
|
393
|
+
@staticmethod
|
|
394
|
+
def draw_event_clips(yields:pd.DataFrame, tracks_p:pd.DataFrame, tracks_y:pd.DataFrame, input_video:str, out_path:str,
|
|
395
|
+
method:str='all', random_number:int=10, event_list:list=None, size:int=1, thick:int=2, padding:int=0,
|
|
396
|
+
show_track:bool=False, show_desc:bool=False, verbose:bool=True,
|
|
397
|
+
video_index:int=None, video_tot:int=None):
|
|
398
|
+
'''
|
|
399
|
+
Parameters:
|
|
400
|
+
- yields: the dataframe of stop events
|
|
401
|
+
- tracks_p: the dataframe of tracks with priority
|
|
402
|
+
- tracks_y: the dataframe of tracks should yield
|
|
403
|
+
- input_video: the raw video file, if None, generate the label files only
|
|
404
|
+
- out_path: the folder for outputing track clips
|
|
405
|
+
- method: 'all' (default) - all tracks, 'specify' - specify events,
|
|
406
|
+
'yield' - yield events, 'not_yield' - non-yield events, 'none' - non interaction events
|
|
407
|
+
- random_number: the number of track ids if method == 'random'
|
|
408
|
+
- event_list: the list of events [(track_p_id, track_y_id)] if method == 'specify'
|
|
409
|
+
- size: font size, default is 1
|
|
410
|
+
- thick: line thinckness, defualt is 2
|
|
411
|
+
- padding: add addtional frames at beggining and ending, default is 0
|
|
412
|
+
- show_track: show track id, default is False
|
|
413
|
+
- show_desc: show event desc, default is Falase
|
|
414
|
+
- verbose: if show progressing bar, default is True
|
|
415
|
+
- video_idex: the index of the video in processing
|
|
416
|
+
- video_tot: the total number of videos
|
|
417
|
+
|
|
418
|
+
Return:
|
|
419
|
+
- A list of dataframes for labels, ['frame','type','coords','color','size','thick','desc']
|
|
420
|
+
'''
|
|
421
|
+
|
|
422
|
+
tracks_p = YieldAnalyzer.add_field_names(tracks_p)
|
|
423
|
+
tracks_y = YieldAnalyzer.add_field_names(tracks_y)
|
|
424
|
+
|
|
425
|
+
tracks_p_grouped = tracks_p.groupby('track')
|
|
426
|
+
tracks_y_grouped = tracks_y.groupby('track')
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
if method == 'all':
|
|
430
|
+
events = yields
|
|
431
|
+
elif method == 'specify':
|
|
432
|
+
events = []
|
|
433
|
+
for p, y in event_list:
|
|
434
|
+
events.append(yields[(yields['track_p']==p) & (yields['track_y']==y)])
|
|
435
|
+
events = pd.concat(events)
|
|
436
|
+
elif method == 'yield':
|
|
437
|
+
events = yields[yields['event']=='yield'].copy()
|
|
438
|
+
elif method == 'not_yield':
|
|
439
|
+
events = yields[yields['event']=='not_yield'].copy()
|
|
440
|
+
elif method == 'event':
|
|
441
|
+
events = yields[yields['event'].isin(['yield', 'not_yield'])].copy()
|
|
442
|
+
elif method == 'none':
|
|
443
|
+
events = yields[~yields['event'].isin(['yield', 'not_yield'])].copy()
|
|
444
|
+
|
|
445
|
+
pbar = tqdm(total= len(events) , unit='event')
|
|
446
|
+
if video_index and video_tot:
|
|
447
|
+
pbar.set_description_str("Generating labeles for yielding events {} of {}".format(video_index, video_tot))
|
|
448
|
+
else:
|
|
449
|
+
pbar.set_description_str("Generating labels for yielding events")
|
|
450
|
+
|
|
451
|
+
labeler = Labeler()
|
|
452
|
+
for index, event in events.iterrows():
|
|
453
|
+
result = []
|
|
454
|
+
track_p_id = event['track_p']
|
|
455
|
+
track_y_id = event['track_y']
|
|
456
|
+
int_x = int(event['int_x'])
|
|
457
|
+
int_y = int(event['int_y'])
|
|
458
|
+
|
|
459
|
+
if event['event'] == 'yield':
|
|
460
|
+
desc = 'yield'
|
|
461
|
+
color = (0, 255, 0)
|
|
462
|
+
elif event['event'] == 'not_yield':
|
|
463
|
+
desc = 'not yield'
|
|
464
|
+
color = (0, 0, 255)
|
|
465
|
+
else:
|
|
466
|
+
desc = 'no interaction'
|
|
467
|
+
color = (255, 0, 0)
|
|
468
|
+
|
|
469
|
+
frames_p = tracks_p_grouped.get_group(track_p_id)
|
|
470
|
+
frames_y = tracks_y_grouped.get_group(track_y_id)
|
|
471
|
+
frames = pd.concat([frames_p, frames_y])
|
|
472
|
+
for index2, frame in frames.iterrows():
|
|
473
|
+
label_text = ''
|
|
474
|
+
if show_track:
|
|
475
|
+
label_text+='| T:'+str(int(frame['track']))
|
|
476
|
+
|
|
477
|
+
if show_desc:
|
|
478
|
+
label_text+= ' | '+desc
|
|
479
|
+
|
|
480
|
+
result.append([frame['frame'], 'bbox', [(frame['x'], frame['y']), (frame['x']+frame['w'], frame['y']+frame['h'])],
|
|
481
|
+
color, size, thick, label_text])
|
|
482
|
+
result.append([frame['frame'], 'box', [(int_x - 5, int_y - 5), (int_x + 5, int_y + 5)],
|
|
483
|
+
(255, 255, 0), size, thick, ''])
|
|
484
|
+
|
|
485
|
+
df = pd.DataFrame(result, columns=['frame','type','coords','color','size','thick','desc'])
|
|
486
|
+
|
|
487
|
+
if out_path:
|
|
488
|
+
file_name = os.path.join(out_path, str(track_p_id)+'-'+str(track_y_id)+'_label.csv')
|
|
489
|
+
df.to_csv(file_name, index=False)
|
|
490
|
+
|
|
491
|
+
if input_video:
|
|
492
|
+
file_name = os.path.join(out_path, str(track_p_id)+'-'+str(track_y_id)+'_label.mp4')
|
|
493
|
+
min_frame = df['frame'].min() - padding
|
|
494
|
+
max_frame = df['frame'].max() + padding
|
|
495
|
+
labeler.draw(input_video=input_video, output_video=file_name, draws=df,
|
|
496
|
+
start_frame=min_frame, end_frame=max_frame, verbose=False)
|
|
497
|
+
|
|
498
|
+
if verbose:
|
|
499
|
+
pbar.update()
|
|
500
|
+
|
|
501
|
+
pbar.close()
|
|
502
|
+
|
|
503
|
+
|
|
File without changes
|