This project implements real-time object detection using the YOLO (You Only Look Once) deep learning model with OpenCV in Rust. The system loads a pre-trained YOLOv4 model, processes video frames, and detects objects with bounding boxes and confidence scores.
- Loads YOLOv4 model weights and configuration.
- Reads class labels from a
coco.namesfile. - Processes video frames for real-time object detection.
- Applies non-maximum suppression (NMS) to reduce false positives.
- Displays detected objects with class labels and confidence scores.
Ensure you have the following installed:
- Rust (latest stable version) with Cargo
- OpenCV (compiled with DNN module support)
- opencv-rust bindings
Clone the repository and navigate to the project directory:
git clone https://github.com/orbitalisvoid/yolo_tracking.git
cd object-detection-rustInstall dependencies:
cargo buildDownload the necessary YOLOv4 files and place them inside a yolo directory:
yolov4.weightsyolov4.cfgcoco.names- Video file (
0.mp4) for testing
cargo runThis will process the video and print detected object classes with confidence scores.
.
├── src
│ ├── main.rs # Main application file
├── yolo
│ ├── yolov4.weights # YOLO model weights
│ ├── yolov4.cfg # YOLO model configuration
│ ├── coco.names # Class labels
│ ├── 0.mp4 # Sample video
├── Cargo.toml # Rust dependencies and project metadata
└── README.md # Project documentation
Modify the YOLO_FOLDER_PATH constant in main.rs to point to the correct location of the YOLO model files.
const YOLO_FOLDER_PATH: &str = "/path/to/yolo/folder";- Real-time Webcam Support: Implementing live detection using a webcam.
- Improved Performance: Optimize processing speed using GPU acceleration.
- Bounding Box Visualization: Draw detected objects on frames using OpenCV.
This project is licensed under the MIT License. Feel free to use and modify it as needed.
- OpenCV Team
- YOLO Developers (AlexeyAB, PJ Reddie)
- Rust OpenCV Bindings Community