Art installation with TRAjectory Prediction
Find a file
2024-11-08 14:59:21 +01:00
trap Track directly from rtsp 2024-11-08 14:59:21 +01:00
.gitignore gitignore the experiment outputs 2024-01-23 15:53:01 +01:00
.python-version Trajectory prediction - test in browser 2023-10-12 20:28:17 +02:00
poetry.lock Gstreamer for rtsp 2024-11-07 15:18:33 +01:00
pyproject.toml Gstreamer for rtsp 2024-11-07 15:18:33 +01:00
README.md Track directly from rtsp 2024-11-08 14:59:21 +01:00
test_homography.ipynb testing the tracker 2024-04-25 16:31:51 +02:00
test_tracker.ipynb Run tracker with smoother enabled 2024-04-29 14:46:44 +02:00

Trajectory Prediction Video installation

Install

  • Run bash build_opencv_with_gstreamer.sh to build opencv with gstreamer support
  • Use pyenv + poetry to install

How to

See also the sibling repo traptools for camera calibration and homography tools that are needed for this repo.

These are roughly the steps to go from datagathering to training

  1. Make sure to have some recordings with a fixed camera. [UPDATE: not needed anymore, except for calibration & homography footage]
    • Recording can be done with ffmpeg -rtsp_transport udp -i rtsp://USER:PASS@IP:554/Streaming/Channels/1.mp4 hof2-cam-$(date "+%Y%m%d-%H%M").mp4
  2. Follow the steps in the auxilary traptools repository to obtain (1) camera matrix, lens distortion, image dimensions, and (2+3) homography
  3. Run the tracker, e.g. poetry run tracker --detector ultralytics --homography ../DATASETS/NAME/homography.json --video-src ../DATASETS/NAME/*.mp4 --calibration ../DATASETS/NAME/calibration.json --save-for-training EXPERIMENTS/raw/NAME/
    • Note: You can run this right of the camera stream: poetry run tracker --eval_device cuda:0 --detector ultralytics --video-src rtsp://USER:PW@ADDRESS/STREAM --homography ../DATASETS/NAME/homography.json --calibration ../DATASETS/NAME/calibration.json --save-for-training EXPERIMENTS/raw/NAME/, each recording adding a new file to the raw folder.
  4. Parse tracker data to Trajectron format: poetry run process_data --src-dir EXPERIMENTS/raw/NAME --dst-dir EXPERIMENTS/trajectron-data/ --name NAME
  5. Train Trajectron model poetry run trajectron_train --eval_every 10 --vis_every 1 --train_data_dict NAME_train.pkl --eval_data_dict NAME_val.pkl --offline_scene_graph no --preprocess_workers 8 --log_dir EXPERIMENTS/models --log_tag _NAME --train_epochs 100 --conf EXPERIMENTS/config.json --batch_size 256 --data_dir EXPERIMENTS/trajectron-data
  6. The run!
    • On a video file (you can use a wildcard) DISPLAY=:1 poetry run trapserv --remote-log-addr 100.69.123.91 --eval_device cuda:0 --detector ultralytics --homography ../DATASETS/NAME/homography.json --video-src ../DATASETS/NAME/*.mp4 --model_dir EXPERIMENTS/models/models_DATE_NAME/--smooth-predictions --num-samples 3 --render-window --calibration ../DATASETS/NAME/calibration.json (the DISPLAY environment variable is used here to running over SSH connection and display on local monitor)
    • or on the RTSP stream. Which uses gstreamer to substantially reduce latency compared to the default ffmpeg bindings in OpenCV.