Overview
Reciclaje AI uses a real-time computer vision pipeline powered by YOLOv8 to detect and classify waste materials from a camera feed. The system processes video frames continuously, identifies waste objects, and categorizes them into recyclable materials.Detection Pipeline
The waste detection system follows a streamlined pipeline from camera input to classification output:Frame Processing
Each video frame is read and passed to the YOLOv8 model for inference.The
stream=True parameter enables efficient processing for real-time video.Object Detection
YOLOv8 analyzes the frame and returns detected objects with:
- Bounding box coordinates (x1, y1, x2, y2)
- Class ID (0-4 for the 5 waste categories)
- Confidence score (0-1 probability)
Real-Time Processing Loop
The system operates in a continuous loop for real-time detection:The system uses
cv2.waitKey(5) to create a 5ms delay between frames, enabling smooth video playback and allowing keyboard input for graceful shutdown.Bounding Box Validation
To prevent rendering errors, the system validates bounding box coordinates:Model Integration
The YOLOv8 model is loaded from a pre-trained weights file:The
best.pt file contains the trained model weights specifically optimized for detecting the 5 waste categories in Reciclaje AI.Key Features
Real-Time Processing
Processes live video feed with minimal latency for instant waste classification.
Multi-Object Detection
Can detect and classify multiple waste items simultaneously in a single frame.
Confidence Scoring
Each detection includes a confidence percentage indicating prediction reliability.
Visual Feedback
Draws bounding boxes and labels directly on the video feed for easy interpretation.
Performance Considerations
Why stream=True?
Why stream=True?
The
stream=True parameter in YOLOv8 enables generator-based inference, which is more memory-efficient for processing video streams. It yields results as they’re produced rather than storing all frames in memory.Frame Rate Optimization
Frame Rate Optimization
The system captures at 1280x720 resolution with a 5ms processing delay. For lower-spec hardware, you can reduce resolution or increase the waitKey delay to maintain smooth performance.
Confidence Threshold
Confidence Threshold
The code uses
if conf > 0 as the threshold for displaying detections. In production, you might want to set a higher threshold (e.g., 0.5 or 0.7) to filter out low-confidence predictions.Next Steps
Detection Classes
Learn about the 5 waste categories and their characteristics
Model Architecture
Understand the YOLOv8 architecture powering the detection