This repo is an object tracking system tested on live webcam feeds and deployed to a custom (cheap and shitty) physical robot that I built, called TAILGATER-1.
It uses a Siamese Fully Convolutional Network (SiamFC).
The system is split into two parts:
- Vision / Control (Python): Python pipeline for dataset downloading, preprocessing, and SiamFC model training. It has two main scripts:
track_webcam.py: Runs object tracking on any PC camera feed.control_tailgater.py: Calculates target bounding box coordinates, converts them into movement commands (forward,backward,left,right,stop), and sends them to the robot over Wi-Fi.
- Movement / Hardware (C++): ESP32 loop (
src/main.cpp) that receives directional commands from the Python tracker and controls the motors to keep the target centered.
- Project Showcase
- Robot Hardware Specs
- Code + Repo Structure
- Quick Start: Webcam Tracking
- Training Your Own SiamFC (Optional)
The total cost for the robot stays under 30$ (~110-120 PLN), excluding reusable stuff like Li-ion 18650 cells.
| Component | Description | Approx. Cost (PLN) |
|---|---|---|
| Chassis Kit | 2WD Acrylic chassis + 2x TT Gear Motors + wheels | ~30 PLN |
| MC + Vision | ESP32-CAM module | ~60 PLN |
| Motor Driver | L298N Dual H-Bridge driver | ~8 PLN |
| Power Management | LM2596 DC-DC Buck Converter | ~10 PLN |
| Power Source | 4x 18650 Li-ion batteries | ~idk |
├── control_tailgater.py # Runs the vision loop and sends commands over to ESP32
├── track_webcam.py # Runs the same vision loop but on a webcam instead of ESP32-CAM
├── platformio.ini # Config file for platformio
├── src/
│ └── main.cpp # ESP32 loop receiving commands and spinning motors
└── python_ml/
├── dataset.py # PyTorch Dataset loader
├── loss.py # Balanced logistic loss for SiamFC
├── siamfc.py # SiamFC architecture
├── train.py # Training loop for SiamFC
└── scripts/
├── download_dataset.py # Dataset fetcher script
└── preprocess_dataset.py # Data cropping / filtering script
I decided not to give instructions on how to build the robot, because I'm more into the software part, rather than the hardware. Also the robot is such a botch job it's crazy.
You can run the webcam tracker on your PC, without training a model. I included the SiamFC weights under weights/siamfc.pth.
Clone the repo and install the required Python packages:
git clone https://github.com/horecdev/tailgater.git
cd tailgater
pip install torch torchvision opencv-python numpypython track_webcam.pyHow to use it: When the camera feed window opens, move your mouse and left-click on whatever you want to track. Use right-click to drop the target. Use scroll to adjust the selection box size. Press q to quit.
Here is how to train your own model end to end.
Fetches the raw dataset.
python python_ml/scripts/download_dataset.pyCrops and filters the GOT10k frames.
python python_ml/scripts/preprocess_dataset.pyTrain the model :)
python python_ml/train.pyPick the best model from ./train/ (epoch with lowest loss presumably) and put it in weights/siamfc.pth or update paths in python scripts to point to it.
I did not run this through validation benchmarks, because the goal was just to get it working for the robot and webcam. I stopped training after 61 epochs. Here is the loss curve:

