Mustafa Sepen Robotics Software Engineer

Project 05

Motion Detection — CUDA / YOLO

Optical flow, GPU processing and learned detection

Role
Implementation, CUDA experimentation, evaluation
Year
2025
Platform
UAV footage · Linux · NVIDIA GPU
Context
UAV footage · simulation systems R&D
Focus
Image perception only
Motion detection pipeline diagram. A CPU path runs optical flow and temporal masking to produce region-centre markers; a CUDA path maps an OpenGL scene, runs GPU flow and component kernels and copies results back to a texture for display; and a YOLO11 path runs inference on video with supplied weights, with optional library tracking feeding an annotated display.
Three processing paths and the CPU/GPU boundaries between them. Diagram from the project repository.

The problem

Two ways to notice something moved

Optical flow provides motion cues without restricting detection to learned classes. A trained detector recognises specific categories, and ignores everything else.

Those two approaches fail differently, and the difference matters for anything that has to notice an object it was never trained on. This project builds three separate implementations of the same problem — classical optical flow, an experimental CUDA/OpenGL path, and a fine-tuned YOLO11 detector — in order to compare their failure modes and the integration cost of rendered imagery with GPU processing.

The three implementations

Different inputs, different algorithms

Component Input Processing and output
Classical CPU Local video Farnebäck flow, temporal filtering, motion masks, bounding-box-centre markers
CUDA / OpenGL Generated moving-circle scene OpenCV CUDA flow, experimental component kernels, markers on a rendered texture
YOLO11 Local video and supplied weights Learned object detections and optional library-provided tracking

CPU. Grayscale conversion and Gaussian blur precede dense optical flow. A 10-frame average and spatial-median thresholds produce masks for contour-based region extraction.

CUDA. The OpenGL texture is copied into a GpuMat, processed, and copied back. Host orchestration and scalar reductions remain on the CPU.

YOLO. Frames pass through the detector and, in tracking mode, through Ultralytics' BoT-SORT configuration. The recorded model covers six object classes.

Engineering work

Implementation, integration, evaluation

  • Classical optical-flow processing, temporal motion filtering, and threshold experiments.
  • CUDA/OpenGL interoperability and integration of OpenCV CUDA operations.
  • Custom CUDA component-processing and marker-generation kernels.
  • YOLO11n fine-tuning configuration, and video inference and tracking integration.
  • Experimental comparison of classical motion cues against learned detections.

Farnebäck optical flow, OpenCV, the YOLO11 architecture and pretrained weights, Ultralytics training and inference, and BoT-SORT tracking are established third-party foundations, not work of mine. The origin of adapted CUDA labelling code is still unconfirmed and is documented as such in the repository.

Recorded results

From the original experiment, not reproduced

Precision 0.599
Recall 0.462
mAP@0.50 0.496
mAP@0.50:0.95 0.327

These are recorded validation results from the original experiment. They are not independently reproduced benchmark results.

YOLO11n was fine-tuned for 150 epochs at image size 640 and batch size 64. The saved run used two Tesla T4 GPUs and evaluated 737 validation images.

Performance varied substantially by class: car mAP@0.50 was 0.918, while bicycle mAP@0.50 was 0.106. The evaluation notes (opens in a new tab) carry the full class breakdown, the limits of the evidence, and a proposed controlled comparison.

Limitations

Stated plainly

  • Classical motion analysis is sensitive to camera movement and to heuristic thresholds.
  • The CPU and CUDA implementations differ in both inputs and algorithms, so their historical frame-rate observations are not directly comparable. No CUDA speedup is established by this project.
  • CUDA component labelling remains experimental, with concurrency and convergence questions that require validation on the target system.
  • Ten numerical and mocked-boundary tests passed during preparation. They do not validate actual OpenCV, YOLO or CUDA execution, and the CUDA build has not been verified in the current environment.
  • The project covers image perception only. Live sensor, ROS, localization, navigation and control integration are outside the supplied implementation.

Tech stack

Classical

  • C++17
  • OpenCV
  • Farnebäck optical flow
  • Temporal filtering
  • Contour extraction

GPU

  • CUDA
  • OpenGL interop
  • OpenCV CUDA module
  • Custom component kernels
  • GLFW / GLEW

Learned

  • YOLO11n
  • Ultralytics
  • PyTorch
  • BoT-SORT tracking

Tooling

  • Python 3.10
  • CMake
  • NumPy