Repository:
smart-depth-cra2m-tracker
Author: Rolando Cortez (Computer Vision Developer)
Smart Depth CRA2M Tracker is a plug-and-play 3D perception module using just a monocular RGB camera. It enables absolute distance estimation and real-time tracking without the need for LIDAR or stereo vision — ideal for edge robotics and smart monitoring.
- YOLOv10: robust object detection.
- ByteTrack: multi-object tracking.
- Depth Anything v2: relative depth map estimation.
- CRA2M: converts relative depth to metric using ArUco/Charuco markers and
solvePnP. - 1D Kalman Filter: smoothing and continuity in depth estimation.
- Graphical Interface: live controls for tracking, scaling, and averaging settings.
graph LR
A[RGB Frame] --> B[YOLOv10 Detector]
B --> C[ByteTrack Tracker]
C --> D[Bounding Box Center]
A --> E[Depth Anything Map -every 4 frames-]
D & E --> F[Patch Sampling -median-]
F --> G[CRA2M Scale Estimation]
G --> H[Z Real Estimation]
H --> I[Kalman Filter per ID]
I --> J[Final Depth + Visualization]
- Relative depth is calculated at the center of the bounding box using a patch of 10% its size.
- CRA2M: custom calibration-based scaling from relative to real-world metric depth using ArUco markers + PnP, enabling depth in meters from monocular input.
- The metric depth of each tracked object is updated by applying the model and smoothing with a per-ID Kalman filter.
smart-depth-cra2m-tracker/
├── gui/ # User interface (PyQt backend in video_worker.py)
├── depth/ # CRA2M, estimation and Kalman tracking
├── detection/ # YOLOv10 wrapper
├── tracking/ # ByteTrack + Q/R tuning
├── utils/ # Central patch, buffers, scaling
├── scripts/ # Main runners: webcam vs OAK-1
├── checkpoints/ # Models: YOLOv10, DepthAnything
├── data/ # Calibrations
├── config.py # ByteTrack config loader
python scripts/run_cra2m_tracking.pypython scripts/run_cra2m_tracking_oak.pyHere’s a demo of the interface in action. It shows real-time object tracking, depth estimation, and scaling visualization.
🎥 Click here to watch on YouTube
Features:
- Select depth model (
vits,vitb,vitl) - Switch between linear, quadratic, cubic, spline scaling, etc.
- Visualize detected markers and their
rvec,tvec - Change averaging type:
z_rel,z_real, or none - Use optional buffers and stabilization per ID
- Python 3.9+
- PyTorch (depends on CUDA version)
- OpenCV with GUI (
opencv-python, notheadless) - Models:
depth_anything_v2_vitl.pth,yolov10s.pt...
Installation:
pip install -r requirements.txtCommon GUI issue fix:
pip uninstall opencv-python opencv-python-headless
pip install opencv-python==4.8.0.76- Real-time visualization (RGB + Depth + Metric)
- Select:
- Camera (Webcam / OAK-1)
- YOLO and Depth models
- Scaling method (linear, cubic, spline, etc.)
- Smoothing strategy (Kalman, averaging)
- Scale type used (
z_rel,z_real, none)
- Tune:
- Inference frequency
- Central patch size
- Buffer length
- Kalman parameters (
Q,R) per ID
- Display:
- Depth per object ID
- CRA2M-generated scale models
- FPS, resolution, active markers
- Detector:
YOLOv10(PyTorch) - Tracker:
ByteTrackwith YAML config - Association via IOU and score
- Monocular model:
Depth Anything v2 - Takes median from a central patch of the bounding box
- Configurable frequency: apply every N frames
- Uses ArUco/Charuco and
solvePnPto compute real distances - Compares the
z_relof those points with theirz_realto derive scaling factors - Fitting methods:
linear,quadratic,cubic,log,exp,spline
- GUI shows real-time fitting status
- One independent 1D filter per object (ByteTrack ID)
- Dynamically tuned
QandRusing multiple strategies:- Based on deviation, prediction, or hybrid models
- Maintains depth stability between inferences
- Smart monitoring systems
- Mobile robots without LIDAR
- Depth estimation on edge devices
- HMI applications where low-cost proximity sensing is needed
- Based on ArUco / Charuco and
solvePnP - Supports single marker, Charuco, or multi-marker mode
- Generates scales:
linear: a * z + bquadratic: a * z² + b * z + cspline: smooth interpolation
- Evaluated in real time and viewable in GUI
- Validates range and consistency of each scale
This project showcases the following applied skills:
- Designed and integrated a multi-model CV pipeline combining detection, monocular depth estimation, metric scaling, and object tracking.
- Applied camera geometry and PnP estimation (ArUco/Charuco + solvePnP) for real-world distance calibration.
- Developed CRA2M, a custom depth scaling framework supporting linear, polynomial, and spline mappings.
- Built a real-time GUI (PyQt) with modular configuration, allowing dynamic model switching, scaling modes, and per-ID Kalman smoothing.
- Focused on practical engineering: real-time performance, usability, modularity, and deployability on edge devices.
- Dynamic Adjustment of Q and R: The
adjust_qrfunction has been designed to dynamically adjust theQandRparameters of the Kalman filter, but it is currently not connected to the backend of the system. The code and necessary functions are present in the project, but they are not yet invoked or integrated into the main flow. This feature is planned for future improvement and will be completed in upcoming versions. Why this approach?
- YOLOv10 (THU-MIG)
- Depth Anything V2 (ISL)
- ByteTrack
- Full interface and integration: Rolando Cortez García
- CRA2M (including the quadratic, spline, exponential, and logarithmic functions) is an original implementation by Rolando Cortez García
MIT License
Rolando Cortez García
Email: rolscg@gmail.com
GitHub: rolandocortez
LinkedIn: rolando-cortez
“Detect, scale, track — one frame at a time.” 🚀