Object Detection and Tracking in Video


We built a proof of concept for real-time object detection and tracking in video from a camera.

Input

Video from a camera (public video datasets during the proof of concept)

Output

Bounding boxes for people and vehicles, each with an ID that stays the same across frames, plus a runtime and memory profile per model combination

Goal

Compare detector and tracker combinations and build a configurable pipeline


Challenges


Detecting people and vehicles in a single frame is largely solved, and pre-trained models do it well. The harder part is deciding which detection in the next frame belongs to which object, so that every object keeps its ID over time. This association step runs continuously alongside detection, and its cost depends on how many objects are in the scene.

There are many detectors and trackers to choose from, with different trade-offs between speed, accuracy and model size. Published benchmarks are measured on other data and hardware, so they are only a starting point. Detection and tracking also influence each other: a fast detector paired with a heavy tracker can be slower overall than a slower detector with a light one. The only reliable way to choose is to measure complete combinations on the same footage.

Evaluation needed its own approach. Public video datasets are often only partly annotated. A model that correctly finds an unannotated person is then counted as wrong, so standard scores such as mAP or MOTA would mostly reflect gaps in the labels.

Finally, the client receives full rights to the result. Several common models and trackers are published under a commercial licence, so licensing was a selection criterion from the start.


Solution


We used tracking by detection. A detector finds the objects in each frame, and a tracker links them over time.

Before the official start, we checked the approach on public video footage with off-the-shelf models. This gave us a first idea of runtime and output quality and helped define the work packages.

We then built a pipeline with six stages. The input handler reads video files frame by frame. Preprocessing resizes and normalises each frame. The detection stage returns bounding boxes with class and confidence. The tracking stage assigns IDs. Post-processing smooths the tracks and filters duplicate boxes, and the output handler writes an annotated video and a log of all detections and tracks. Detector and tracker are set in a configuration file, so a new combination runs without changes to the code.

On the detection side we compared two families: one-stage convolutional detectors (YOLOv9, YOLOv11) and a transformer-based detector (RT-DETRv2). We shortlisted them by published speed and accuracy, model size, licence and export to ONNX. On the tracking side we compared three designs. ByteTrack uses only motion and box overlap. BoT-SORT adds appearance features and compensates for camera motion. DeepSORT relies on a learned appearance descriptor for every object.

For each combination we measured latency per frame, split into detection and tracking, along with frame rate, GPU memory and RAM. We ran the measurements on different hardware configurations, at several input resolutions and on scenes with few and with many objects, and compared PyTorch with exported model formats. Because of the label gaps, we judged tracking quality on long video sequences by how consistently each object kept its ID. We documented the licence of every component, together with open-source alternatives where one exists.


Results


After eight weeks, the client had a factual basis for choosing its detection and tracking stack. Published benchmarks come from other datasets and other hardware. With the new setup, the team can see for every detector and tracker combination how runtime, memory use and tracking quality relate under its own conditions, and decide which trade-off fits which use case.

In the pipeline, detector and tracker are exchanged in a configuration file, and every candidate runs through the same benchmark.

The client owns all code, models and documentation, including a licence review of every component. The handover workshop covered the code base and a live run of the containerised pipeline, and the technical report documents the trade-offs behind each option.


Technical Background


  • ML: Python, PyTorch, Ultralytics

  • Export: ONNX

  • Packaging and handover: Docker, GitLab

Related projects