dnt 0.2.4__py3-none-any.whl → 0.3.1.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of dnt might be problematic. Click here for more details.
- dnt/__init__.py +3 -2
- dnt/analysis/__init__.py +3 -2
- dnt/analysis/count.py +54 -37
- dnt/analysis/interaction2.py +518 -0
- dnt/analysis/stop.py +22 -17
- dnt/analysis/stop2.py +289 -0
- dnt/analysis/stop3.py +758 -0
- dnt/detect/signal/detector.py +326 -0
- dnt/detect/timestamp.py +105 -0
- dnt/detect/yolov8/detector.py +179 -36
- dnt/detect/yolov8/segmentor.py +60 -2
- dnt/engine/__init__.py +8 -0
- dnt/engine/bbox_interp.py +83 -0
- dnt/engine/bbox_iou.py +20 -0
- dnt/engine/cluster.py +31 -0
- dnt/engine/iob.py +66 -0
- dnt/filter/filter.py +333 -2
- dnt/label/labeler.py +4 -4
- dnt/label/labeler2.py +605 -0
- dnt/shared/__init__.py +2 -1
- dnt/shared/data/coco.names +0 -0
- dnt/shared/data/openimages.names +0 -0
- dnt/shared/data/voc.names +0 -0
- dnt/shared/download.py +12 -0
- dnt/shared/synhcro.py +150 -0
- dnt/shared/util.py +17 -4
- dnt/third_party/fast-reid/__init__.py +1 -0
- dnt/third_party/fast-reid/configs/Base-AGW.yml +19 -0
- dnt/third_party/fast-reid/configs/Base-MGN.yml +12 -0
- dnt/third_party/fast-reid/configs/Base-SBS.yml +63 -0
- dnt/third_party/fast-reid/configs/Base-bagtricks.yml +76 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/AGW_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/AGW_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/AGW_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/AGW_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/mgn_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/sbs_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/sbs_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/sbs_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/sbs_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/AGW_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MOT17/AGW_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/AGW_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MOT17/AGW_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/bagtricks_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MOT17/bagtricks_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/bagtricks_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MOT17/bagtricks_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/mgn_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/sbs_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MOT17/sbs_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/sbs_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MOT17/sbs_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/AGW_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MOT20/AGW_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/AGW_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MOT20/AGW_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/bagtricks_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MOT20/bagtricks_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/bagtricks_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MOT20/bagtricks_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/mgn_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/sbs_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MOT20/sbs_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/sbs_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MOT20/sbs_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MSMT17/AGW_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MSMT17/AGW_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MSMT17/AGW_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MSMT17/AGW_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MSMT17/bagtricks_R101-ibn.yml +13 -0
- dnt/third_party/fast-reid/configs/MSMT17/bagtricks_R50-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MSMT17/bagtricks_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MSMT17/bagtricks_S50.yml +12 -0
- dnt/third_party/fast-reid/configs/MSMT17/mgn_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MSMT17/sbs_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MSMT17/sbs_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MSMT17/sbs_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MSMT17/sbs_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/AGW_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/Market1501/AGW_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/AGW_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/Market1501/AGW_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/bagtricks_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/Market1501/bagtricks_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/bagtricks_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/Market1501/bagtricks_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/bagtricks_vit.yml +88 -0
- dnt/third_party/fast-reid/configs/Market1501/mgn_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/sbs_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/Market1501/sbs_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/sbs_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/Market1501/sbs_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/VERIWild/bagtricks_R50-ibn.yml +35 -0
- dnt/third_party/fast-reid/configs/VeRi/sbs_R50-ibn.yml +35 -0
- dnt/third_party/fast-reid/configs/VehicleID/bagtricks_R50-ibn.yml +36 -0
- dnt/third_party/fast-reid/configs/__init__.py +0 -0
- dnt/third_party/fast-reid/fast_reid_interfece.py +175 -0
- dnt/third_party/fast-reid/fastreid/__init__.py +6 -0
- dnt/third_party/fast-reid/fastreid/config/__init__.py +15 -0
- dnt/third_party/fast-reid/fastreid/config/config.py +319 -0
- dnt/third_party/fast-reid/fastreid/config/defaults.py +329 -0
- dnt/third_party/fast-reid/fastreid/data/__init__.py +17 -0
- dnt/third_party/fast-reid/fastreid/data/build.py +194 -0
- dnt/third_party/fast-reid/fastreid/data/common.py +58 -0
- dnt/third_party/fast-reid/fastreid/data/data_utils.py +202 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/AirportALERT.py +50 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/__init__.py +43 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/bases.py +183 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/caviara.py +44 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/cuhk03.py +274 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/cuhk_sysu.py +58 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/dukemtmcreid.py +70 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/grid.py +44 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/iLIDS.py +45 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/lpw.py +49 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/market1501.py +89 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/msmt17.py +114 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/pes3d.py +44 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/pku.py +44 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/prai.py +43 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/prid.py +41 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/saivt.py +47 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/sensereid.py +47 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/shinpuhkan.py +48 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/sysu_mm.py +47 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/thermalworld.py +43 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/vehicleid.py +126 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/veri.py +69 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/veriwild.py +140 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/viper.py +45 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/wildtracker.py +59 -0
- dnt/third_party/fast-reid/fastreid/data/samplers/__init__.py +18 -0
- dnt/third_party/fast-reid/fastreid/data/samplers/data_sampler.py +85 -0
- dnt/third_party/fast-reid/fastreid/data/samplers/imbalance_sampler.py +67 -0
- dnt/third_party/fast-reid/fastreid/data/samplers/triplet_sampler.py +260 -0
- dnt/third_party/fast-reid/fastreid/data/transforms/__init__.py +11 -0
- dnt/third_party/fast-reid/fastreid/data/transforms/autoaugment.py +806 -0
- dnt/third_party/fast-reid/fastreid/data/transforms/build.py +100 -0
- dnt/third_party/fast-reid/fastreid/data/transforms/functional.py +180 -0
- dnt/third_party/fast-reid/fastreid/data/transforms/transforms.py +161 -0
- dnt/third_party/fast-reid/fastreid/engine/__init__.py +15 -0
- dnt/third_party/fast-reid/fastreid/engine/defaults.py +490 -0
- dnt/third_party/fast-reid/fastreid/engine/hooks.py +534 -0
- dnt/third_party/fast-reid/fastreid/engine/launch.py +103 -0
- dnt/third_party/fast-reid/fastreid/engine/train_loop.py +357 -0
- dnt/third_party/fast-reid/fastreid/evaluation/__init__.py +6 -0
- dnt/third_party/fast-reid/fastreid/evaluation/clas_evaluator.py +81 -0
- dnt/third_party/fast-reid/fastreid/evaluation/evaluator.py +176 -0
- dnt/third_party/fast-reid/fastreid/evaluation/query_expansion.py +46 -0
- dnt/third_party/fast-reid/fastreid/evaluation/rank.py +200 -0
- dnt/third_party/fast-reid/fastreid/evaluation/rank_cylib/__init__.py +20 -0
- dnt/third_party/fast-reid/fastreid/evaluation/rank_cylib/setup.py +32 -0
- dnt/third_party/fast-reid/fastreid/evaluation/rank_cylib/test_cython.py +106 -0
- dnt/third_party/fast-reid/fastreid/evaluation/reid_evaluation.py +143 -0
- dnt/third_party/fast-reid/fastreid/evaluation/rerank.py +73 -0
- dnt/third_party/fast-reid/fastreid/evaluation/roc.py +90 -0
- dnt/third_party/fast-reid/fastreid/evaluation/testing.py +88 -0
- dnt/third_party/fast-reid/fastreid/layers/__init__.py +19 -0
- dnt/third_party/fast-reid/fastreid/layers/activation.py +59 -0
- dnt/third_party/fast-reid/fastreid/layers/any_softmax.py +80 -0
- dnt/third_party/fast-reid/fastreid/layers/batch_norm.py +205 -0
- dnt/third_party/fast-reid/fastreid/layers/context_block.py +113 -0
- dnt/third_party/fast-reid/fastreid/layers/drop.py +161 -0
- dnt/third_party/fast-reid/fastreid/layers/frn.py +199 -0
- dnt/third_party/fast-reid/fastreid/layers/gather_layer.py +30 -0
- dnt/third_party/fast-reid/fastreid/layers/helpers.py +31 -0
- dnt/third_party/fast-reid/fastreid/layers/non_local.py +54 -0
- dnt/third_party/fast-reid/fastreid/layers/pooling.py +124 -0
- dnt/third_party/fast-reid/fastreid/layers/se_layer.py +25 -0
- dnt/third_party/fast-reid/fastreid/layers/splat.py +109 -0
- dnt/third_party/fast-reid/fastreid/layers/weight_init.py +122 -0
- dnt/third_party/fast-reid/fastreid/modeling/__init__.py +23 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/__init__.py +18 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/build.py +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/mobilenet.py +195 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/mobilenetv3.py +283 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/osnet.py +525 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/__init__.py +4 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/config.py +396 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B0_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B1_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B2_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B3_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B4_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B5_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet.py +281 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnet.py +596 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-1.6GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-12GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-16GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-200MF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-3.2GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-32GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-4.0GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-400MF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-6.4GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-600MF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-8.0GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-800MF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-1.6GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-12GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-16GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-200MF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-3.2GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-32GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-4.0GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-400MF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-6.4GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-600MF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-8.0GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-800MF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/repvgg.py +309 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/resnest.py +365 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/resnet.py +364 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/resnext.py +335 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/shufflenet.py +203 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/vision_transformer.py +399 -0
- dnt/third_party/fast-reid/fastreid/modeling/heads/__init__.py +11 -0
- dnt/third_party/fast-reid/fastreid/modeling/heads/build.py +25 -0
- dnt/third_party/fast-reid/fastreid/modeling/heads/clas_head.py +36 -0
- dnt/third_party/fast-reid/fastreid/modeling/heads/embedding_head.py +151 -0
- dnt/third_party/fast-reid/fastreid/modeling/losses/__init__.py +12 -0
- dnt/third_party/fast-reid/fastreid/modeling/losses/circle_loss.py +71 -0
- dnt/third_party/fast-reid/fastreid/modeling/losses/cross_entroy_loss.py +54 -0
- dnt/third_party/fast-reid/fastreid/modeling/losses/focal_loss.py +92 -0
- dnt/third_party/fast-reid/fastreid/modeling/losses/triplet_loss.py +113 -0
- dnt/third_party/fast-reid/fastreid/modeling/losses/utils.py +48 -0
- dnt/third_party/fast-reid/fastreid/modeling/meta_arch/__init__.py +14 -0
- dnt/third_party/fast-reid/fastreid/modeling/meta_arch/baseline.py +188 -0
- dnt/third_party/fast-reid/fastreid/modeling/meta_arch/build.py +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/meta_arch/distiller.py +140 -0
- dnt/third_party/fast-reid/fastreid/modeling/meta_arch/mgn.py +394 -0
- dnt/third_party/fast-reid/fastreid/modeling/meta_arch/moco.py +126 -0
- dnt/third_party/fast-reid/fastreid/solver/__init__.py +8 -0
- dnt/third_party/fast-reid/fastreid/solver/build.py +348 -0
- dnt/third_party/fast-reid/fastreid/solver/lr_scheduler.py +66 -0
- dnt/third_party/fast-reid/fastreid/solver/optim/__init__.py +10 -0
- dnt/third_party/fast-reid/fastreid/solver/optim/lamb.py +123 -0
- dnt/third_party/fast-reid/fastreid/solver/optim/radam.py +149 -0
- dnt/third_party/fast-reid/fastreid/solver/optim/swa.py +246 -0
- dnt/third_party/fast-reid/fastreid/utils/__init__.py +6 -0
- dnt/third_party/fast-reid/fastreid/utils/checkpoint.py +503 -0
- dnt/third_party/fast-reid/fastreid/utils/collect_env.py +158 -0
- dnt/third_party/fast-reid/fastreid/utils/comm.py +255 -0
- dnt/third_party/fast-reid/fastreid/utils/compute_dist.py +200 -0
- dnt/third_party/fast-reid/fastreid/utils/env.py +119 -0
- dnt/third_party/fast-reid/fastreid/utils/events.py +461 -0
- dnt/third_party/fast-reid/fastreid/utils/faiss_utils.py +127 -0
- dnt/third_party/fast-reid/fastreid/utils/file_io.py +520 -0
- dnt/third_party/fast-reid/fastreid/utils/history_buffer.py +71 -0
- dnt/third_party/fast-reid/fastreid/utils/logger.py +211 -0
- dnt/third_party/fast-reid/fastreid/utils/params.py +103 -0
- dnt/third_party/fast-reid/fastreid/utils/precision_bn.py +94 -0
- dnt/third_party/fast-reid/fastreid/utils/registry.py +66 -0
- dnt/third_party/fast-reid/fastreid/utils/summary.py +120 -0
- dnt/third_party/fast-reid/fastreid/utils/timer.py +68 -0
- dnt/third_party/fast-reid/fastreid/utils/visualizer.py +278 -0
- dnt/track/__init__.py +2 -0
- dnt/track/botsort/__init__.py +4 -0
- dnt/track/botsort/bot_tracker/__init__.py +3 -0
- dnt/track/botsort/bot_tracker/basetrack.py +60 -0
- dnt/track/botsort/bot_tracker/bot_sort.py +473 -0
- dnt/track/botsort/bot_tracker/gmc.py +316 -0
- dnt/track/botsort/bot_tracker/kalman_filter.py +269 -0
- dnt/track/botsort/bot_tracker/matching.py +194 -0
- dnt/track/botsort/bot_tracker/mc_bot_sort.py +505 -0
- dnt/track/{dsort/utils → botsort/bot_tracker/tracking_utils}/evaluation.py +14 -4
- dnt/track/{dsort/utils → botsort/bot_tracker/tracking_utils}/io.py +19 -36
- dnt/track/botsort/bot_tracker/tracking_utils/timer.py +37 -0
- dnt/track/botsort/inference.py +96 -0
- dnt/track/config.py +120 -0
- dnt/track/dsort/configs/bagtricks_R50.yml +7 -0
- dnt/track/dsort/configs/deep_sort.yaml +0 -0
- dnt/track/dsort/configs/fastreid.yaml +1 -1
- dnt/track/dsort/deep_sort/deep/checkpoint/ckpt.t7 +0 -0
- dnt/track/dsort/deep_sort/deep/feature_extractor.py +87 -8
- dnt/track/dsort/deep_sort/deep_sort.py +31 -20
- dnt/track/dsort/deep_sort/sort/detection.py +2 -1
- dnt/track/dsort/deep_sort/sort/iou_matching.py +0 -2
- dnt/track/dsort/deep_sort/sort/linear_assignment.py +0 -3
- dnt/track/dsort/deep_sort/sort/nn_matching.py +5 -5
- dnt/track/dsort/deep_sort/sort/preprocessing.py +1 -2
- dnt/track/dsort/deep_sort/sort/track.py +2 -1
- dnt/track/dsort/deep_sort/sort/tracker.py +1 -1
- dnt/track/dsort/dsort.py +43 -33
- dnt/track/re_class.py +117 -0
- dnt/track/sort/sort.py +9 -6
- dnt/track/tracker.py +213 -32
- {dnt-0.2.4.dist-info → dnt-0.3.1.7.dist-info}/METADATA +41 -13
- dnt-0.3.1.7.dist-info/RECORD +315 -0
- {dnt-0.2.4.dist-info → dnt-0.3.1.7.dist-info}/WHEEL +1 -1
- dnt/analysis/yield.py +0 -9
- dnt/track/dsort/deep_sort/deep/evaluate.py +0 -15
- dnt/track/dsort/deep_sort/deep/original_model.py +0 -106
- dnt/track/dsort/deep_sort/deep/test.py +0 -77
- dnt/track/dsort/deep_sort/deep/train.py +0 -189
- dnt/track/dsort/utils/asserts.py +0 -13
- dnt/track/dsort/utils/draw.py +0 -36
- dnt/track/dsort/utils/json_logger.py +0 -383
- dnt/track/dsort/utils/log.py +0 -17
- dnt/track/dsort/utils/parser.py +0 -35
- dnt/track/dsort/utils/tools.py +0 -39
- dnt-0.2.4.dist-info/RECORD +0 -64
- /dnt/{track/dsort/utils → third_party/fast-reid/checkpoint}/__init__.py +0 -0
- {dnt-0.2.4.dist-info → dnt-0.3.1.7.dist-info/licenses}/LICENSE +0 -0
- {dnt-0.2.4.dist-info → dnt-0.3.1.7.dist-info}/top_level.txt +0 -0
dnt/analysis/stop3.py
ADDED
|
@@ -0,0 +1,758 @@
|
|
|
1
|
+
from shapely.geometry import Point, Polygon, LineString, box
|
|
2
|
+
from shapely import intersects
|
|
3
|
+
import geopandas as gpd, pandas as pd
|
|
4
|
+
import datetime
|
|
5
|
+
from tqdm import tqdm
|
|
6
|
+
from cython_bbox import bbox_overlaps
|
|
7
|
+
import numpy as np
|
|
8
|
+
#import mapply
|
|
9
|
+
import sys
|
|
10
|
+
import os
|
|
11
|
+
sys.path.append(os.path.dirname(__file__))
|
|
12
|
+
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
|
13
|
+
from filter import Filter
|
|
14
|
+
from matplotlib import pyplot as plt
|
|
15
|
+
import random, os
|
|
16
|
+
from label.labeler2 import Labeler
|
|
17
|
+
from engine.bbox_iou import ious
|
|
18
|
+
|
|
19
|
+
class StopAnalyzer():
|
|
20
|
+
def __init__(self,
|
|
21
|
+
stop_zones:list[Polygon],
|
|
22
|
+
lane_zones:list[Polygon],
|
|
23
|
+
event_dicts:list[dict],
|
|
24
|
+
|
|
25
|
+
stop_iou:float=0.97,
|
|
26
|
+
iou_mode:str='edge',
|
|
27
|
+
frame_buffer:int=5,
|
|
28
|
+
|
|
29
|
+
stop_zone_mode:str='iob',
|
|
30
|
+
bbox_iob:float=0.05,
|
|
31
|
+
bbox_offset:tuple=(0, 0, 0, 0),
|
|
32
|
+
|
|
33
|
+
lane_zone_ref:str = 'br',
|
|
34
|
+
ref_offset:tuple=(0, 0),
|
|
35
|
+
lane_adjust:bool=False,
|
|
36
|
+
|
|
37
|
+
leading_axis:str='x',
|
|
38
|
+
leading_direct:str='+',
|
|
39
|
+
leading_buffer:int = 30,
|
|
40
|
+
verbose:bool=True):
|
|
41
|
+
|
|
42
|
+
'''
|
|
43
|
+
Parameters:
|
|
44
|
+
stop_zones: A list of Polygons for identifying stopping position, the priority of zones is ascending
|
|
45
|
+
lane_zones: A list of Polygons for identifying lanes
|
|
46
|
+
event_dicts: A list of dicts to define event code, event description, and associated stop zone
|
|
47
|
+
stop_iou: The threshold for stopping, stop if iou > the threshold
|
|
48
|
+
iou_mode: The mode to judge stop, default is 'edge' [the differenc between two ends], 'mean', 'max'
|
|
49
|
+
frame_buffer: the number of consecutive frames for stopping identification
|
|
50
|
+
stop_zone_mode: default is 'iob' - intersection over bbox, 'intersect' - if bbox and stop zone intersected
|
|
51
|
+
bbox_iob: the threshold for iob, default is 0.05
|
|
52
|
+
bbox_offset: the offset (x1, y1, x2, y2) for bbox, default is (0, 0, 0, 0)
|
|
53
|
+
lane_zone_ref: the reference point for lane recognition
|
|
54
|
+
br (buttom-right, default), bl (bottom-left), bc (bottom-center)
|
|
55
|
+
tl (top-left), tr (top-right), tc (top-center)
|
|
56
|
+
cc (center-center), cl (center-left), cr (center-right)
|
|
57
|
+
ref_offset: the offset (x, y) for reference point, default is (0, 0)
|
|
58
|
+
lane_adjust: If adjust lane zone for the missed frames (lane_zone=-1) based on the most frequent lane zone, default is True
|
|
59
|
+
leading_axis: the axis of stop zone indexes to identify leading vehicles (vehicle travel direction)
|
|
60
|
+
'x' (default), 'y', 'xy'
|
|
61
|
+
leading_direct: leading direction - '+' (default) increased, '-' descreased, '+-', increased in x and decreased in y
|
|
62
|
+
verbsoe: Display processing bars, default is True
|
|
63
|
+
'''
|
|
64
|
+
self.hzones = stop_zones
|
|
65
|
+
self.vzones = lane_zones
|
|
66
|
+
self.event_dicts = event_dicts
|
|
67
|
+
self.stop_iou = stop_iou
|
|
68
|
+
self.iou_mode = iou_mode
|
|
69
|
+
self.frame_buffer = frame_buffer
|
|
70
|
+
self.ref_point = lane_zone_ref
|
|
71
|
+
self.stop_zone_mode = stop_zone_mode
|
|
72
|
+
self.stop_iob = bbox_iob
|
|
73
|
+
self.hzone_offset = bbox_offset
|
|
74
|
+
self.vzone_offset = ref_offset
|
|
75
|
+
self.vzone_adjust = lane_adjust
|
|
76
|
+
self.leading_axis = leading_axis
|
|
77
|
+
self.leading_direct = leading_direct
|
|
78
|
+
self.leading_buffer = leading_buffer
|
|
79
|
+
self.verbose = verbose
|
|
80
|
+
|
|
81
|
+
def analysis_first_stop(self, tracks:pd.DataFrame, video_index:int=None, video_tot:int=None):
|
|
82
|
+
'''
|
|
83
|
+
Inputs:
|
|
84
|
+
tracks: vehicle tracks
|
|
85
|
+
video_index: index of video
|
|
86
|
+
video_tot: total number of videos
|
|
87
|
+
Outputs:
|
|
88
|
+
tracks: vehicle tracks with stop analysis results
|
|
89
|
+
events: event count
|
|
90
|
+
'''
|
|
91
|
+
tracks = StopAnalyzer.add_field_names(tracks)
|
|
92
|
+
results = self.scan_stop(tracks)
|
|
93
|
+
results = self.scan_zones(results)
|
|
94
|
+
results = self.scan_leading_at_first_stop(results)
|
|
95
|
+
results = self.scan_first_stop_event(results)
|
|
96
|
+
events = self.count_event(results)
|
|
97
|
+
|
|
98
|
+
return results, events
|
|
99
|
+
|
|
100
|
+
def scan_stop(self, tracks:pd.DataFrame, video_index:int=None, video_tot:int=None)->pd.DataFrame:
|
|
101
|
+
|
|
102
|
+
tracks = StopAnalyzer.add_field_names(tracks)
|
|
103
|
+
ids = tracks['track'].unique()
|
|
104
|
+
tracks['x2'] = tracks.apply(lambda t: t['x'] + t['w'], axis=1)
|
|
105
|
+
tracks['y2'] = tracks.apply(lambda t: t['y'] + t['h'], axis=1)
|
|
106
|
+
tracks = tracks.sort_values(by='frame') # sort by frame in ascending
|
|
107
|
+
|
|
108
|
+
pbar = tqdm(total=len(ids), unit=' tracks')
|
|
109
|
+
if video_index and video_tot:
|
|
110
|
+
pbar.set_description_str("Scanning stops {} of {}".format(video_index, video_tot))
|
|
111
|
+
else:
|
|
112
|
+
pbar.set_description_str("Scanning stops")
|
|
113
|
+
|
|
114
|
+
for id in ids:
|
|
115
|
+
track = tracks[tracks['track'] == id]
|
|
116
|
+
|
|
117
|
+
# exclude the tracks length < frame_buffer
|
|
118
|
+
if [len(track)>=self.frame_buffer]:
|
|
119
|
+
bb = track[['x', 'y', 'x2', 'y2']].to_numpy(dtype=np.int32)
|
|
120
|
+
|
|
121
|
+
if self.iou_mode == 'edge':
|
|
122
|
+
bb_buf = np.vstack((np.array([-2 , -2, -1, -1]*self.frame_buffer).reshape(self.frame_buffer, 4), bb)) # add buff frame
|
|
123
|
+
#iou_scores = StopAnalyzer.ious(bb, bb_buf)
|
|
124
|
+
iou_scores = ious(bb, bb_buf)
|
|
125
|
+
tracks.loc[tracks['track']==id, 'iou'] = np.diagonal(iou_scores)
|
|
126
|
+
|
|
127
|
+
elif self.iou_mode == 'max':
|
|
128
|
+
bb_buf = np.vstack((np.array([-2 , -2, -1, -1]*self.frame_buffer).reshape(self.frame_buffer, 4), bb)) # add buff frame
|
|
129
|
+
#iou_scores = StopAnalyzer.ious(bb, bb_buf)
|
|
130
|
+
iou_scores = ious(bb, bb_buf)
|
|
131
|
+
nrows, ncols =np.shape(bb)
|
|
132
|
+
iou_arr = np.empty([nrows, self.frame_buffer])
|
|
133
|
+
for i in range(nrows):
|
|
134
|
+
iou_arr[i, :] = iou_scores[i, i:i+self.frame_buffer]
|
|
135
|
+
tracks.loc[tracks['track']==id, 'iou'] = np.amax(iou_arr, axis=1)
|
|
136
|
+
|
|
137
|
+
elif self.iou_mode == 'mean':
|
|
138
|
+
#iou_scores = StopAnalyzer.ious(bb, bb)
|
|
139
|
+
iou_scores = ious(bb, bb)
|
|
140
|
+
nrows, ncols =np.shape(bb)
|
|
141
|
+
iou_arr = np.zeros([nrows])
|
|
142
|
+
for i in range(1, nrows):
|
|
143
|
+
beg = max(i-self.frame_buffer, 0)
|
|
144
|
+
end = max(i-1, 0) + 1
|
|
145
|
+
iou_arr[i] = np.mean(iou_scores[i, beg:end])
|
|
146
|
+
|
|
147
|
+
tracks.loc[tracks['track']==id, 'iou'] = iou_arr
|
|
148
|
+
|
|
149
|
+
if self.verbose:
|
|
150
|
+
pbar.update()
|
|
151
|
+
|
|
152
|
+
pbar.close()
|
|
153
|
+
|
|
154
|
+
if video_index and video_tot:
|
|
155
|
+
tqdm.pandas(desc='Updating stops {} of {}'.format(video_index, video_tot), unit='frames')
|
|
156
|
+
else:
|
|
157
|
+
tqdm.pandas(desc='Updating stops '.format(video_index, video_tot), unit='frames')
|
|
158
|
+
tracks['stop'] = tracks['iou'].progress_apply(lambda iou: 1 if iou>=self.stop_iou else -1)
|
|
159
|
+
tracks = tracks.drop(columns=['x2', 'y2'])
|
|
160
|
+
|
|
161
|
+
return tracks
|
|
162
|
+
|
|
163
|
+
def scan_zones(self, tracks:pd.DataFrame, video_index:int=None, video_tot:int=None):
|
|
164
|
+
|
|
165
|
+
tracks = StopAnalyzer.add_field_names(tracks)
|
|
166
|
+
tracks['hzone'] = -1
|
|
167
|
+
|
|
168
|
+
if self.hzones:
|
|
169
|
+
|
|
170
|
+
if video_index and video_tot:
|
|
171
|
+
tqdm.pandas(desc='Generating bbox {} of {}'.format(video_index, video_tot), unit='frames')
|
|
172
|
+
else:
|
|
173
|
+
tqdm.pandas(desc='Generating bbox '.format(video_index, video_tot), unit='frames')
|
|
174
|
+
g = tracks.progress_apply(lambda track: box(track['x'] + self.hzone_offset[0],
|
|
175
|
+
track['y'] + self.hzone_offset[1],
|
|
176
|
+
track['x'] + self.hzone_offset[2] + track['w'],
|
|
177
|
+
track['y'] + self.hzone_offset[3] + track['h']),
|
|
178
|
+
axis=1)
|
|
179
|
+
geo_tracks = gpd.GeoDataFrame(tracks, geometry=g)
|
|
180
|
+
|
|
181
|
+
pbar = tqdm(total=len(self.hzones), unit= 'zone')
|
|
182
|
+
if video_index and video_tot:
|
|
183
|
+
pbar.set_description_str("Scanning stop-zones {} of {}".format(video_index, video_tot))
|
|
184
|
+
else:
|
|
185
|
+
pbar.set_description_str("Scanning stop-zones")
|
|
186
|
+
|
|
187
|
+
zones = range(len(self.hzones))
|
|
188
|
+
|
|
189
|
+
for i in zones:
|
|
190
|
+
if self.stop_zone_mode == 'intersect':
|
|
191
|
+
geo_tracks.loc[((geo_tracks.geometry.intersects(self.hzones[i])) & (geo_tracks['hzone']<i)), 'hzone'] = i
|
|
192
|
+
else:
|
|
193
|
+
geo_tracks['iob'] = geo_tracks.geometry.apply(lambda bbox:
|
|
194
|
+
(bbox.intersection(self.hzones[i]).area)/(bbox.area) if bbox.area>0 else -1)
|
|
195
|
+
geo_tracks.loc[((geo_tracks['iob']>=self.stop_iob) & (geo_tracks['hzone']<i)), 'hzone'] = i
|
|
196
|
+
|
|
197
|
+
pbar.update()
|
|
198
|
+
|
|
199
|
+
pbar.close()
|
|
200
|
+
|
|
201
|
+
geo_tracks=geo_tracks[geo_tracks['hzone']>-1]
|
|
202
|
+
tracks = pd.DataFrame(geo_tracks.drop(columns='geometry'))
|
|
203
|
+
|
|
204
|
+
if self.vzones:
|
|
205
|
+
if video_index and video_tot:
|
|
206
|
+
tqdm.pandas(desc='Generating reference point {} of {}'.format(video_index, video_tot), unit='frames')
|
|
207
|
+
else:
|
|
208
|
+
tqdm.pandas(desc='Generating reference point '.format(video_index, video_tot), unit='frames')
|
|
209
|
+
if self.ref_point == 'cc':
|
|
210
|
+
g = tracks.progress_apply(lambda track: Point([track['x'] + track['w']/2 + self.vzone_offset[0],
|
|
211
|
+
track['y'] + track['h']/2 + self.vzone_offset[1]]), axis=1)
|
|
212
|
+
elif self.ref_point == 'tc':
|
|
213
|
+
g = tracks.progress_apply(lambda track: Point([track['x'] + track['w']/2 + self.vzone_offset[0],
|
|
214
|
+
track['y'] + self.vzone_offset[1]]), axis=1)
|
|
215
|
+
elif self.ref_point == 'bc':
|
|
216
|
+
g = tracks.progress_apply(lambda track: Point([[track['x'] + track['w']/2 + self.vzone_offset[0],
|
|
217
|
+
track['y'] + track['h'] + self.vzone_offset[1]]]), axis=1)
|
|
218
|
+
elif self.ref_point == 'cl':
|
|
219
|
+
g = tracks.progress_apply(lambda track: Point([[track['x'] + self.vzone_offset[0],
|
|
220
|
+
track['y'] + track['h']/2 + self.vzone_offset[1]]]), axis=1)
|
|
221
|
+
elif self.ref_point == 'cr':
|
|
222
|
+
g = tracks.progress_apply(lambda track: Point([track['x'] + track['w'] + self.vzone_offset[0],
|
|
223
|
+
track['y'] + track['h']/2 + self.vzone_offset[1]]), axis=1)
|
|
224
|
+
elif self.ref_point == 'tl':
|
|
225
|
+
g = tracks.progress_apply(lambda track: Point([track['x'] + self.vzone_offset[0],
|
|
226
|
+
track['y'] + self.vzone_offset[1]]), axis=1)
|
|
227
|
+
elif self.ref_point == 'tr':
|
|
228
|
+
g = tracks.progress_apply(lambda track: Point([track['x'] + track['w'] + self.vzone_offset[0],
|
|
229
|
+
track['y'] + self.vzone_offset[1]]), axis=1)
|
|
230
|
+
elif self.ref_point == 'bl':
|
|
231
|
+
g = tracks.progress_apply(lambda track: Point([track['x'] + self.vzone_offset[0],
|
|
232
|
+
track['y'] + tracks['h'] + self.vzone_offset[1]]), axis=1)
|
|
233
|
+
elif self.ref_point == 'br':
|
|
234
|
+
g = tracks.progress_apply(lambda track: Point([track['x'] + track['w'] + self.vzone_offset[0],
|
|
235
|
+
track['y'] + track['h'] + self.vzone_offset[1]]), axis=1)
|
|
236
|
+
else:
|
|
237
|
+
g = tracks.progress_apply(lambda track: Point([track['x'] + track['w']/2 + self.vzone_offset[0],
|
|
238
|
+
track['y'] + track['h'] + self.vzone_offset[1]]), axis=1)
|
|
239
|
+
|
|
240
|
+
geo_tracks = gpd.GeoDataFrame(tracks, geometry=g)
|
|
241
|
+
|
|
242
|
+
pbar = tqdm(total=len(self.vzones), unit=' zone')
|
|
243
|
+
if video_index and video_tot:
|
|
244
|
+
pbar.set_description_str("Scanning lane-zones {} of {}".format(video_index, video_tot))
|
|
245
|
+
else:
|
|
246
|
+
pbar.set_description_str("Scanning lane-zones ")
|
|
247
|
+
for i in range(len(self.vzones)):
|
|
248
|
+
geo_tracks.loc[(geo_tracks.geometry.within(self.vzones[i])), 'vzone'] = i
|
|
249
|
+
pbar.update()
|
|
250
|
+
pbar.close()
|
|
251
|
+
|
|
252
|
+
if self.vzone_adjust:
|
|
253
|
+
ids = geo_tracks['track'].unique()
|
|
254
|
+
pbar = tqdm(total=len(ids), unit=' tracks')
|
|
255
|
+
if video_index and video_tot:
|
|
256
|
+
pbar.set_description_str("Adjusting lane-zones {} of {}".format(video_index, video_tot))
|
|
257
|
+
else:
|
|
258
|
+
pbar.set_description_str("Adjusting lane-zones ")
|
|
259
|
+
for id in ids:
|
|
260
|
+
located_frames = geo_tracks[(geo_tracks['track']==id) & (geo_tracks['vzone']>-1)]
|
|
261
|
+
if len(located_frames)>0:
|
|
262
|
+
geo_tracks.loc[geo_tracks['track']==id, 'vzone'] = located_frames['vzone'].mode()[0]
|
|
263
|
+
|
|
264
|
+
pbar.update()
|
|
265
|
+
pbar.close()
|
|
266
|
+
|
|
267
|
+
tracks = pd.DataFrame(geo_tracks.drop(columns='geometry'))
|
|
268
|
+
|
|
269
|
+
return tracks
|
|
270
|
+
|
|
271
|
+
def scan_zones_v2(self, tracks:pd.DataFrame, video_index:int=None, video_tot:int=None):
|
|
272
|
+
|
|
273
|
+
tracks = StopAnalyzer.add_field_names(tracks)
|
|
274
|
+
|
|
275
|
+
if self.hzones:
|
|
276
|
+
|
|
277
|
+
if video_index and video_tot:
|
|
278
|
+
tqdm.pandas(desc='Generating bbox {} of {}'.format(video_index, video_tot), unit='frames')
|
|
279
|
+
else:
|
|
280
|
+
tqdm.pandas(desc='Generating bbox '.format(video_index, video_tot), unit='frames')
|
|
281
|
+
g = tracks.progress_apply(lambda track: box(track['x'] + self.hzone_offset[0] + track['w']*(1-self.hzone_factor)/2,
|
|
282
|
+
track['y'] + self.hzone_offset[1] + track['h']*(1-self.hzone_factor)/2,
|
|
283
|
+
track['x'] + self.hzone_offset[2] + track['w'] - track['w']*(1-self.hzone_factor)/2,
|
|
284
|
+
track['y'] + self.hzone_offset[3] + track['h'] - track['h']*(1-self.hzone_factor)/2),
|
|
285
|
+
axis=1)
|
|
286
|
+
geo_tracks = gpd.GeoDataFrame(tracks, geometry=g)
|
|
287
|
+
|
|
288
|
+
pbar = tqdm(total=len(self.hzones), unit= 'zone')
|
|
289
|
+
if video_index and video_tot:
|
|
290
|
+
pbar.set_description_str("Scanning stop-zones {} of {}".format(video_index, video_tot))
|
|
291
|
+
else:
|
|
292
|
+
pbar.set_description_str("Scanning stop-zones")
|
|
293
|
+
|
|
294
|
+
zones = range(len(self.hzones))
|
|
295
|
+
|
|
296
|
+
for i in zones:
|
|
297
|
+
# geo_tracks.loc[((geo_tracks.geometry.intersects(self.hzones[i])) & (geo_tracks['hzone']<i)), 'hzone'] = i
|
|
298
|
+
geo_tracks['iob'] = geo_tracks.geometry.apply(lambda bbox: (bbox.intersection(self.hzones[i]).area)/(bbox.area) if bbox.area>0 else -1)
|
|
299
|
+
geo_tracks.loc[((geo_tracks['iob']>=self.stop_iob) & (geo_tracks['hzone']<i)), 'hzone'] = i
|
|
300
|
+
pbar.update()
|
|
301
|
+
|
|
302
|
+
pbar.close()
|
|
303
|
+
|
|
304
|
+
geo_tracks=geo_tracks[geo_tracks['hzone']>-1]
|
|
305
|
+
tracks = pd.DataFrame(geo_tracks.drop(columns='geometry'))
|
|
306
|
+
|
|
307
|
+
if self.vzones:
|
|
308
|
+
if video_index and video_tot:
|
|
309
|
+
tqdm.pandas(desc='Generating reference point {} of {}'.format(video_index, video_tot), unit='frames')
|
|
310
|
+
else:
|
|
311
|
+
tqdm.pandas(desc='Generating reference point '.format(video_index, video_tot), unit='frames')
|
|
312
|
+
if self.ref_point == 'cc':
|
|
313
|
+
g = tracks.progress_apply(lambda track: Point([track['x'] + track['w']/2 + self.vzone_offset[0],
|
|
314
|
+
track['y'] + track['h']/2 + self.vzone_offset[1]]), axis=1)
|
|
315
|
+
elif self.ref_point == 'tc':
|
|
316
|
+
g = tracks.progress_apply(lambda track: Point([track['x'] + track['w']/2 + self.vzone_offset[0],
|
|
317
|
+
track['y'] + self.vzone_offset[1]]), axis=1)
|
|
318
|
+
elif self.ref_point == 'bc':
|
|
319
|
+
g = tracks.progress_apply(lambda track: Point([[track['x'] + track['w']/2 + self.vzone_offset[0],
|
|
320
|
+
track['y'] + track['h'] + self.vzone_offset[1]]]), axis=1)
|
|
321
|
+
elif self.ref_point == 'cl':
|
|
322
|
+
g = tracks.progress_apply(lambda track: Point([[track['x'] + self.vzone_offset[0],
|
|
323
|
+
track['y'] + track['h']/2 + self.vzone_offset[1]]]), axis=1)
|
|
324
|
+
elif self.ref_point == 'cr':
|
|
325
|
+
g = tracks.progress_apply(lambda track: Point([track['x'] + track['w'] + self.vzone_offset[0],
|
|
326
|
+
track['y'] + track['h']/2 + self.vzone_offset[1]]), axis=1)
|
|
327
|
+
elif self.ref_point == 'tl':
|
|
328
|
+
g = tracks.progress_apply(lambda track: Point([track['x'] + self.vzone_offset[0],
|
|
329
|
+
track['y'] + self.vzone_offset[1]]), axis=1)
|
|
330
|
+
elif self.ref_point == 'tr':
|
|
331
|
+
g = tracks.progress_apply(lambda track: Point([track['x'] + track['w'] + self.vzone_offset[0],
|
|
332
|
+
track['y'] + self.vzone_offset[1]]), axis=1)
|
|
333
|
+
elif self.ref_point == 'bl':
|
|
334
|
+
g = tracks.progress_apply(lambda track: Point([track['x'] + self.vzone_offset[0],
|
|
335
|
+
track['y'] + tracks['h'] + self.vzone_offset[1]]), axis=1)
|
|
336
|
+
elif self.ref_point == 'br':
|
|
337
|
+
g = tracks.progress_apply(lambda track: Point([track['x'] + track['w'] + self.vzone_offset[0],
|
|
338
|
+
track['y'] + track['h'] + self.vzone_offset[1]]), axis=1)
|
|
339
|
+
else:
|
|
340
|
+
g = tracks.progress_apply(lambda track: Point([track['x'] + track['w']/2 + self.vzone_offset[0],
|
|
341
|
+
track['y'] + track['h'] + self.vzone_offset[1]]), axis=1)
|
|
342
|
+
|
|
343
|
+
geo_tracks = gpd.GeoDataFrame(tracks, geometry=g)
|
|
344
|
+
|
|
345
|
+
pbar = tqdm(total=len(self.vzones), unit=' zone')
|
|
346
|
+
if video_index and video_tot:
|
|
347
|
+
pbar.set_description_str("Scanning lane-zones {} of {}".format(video_index, video_tot))
|
|
348
|
+
else:
|
|
349
|
+
pbar.set_description_str("Scanning lane-zones ")
|
|
350
|
+
for i in range(len(self.vzones)):
|
|
351
|
+
geo_tracks.loc[(geo_tracks.geometry.within(self.vzones[i])), 'vzone'] = i
|
|
352
|
+
pbar.update()
|
|
353
|
+
pbar.close()
|
|
354
|
+
|
|
355
|
+
if self.vzone_adjust:
|
|
356
|
+
ids = geo_tracks['track'].unique()
|
|
357
|
+
pbar = tqdm(total=len(ids), unit=' tracks')
|
|
358
|
+
if video_index and video_tot:
|
|
359
|
+
pbar.set_description_str("Adjusting lane-zones {} of {}".format(video_index, video_tot))
|
|
360
|
+
else:
|
|
361
|
+
pbar.set_description_str("Adjusting lane-zones ")
|
|
362
|
+
for id in ids:
|
|
363
|
+
located_frames = geo_tracks[(geo_tracks['track']==id) & (geo_tracks['vzone']>-1)]
|
|
364
|
+
if len(located_frames)>0:
|
|
365
|
+
geo_tracks.loc[geo_tracks['track']==id, 'vzone'] = located_frames['vzone'].mode()[0]
|
|
366
|
+
|
|
367
|
+
pbar.update()
|
|
368
|
+
pbar.close()
|
|
369
|
+
|
|
370
|
+
tracks = pd.DataFrame(geo_tracks.drop(columns='geometry'))
|
|
371
|
+
|
|
372
|
+
return tracks
|
|
373
|
+
|
|
374
|
+
def scan_leading_at_first_stop(self, tracks:pd.DataFrame, video_index:int=None, video_tot:int=None) -> pd.DataFrame:
|
|
375
|
+
|
|
376
|
+
tracks = StopAnalyzer.add_field_names(tracks)
|
|
377
|
+
tracks['xc'] = tracks.apply(lambda track: track['x'] + track['w']/2, axis=1)
|
|
378
|
+
tracks['yc'] = tracks.apply(lambda track: track['y'] + track['h']/2, axis=1)
|
|
379
|
+
|
|
380
|
+
stop_tracks = tracks[tracks['stop']==1]
|
|
381
|
+
stop_ids = stop_tracks['track'].unique()
|
|
382
|
+
|
|
383
|
+
pbar = tqdm(total=len(stop_ids), unit=' tracks')
|
|
384
|
+
if video_index and video_tot:
|
|
385
|
+
pbar.set_description_str("Scanning leading vehicles {} of {}".format(video_index, video_tot))
|
|
386
|
+
else:
|
|
387
|
+
pbar.set_description_str("Scanning leading vehicles")
|
|
388
|
+
for stop_id in stop_ids:
|
|
389
|
+
track = stop_tracks[stop_tracks['track']==stop_id].sort_values(by='frame').iloc[0]
|
|
390
|
+
vzone = track['vzone']
|
|
391
|
+
hzone = track['hzone']
|
|
392
|
+
min_frame = track['frame'] - self.leading_buffer
|
|
393
|
+
max_frame = track['frame'] + self.leading_buffer
|
|
394
|
+
xc = track['xc']
|
|
395
|
+
yc = track['yc']
|
|
396
|
+
|
|
397
|
+
if (self.leading_axis=='x') and (self.leading_direct=='+'):
|
|
398
|
+
veh_front = tracks[(tracks['frame']>=min_frame) & (tracks['frame']<=max_frame) & (tracks['track']!=stop_id)
|
|
399
|
+
& (tracks['vzone']==vzone) & (tracks['xc']>=xc) & (tracks['stop']==1)]
|
|
400
|
+
elif (self.leading_axis=='x') and (self.leading_direct=='-'):
|
|
401
|
+
veh_front = tracks[(tracks['frame']>=min_frame) & (tracks['frame']<=max_frame) & (tracks['track']!=stop_id)
|
|
402
|
+
& (tracks['vzone']==vzone) & (tracks['xc']<=xc) & (tracks['stop']==1)]
|
|
403
|
+
elif (self.leading_axis=='y') and (self.leading_direct=='+'):
|
|
404
|
+
veh_front = tracks[(tracks['frame']>=min_frame) & (tracks['frame']<=max_frame) & (tracks['track']!=stop_id)
|
|
405
|
+
& (tracks['vzone']==vzone) & (tracks['yc']>=yc) & (tracks['stop']==1)]
|
|
406
|
+
elif (self.leading_axis=='y') and (self.leading_direct=='-'):
|
|
407
|
+
veh_front = tracks[(tracks['frame']>=min_frame) & (tracks['frame']<=max_frame) & (tracks['track']!=stop_id)
|
|
408
|
+
& (tracks['vzone']==vzone) & (tracks['yc']<=yc) & (tracks['stop']==1)]
|
|
409
|
+
elif (self.leading_axis=='xy') and (self.leading_direct=='+'):
|
|
410
|
+
veh_front = tracks[(tracks['frame']>=min_frame) & (tracks['frame']<=max_frame) & (tracks['track']!=stop_id)
|
|
411
|
+
& (tracks['vzone']==vzone) & (tracks['xc']>=xc) & (tracks['yc']>=yc) & (tracks['stop']==1)]
|
|
412
|
+
elif (self.leading_axis=='xy') and (self.leading_direct=='-'):
|
|
413
|
+
veh_front = tracks[(tracks['frame']>=min_frame) & (tracks['frame']<=max_frame) & (tracks['track']!=stop_id)
|
|
414
|
+
& (tracks['vzone']==vzone) & (tracks['xc']<=xc) & (tracks['yc']<=yc) & (tracks['stop']==1)]
|
|
415
|
+
else:
|
|
416
|
+
print('Leading setting is invalid and may cause incorrect results!')
|
|
417
|
+
veh_front = []
|
|
418
|
+
|
|
419
|
+
if len(veh_front) == 0:
|
|
420
|
+
tracks.loc[(tracks['track']==stop_id), 'leading'] = 1
|
|
421
|
+
else:
|
|
422
|
+
tracks.loc[(tracks['track']==stop_id), 'leading'] = -1
|
|
423
|
+
|
|
424
|
+
pbar.update()
|
|
425
|
+
pbar.close()
|
|
426
|
+
|
|
427
|
+
tracks = tracks.drop(columns=['xc', 'yc'])
|
|
428
|
+
return tracks
|
|
429
|
+
|
|
430
|
+
def scan_first_stop_event(self, tracks:pd.DataFrame, video_index:int=None, video_tot:int=None):
|
|
431
|
+
|
|
432
|
+
tracks = StopAnalyzer.add_field_names(tracks)
|
|
433
|
+
|
|
434
|
+
if self.vzones:
|
|
435
|
+
leading_tracks = tracks[(tracks['leading']==1) & (tracks['hzone']>-1) & (tracks['vzone']>-1) & (tracks['stop']==1)]
|
|
436
|
+
else:
|
|
437
|
+
leading_tracks = tracks[(tracks['leading']==1) & (tracks['hzone']>-1) & (tracks['stop']==1)]
|
|
438
|
+
leading_ids = leading_tracks['track'].unique()
|
|
439
|
+
pbar = tqdm(total=len(leading_ids), unit=' tracks')
|
|
440
|
+
|
|
441
|
+
if video_index and video_tot:
|
|
442
|
+
pbar.set_description_str("Scanning first stop events {} of {}".format(video_index, video_tot))
|
|
443
|
+
else:
|
|
444
|
+
pbar.set_description_str("Scanning first stop events")
|
|
445
|
+
|
|
446
|
+
for leading_id in leading_ids:
|
|
447
|
+
frame = leading_tracks[leading_tracks['track']==leading_id].sort_values(by='frame').iloc[0]
|
|
448
|
+
hzone = int(frame['hzone'])
|
|
449
|
+
event_code = next(item for item in self.event_dicts if item["zone"] == hzone)['code']
|
|
450
|
+
tracks.loc[tracks['track']==leading_id, 'event'] = event_code
|
|
451
|
+
|
|
452
|
+
pbar.update()
|
|
453
|
+
|
|
454
|
+
pbar.close()
|
|
455
|
+
|
|
456
|
+
return tracks
|
|
457
|
+
|
|
458
|
+
def count_event(self, tracks:pd.DataFrame, video_index:int=None, video_tot:int=None)->pd.DataFrame:
|
|
459
|
+
|
|
460
|
+
tracks = StopAnalyzer.add_field_names(tracks)
|
|
461
|
+
|
|
462
|
+
pbar = tqdm(unit='events')
|
|
463
|
+
results = []
|
|
464
|
+
for event in self.event_dicts:
|
|
465
|
+
|
|
466
|
+
vehicles = tracks[tracks['event']==event['code']]['track'].unique()
|
|
467
|
+
if len(vehicles)>0:
|
|
468
|
+
if video_index and video_tot:
|
|
469
|
+
pbar.set_description_str("Counting event {} for {} of {}".format(event['desc'], video_index, video_tot))
|
|
470
|
+
else:
|
|
471
|
+
pbar.set_description_str("Counting event {}".format(event['desc']))
|
|
472
|
+
|
|
473
|
+
pbar.total = len(vehicles)
|
|
474
|
+
for vehicle in vehicles:
|
|
475
|
+
track = tracks[(tracks['track'] == vehicle)]
|
|
476
|
+
start_frame = int(track['frame'].min())
|
|
477
|
+
end_frame = int(track['frame'].max())
|
|
478
|
+
vzones = track['vzone'].values.tolist()
|
|
479
|
+
vzones = [z for z in vzones if z>-1]
|
|
480
|
+
if len(vzones)>0 :
|
|
481
|
+
vzone = max(set(vzones), key = vzones.count)
|
|
482
|
+
else:
|
|
483
|
+
vzone = -1
|
|
484
|
+
results.append([event['code'], event['desc'], vehicle, vzone, start_frame, end_frame])
|
|
485
|
+
|
|
486
|
+
if self.verbose:
|
|
487
|
+
pbar.update()
|
|
488
|
+
|
|
489
|
+
results = pd.DataFrame(results, columns=['event', 'desc', 'track', 'vzone', 'start_frame', 'end_frame'])
|
|
490
|
+
pbar.close()
|
|
491
|
+
|
|
492
|
+
return results
|
|
493
|
+
|
|
494
|
+
def generate_labels(self, tracks:pd.DataFrame, events:pd.DataFrame,
|
|
495
|
+
method:str='all', random_number:int=10, event_codes:list=None, track_ids:list=None,
|
|
496
|
+
size:int=1, thick:int=1, show_track:bool=False, show_desc:bool=False, show_code:bool=False,
|
|
497
|
+
video_index:int=None, video_tot:int=None)->pd.DataFrame:
|
|
498
|
+
'''
|
|
499
|
+
Inputs:
|
|
500
|
+
tracks: tracks with stop analysis results
|
|
501
|
+
events: stop events file
|
|
502
|
+
method: 'all' (default), 'random', 'event', 'track'
|
|
503
|
+
random_number: if method=='random', the number of tracks for labelling, default is 10
|
|
504
|
+
event_codes: if method=='event', the list of event codes for labelling, default is None for all event codes
|
|
505
|
+
track_ids: if method=='tracks', the list of track ids for labelling, default is not for all track ids
|
|
506
|
+
Return:
|
|
507
|
+
a dataframe of labelling events: ['frame','type','coords','color','size','thick','desc']
|
|
508
|
+
'''
|
|
509
|
+
|
|
510
|
+
event_tracks = tracks.loc[tracks['event']>-1].copy()
|
|
511
|
+
if method == 'random':
|
|
512
|
+
track_ids = event_tracks['track'].unique().tolist()
|
|
513
|
+
if random_number<=0:
|
|
514
|
+
random_number = 10
|
|
515
|
+
random_ids = random.sample(track_ids, random_number)
|
|
516
|
+
event_tracks = event_tracks[event_tracks['track'].isin(random_ids)].copy()
|
|
517
|
+
elif method == 'event':
|
|
518
|
+
if (event_codes is None) or (len(event_codes)==0):
|
|
519
|
+
print('No event codes are provided!')
|
|
520
|
+
return pd.DataFrame()
|
|
521
|
+
event_tracks = event_tracks[event_tracks['event'].isin(event_codes)].copy()
|
|
522
|
+
elif method == 'track':
|
|
523
|
+
if (track_ids is None) or (len(track_ids)==0):
|
|
524
|
+
print('No tracks are provided!')
|
|
525
|
+
return pd.DataFrame()
|
|
526
|
+
event_tracks = event_tracks[event_tracks['track'].isin(track_ids)].copy()
|
|
527
|
+
|
|
528
|
+
event_tracks['desc'] = ''
|
|
529
|
+
event_tracks['color'] = None
|
|
530
|
+
for index, event in events.iterrows():
|
|
531
|
+
track_id = event['track']
|
|
532
|
+
start_frame = event['start_frame']
|
|
533
|
+
end_frame = event['end_frame']
|
|
534
|
+
event_id = event['event']
|
|
535
|
+
event_desc = event['desc']
|
|
536
|
+
event_dict = next(item for item in self.event_dicts if item["code"] == event_id)
|
|
537
|
+
|
|
538
|
+
event_tracks.loc[((event_tracks['track']==track_id) & (event_tracks['frame']>=start_frame) &
|
|
539
|
+
(event_tracks['frame']<=end_frame)), ['event', 'desc']] = [event_id, event_desc]
|
|
540
|
+
|
|
541
|
+
cmap = plt.get_cmap('tab20b')
|
|
542
|
+
colors = [cmap(i)[:3] for i in np.linspace(0, 1, 20)]
|
|
543
|
+
|
|
544
|
+
pbar = tqdm(total= len(event_tracks))
|
|
545
|
+
if video_index and video_tot:
|
|
546
|
+
pbar.set_description_str("Generating labeles for {} of {}".format(video_index, video_tot))
|
|
547
|
+
else:
|
|
548
|
+
pbar.set_description_str("Generating labels")
|
|
549
|
+
|
|
550
|
+
results = []
|
|
551
|
+
for index, track in event_tracks.iterrows():
|
|
552
|
+
event_dict = next(item for item in self.event_dicts if item["code"] == track['event'])
|
|
553
|
+
if 'color' in event_dict:
|
|
554
|
+
event_color = event_dict['color']
|
|
555
|
+
else:
|
|
556
|
+
color = colors[int(track['event']) % len(colors)]
|
|
557
|
+
event_color = [int(i * 255) for i in color]
|
|
558
|
+
|
|
559
|
+
label_text = ''
|
|
560
|
+
if show_track:
|
|
561
|
+
label_text+='| T:'+str(int(track['track']))
|
|
562
|
+
|
|
563
|
+
if show_code:
|
|
564
|
+
label_text+='| C:'+str(int(track['event']))
|
|
565
|
+
|
|
566
|
+
if show_desc:
|
|
567
|
+
label_text+='| '+str(track['desc'])
|
|
568
|
+
|
|
569
|
+
if label_text:
|
|
570
|
+
results.append([track['frame'], 'bbox', [(track['x'], track['y']), (track['x']+track['w'], track['y']+track['h'])],
|
|
571
|
+
event_color, size, thick, label_text])
|
|
572
|
+
else:
|
|
573
|
+
results.append([track['frame'], 'box', [(track['x'], track['y']), (track['x']+track['w'], track['y']+track['h'])],
|
|
574
|
+
event_color, size, thick, label_text])
|
|
575
|
+
|
|
576
|
+
if self.verbose:
|
|
577
|
+
pbar.update()
|
|
578
|
+
|
|
579
|
+
df = pd.DataFrame(results, columns=['frame','type','coords','color','size','thick','desc'])
|
|
580
|
+
df.sort_values(by='frame')
|
|
581
|
+
|
|
582
|
+
return df
|
|
583
|
+
|
|
584
|
+
@staticmethod
|
|
585
|
+
def generate_label_clips(events:pd.DataFrame, tracks:pd.DataFrame, out_path:str,
|
|
586
|
+
method:str='all', random_number:int=10, event_codes:list=None, track_ids:list=None,
|
|
587
|
+
event_dicts:list=None, input_video:str=None, size:int=1, thick:int=2, padding:int=0,
|
|
588
|
+
show_track:bool=False, show_code:bool=False, show_desc:bool=False, verbose:bool=True,
|
|
589
|
+
video_index:int=None, video_tot:int=None)->list:
|
|
590
|
+
'''
|
|
591
|
+
Parameters:
|
|
592
|
+
- events: the dataframe of stop events
|
|
593
|
+
- tracks: the dataframe of tracks
|
|
594
|
+
- out_path: the folder for outputing track clips
|
|
595
|
+
- method: 'all' (default) - all tracks, 'random' - random select tracks, 'specify' - specify track ids, 'event' - by event type
|
|
596
|
+
- random_number: the number of track ids if method == 'random'
|
|
597
|
+
- event_codes: the list event code if method == 'event'
|
|
598
|
+
- track_ids: the list of track ids if method == 'specify'
|
|
599
|
+
- event_dicts: the list of event dictionaries
|
|
600
|
+
- input_video: the raw video file, if None, generate the label files only
|
|
601
|
+
- size: font size, default is 1
|
|
602
|
+
- thick: line thinckness, defualt is 2
|
|
603
|
+
- padding: add addtional frames at beggining and ending, default is 0
|
|
604
|
+
- show_track: show track id, default is False
|
|
605
|
+
- show_code: show event code, default is False
|
|
606
|
+
- show_desc: show event desc, default is Falase
|
|
607
|
+
- verbose: if show progressing bar, default is True
|
|
608
|
+
- video_idex: the index of the video in processing
|
|
609
|
+
- video_tot: the total number of videos
|
|
610
|
+
|
|
611
|
+
Return:
|
|
612
|
+
- A list of dataframes for labels, ['frame','type','coords','color','size','thick','desc']
|
|
613
|
+
'''
|
|
614
|
+
|
|
615
|
+
event_tracks = tracks.loc[tracks['event']>-1].copy()
|
|
616
|
+
if method == 'random':
|
|
617
|
+
track_ids = event_tracks['track'].unique().tolist()
|
|
618
|
+
if random_number<=0:
|
|
619
|
+
random_number = 10
|
|
620
|
+
random_ids = random.sample(track_ids, random_number)
|
|
621
|
+
event_tracks = event_tracks[event_tracks['track'].isin(random_ids)].copy()
|
|
622
|
+
elif method == 'event':
|
|
623
|
+
if (event_codes is None) or (len(event_codes)==0):
|
|
624
|
+
print('No event codes are provided!')
|
|
625
|
+
return pd.DataFrame()
|
|
626
|
+
event_tracks = event_tracks[event_tracks['event'].isin(event_codes)].copy()
|
|
627
|
+
elif method == 'track':
|
|
628
|
+
if (track_ids is None) or (len(track_ids)==0):
|
|
629
|
+
print('No tracks are provided!')
|
|
630
|
+
return pd.DataFrame()
|
|
631
|
+
event_tracks = event_tracks[event_tracks['track'].isin(track_ids)].copy()
|
|
632
|
+
|
|
633
|
+
event_tracks['desc'] = ''
|
|
634
|
+
event_tracks['color'] = None
|
|
635
|
+
for index, event in events.iterrows():
|
|
636
|
+
track_id = event['track']
|
|
637
|
+
start_frame = event['start_frame']
|
|
638
|
+
end_frame = event['end_frame']
|
|
639
|
+
event_id = event['event']
|
|
640
|
+
event_desc = event['desc']
|
|
641
|
+
event_dict = next(item for item in event_dicts if item["code"] == event_id)
|
|
642
|
+
event_tracks.loc[((event_tracks['track']==track_id) & (event_tracks['frame']>=start_frame) &
|
|
643
|
+
(event_tracks['frame']<=end_frame)), ['event', 'desc']] = [event_id, event_desc]
|
|
644
|
+
|
|
645
|
+
ids = event_tracks['track'].unique().tolist()
|
|
646
|
+
cmap = plt.get_cmap('tab20b')
|
|
647
|
+
colors = [cmap(i)[:3] for i in np.linspace(0, 1, 20)]
|
|
648
|
+
|
|
649
|
+
pbar = tqdm(total= len(ids) , unit='tracks')
|
|
650
|
+
if video_index and video_tot:
|
|
651
|
+
pbar.set_description_str("Generating labeles for {} of {}".format(video_index, video_tot))
|
|
652
|
+
else:
|
|
653
|
+
pbar.set_description_str("Generating labels")
|
|
654
|
+
|
|
655
|
+
labeler = Labeler()
|
|
656
|
+
|
|
657
|
+
results = []
|
|
658
|
+
for id in ids:
|
|
659
|
+
result = []
|
|
660
|
+
selected_tracks = event_tracks[event_tracks['track']==id]
|
|
661
|
+
for index, track in selected_tracks.iterrows():
|
|
662
|
+
event_dict = next(item for item in event_dicts if item["code"] == track['event'])
|
|
663
|
+
if 'color' in event_dict:
|
|
664
|
+
event_color = event_dict['color']
|
|
665
|
+
else:
|
|
666
|
+
color = colors[int(track['event']) % len(colors)]
|
|
667
|
+
event_color = [int(i * 255) for i in color]
|
|
668
|
+
|
|
669
|
+
label_text = ''
|
|
670
|
+
if show_track:
|
|
671
|
+
label_text+='| T:'+str(int(track['track']))
|
|
672
|
+
|
|
673
|
+
if show_code:
|
|
674
|
+
label_text+='| C:'+str(int(track['event']))
|
|
675
|
+
|
|
676
|
+
if show_desc:
|
|
677
|
+
label_text+='| '+str(track['desc'])
|
|
678
|
+
|
|
679
|
+
result.append([track['frame'], 'bbox', [(track['x'], track['y']), (track['x']+track['w'], track['y']+track['h'])],
|
|
680
|
+
event_color, size, thick, label_text])
|
|
681
|
+
|
|
682
|
+
df = pd.DataFrame(result, columns=['frame','type','coords','color','size','thick','desc'])
|
|
683
|
+
|
|
684
|
+
if out_path:
|
|
685
|
+
file_name = os.path.join(out_path, str(id)+'_label.csv')
|
|
686
|
+
df.to_csv(file_name, index=False)
|
|
687
|
+
|
|
688
|
+
if input_video:
|
|
689
|
+
|
|
690
|
+
file_name = os.path.join(out_path, str(id)+'_label.mp4')
|
|
691
|
+
min_frame = df['frame'].min() - padding
|
|
692
|
+
max_frame = df['frame'].max() + padding
|
|
693
|
+
labeler.draw(input_video=input_video, output_video=file_name, draws=df,
|
|
694
|
+
start_frame=min_frame, end_frame=max_frame, verbose=False)
|
|
695
|
+
|
|
696
|
+
results.append(df)
|
|
697
|
+
|
|
698
|
+
if verbose:
|
|
699
|
+
pbar.update()
|
|
700
|
+
|
|
701
|
+
return results
|
|
702
|
+
|
|
703
|
+
@staticmethod
|
|
704
|
+
def add_field_names(tracks: pd.DataFrame)->pd.DataFrame:
|
|
705
|
+
if len(tracks.columns)==10:
|
|
706
|
+
tracks.columns = ['frame', 'track', 'x', 'y', 'w', 'h', 'score', 'cls', 'r3','r4']
|
|
707
|
+
tracks['iou'] = -1.0
|
|
708
|
+
tracks['stop'] = -1
|
|
709
|
+
tracks['vzone'] = -1
|
|
710
|
+
tracks['iob'] = -1.0
|
|
711
|
+
tracks['hzone'] = -1
|
|
712
|
+
tracks['leading'] = -1
|
|
713
|
+
tracks['event'] = -1
|
|
714
|
+
elif len(tracks.columns) == 17:
|
|
715
|
+
tracks.columns = ['frame', 'track', 'x', 'y', 'w', 'h', 'score', 'cls', 'r3','r4',
|
|
716
|
+
'iou', 'stop', 'vzone', 'iob', 'hzone', 'leading', 'event']
|
|
717
|
+
else:
|
|
718
|
+
raise Exception('The number of fields is invalid.')
|
|
719
|
+
|
|
720
|
+
return tracks
|
|
721
|
+
|
|
722
|
+
'''copy from bot sort'''
|
|
723
|
+
@staticmethod
|
|
724
|
+
def ious(atlbrs, btlbrs):
|
|
725
|
+
"""
|
|
726
|
+
Compute cost based on IoU
|
|
727
|
+
:type atlbrs: list[tlbr] | np.ndarray
|
|
728
|
+
:type atlbrs: list[tlbr] | np.ndarray
|
|
729
|
+
|
|
730
|
+
:rtype ious np.ndarray
|
|
731
|
+
"""
|
|
732
|
+
ious = np.zeros((len(atlbrs), len(btlbrs)), dtype=np.float64)
|
|
733
|
+
if ious.size == 0:
|
|
734
|
+
return ious
|
|
735
|
+
|
|
736
|
+
ious = bbox_overlaps(
|
|
737
|
+
np.ascontiguousarray(atlbrs, dtype=np.float64),
|
|
738
|
+
np.ascontiguousarray(btlbrs, dtype=np.float64)
|
|
739
|
+
)
|
|
740
|
+
|
|
741
|
+
return ious
|
|
742
|
+
|
|
743
|
+
@staticmethod
|
|
744
|
+
def gen_zones(coords:list)->list[Polygon]:
|
|
745
|
+
"""
|
|
746
|
+
Generate a list of shapely polygons
|
|
747
|
+
Inputs:
|
|
748
|
+
line_coords: a list of line coords ([[(x11, y11),(x12, y12)], [(x21, y21),(x22, y22)], ...])
|
|
749
|
+
Returns:
|
|
750
|
+
A list of PloyGons
|
|
751
|
+
"""
|
|
752
|
+
|
|
753
|
+
zones = []
|
|
754
|
+
for coord in coords:
|
|
755
|
+
zones.append(Polygon(coord))
|
|
756
|
+
|
|
757
|
+
return zones
|
|
758
|
+
|