# Watrix Gait Video-To-Feature Demo

This package runs the full local-video-to-feature flow:

1. Detect and track people in a local video with ONNX Runtime CPU and `gait_detect.onnx`.
2. Export one gait sequence image directory per person track.
3. Call the Watrix Gait API to extract gait, ReID, and face features.
4. Compute dot-product similarity for normalized output features.

Sequence images are uploaded in one multipart batch: the complete request must be no larger than 32 MB. Frame order is the repeated upload-field order; filenames are ignored.

The detector now loads an external ONNX model file:

- Python: `python/gait_detect.onnx`
- C++: `cpp/gait_detect.onnx`
- C++ ONNX Runtime CPU dependency: `cpp/third_party/onnxruntime-linux-x64/`

Detection post-processing keeps the previous semantics: score threshold, NMS threshold, topK, coordinate restoration, NMS, and sequence tracking logic stay aligned.

## Python

```bash
cd python
python3 -m pip install -r requirements.txt
export WATRIX_GAIT_API_KEY="your API Key"
python3 watrix_gait_video_sequence_api_demo.py /path/to/video.mp4 \
  --base-url https://www.watrixgait.com \
  --output ./output
```

## C++

The C++ demo uses CPU-only ONNX Runtime. CUDA, cuDNN, and TensorRT are not required.

```bash
cd cpp
sudo apt-get install -y cmake g++ libopencv-dev libcurl4-openssl-dev nlohmann-json3-dev
./build.sh
export WATRIX_GAIT_API_KEY="your API Key"
export WATRIX_GAIT_BASE_URL="https://www.watrixgait.com"
./run_video_sequence_feature_demo.sh /path/to/video.mp4 ./output
```

The output directory contains:

```text
output/
  sequences/        # sequence images exported by local detection and tracking
  api_results/      # raw API response for each sequence
  summary.json      # execution summary
  similarity.json   # dot-product similarity report
```

The platform returns normalized gait_feature, reid_feature, and face_feature vectors. The dot product between same-type features is cosine similarity.

## Replacing The Model

To replace the detector later, replace `gait_detect.onnx` in the download directory and rebuild the zip package. Users need to download the new zip. The server API does not need a restart.
