opencv/object_tracking_vittrack
4
1# VIT tracker2 3VIT tracker(vision transformer tracker) is a much better model for real-time object tracking. VIT tracker can achieve speeds exceeding nanotrack by 20% in single-threaded mode with ARM chip, and the advantage becomes even more pronounced in multi-threaded mode. In addition, on the dataset, vit tracker demonstrates better performance compared to nanotrack. Moreover, vit trackerprovides confidence values during the tracking process, which can be used to determine if the tracking is currently lost.4 5In target tracking tasks, the score is an important indicator that can indicate whether the current target is lost. In the video, vit tracker can track the target and display the current score in the upper left corner of the video. When the target is lost, the score drops significantly. While nanotrack will only return 0.9 score in any situation, so that we cannot determine whether the target is lost.6 7Video demo: https://youtu.be/MJiPnu1ZQRI8 9This model is contributed by [Pengyu Liu](https://github.com/lpylpy0514) in GSoC 2023 project [**Realtime object tracking models**](https://github.com/opencv/opencv/wiki/GSoC_2023#idea-realtime-object-tracking-models)10 11**Note**:12- OpenCV > 4.8.0 is required. Build from source with instructions from https://opencv.org/get-started/.**13- `object_tracking_vittrack_2023sep_int8bq.onnx` represents the block-quantized version in int8 precision and is generated using [block_quantize.py](../../tools/quantize/block_quantize.py) with `block_size=64`.14 15 16# Demo17## Python18```bash19# tracking on camera input20python demo.py21 22# tracking on video23python demo.py --input /path/to/video24 25# get help regarding various parameters26python demo.py --help27```28## C++29Install latest OpenCV and CMake >= 3.24.0 to get started.30 31```shell32# A typical and default installation path of OpenCV is /usr/local33cmake -B build -D OPENCV_INSTALLATION_PATH=/path/to/opencv/installation .34cmake --build build35 36# tracking on camera input37./build/opencv_zoo_object_tracking_vittrack38 39# tracking on video40./build/opencv_zoo_object_tracking_vittrack -i=/path/to/video41 42# get help messages43./build/opencv_zoo_object_tracking_vittrack -h44```45 46# Example outputs47 48<img src="example_outputs/vittrack_demo.gif" style="zoom:200%;" />49 50 51# Speed test52 53NOTE: The speed below is tested by **onnxruntime** because opencv has poor support for the transformer architecture for now.54 55ONNX speed test on ARM platform(apple M2)(ms):56 57| thread nums | 1 | 2 | 3 | 4 |58| ----------- | ---- | ---- | ---- | ------------- |59| nanotrack | 5.25 | 4.86 | 4.72 | 4.49 |60| vit tracker | 4.18 | 2.41 | 1.97 | **1.46 (3X)** |61 62ONNX speed test on x86 platform(intel i3 10105)(ms):63 64| thread nums | 1 | 2 | 3 | 4 |65| ----------- | ---- | ---- | ---- | ---- |66| nanotrack | 3.20 | 2.75 | 2.46 | 2.55 |67| vit tracker | 3.84 | 2.37 | 2.10 | 2.01 |68 69# Performance test70 71preformance test on lasot dataset(AUC is the most important data. Higher AUC means better tracker):72 73| LASOT | AUC | P | Pnorm |74| ----------- | ---- | ---- | ----- |75| nanotrack | 46.8 | 45.0 | 43.3 |76| vit tracker | 48.6 | 44.8 | 54.7 |77 78# License79 80All files in this directory are licensed under [Apache 2.0 License](./LICENSE).81 82# Reference:83 84OSTrack: https://github.com/botaoye/OSTrack85 86OpenCV Sample: https://github.com/opencv/opencv/blob/4.x/samples/dnn/vit_tracker.cpp87 