This project implements real-time object detection using the YOLOv3 (You Only Look Once) model with OpenCV and Deep Neural Network (DNN) module. The program processes video frames to detect and label objects from the COCO dataset in real-time.
- Loads a pre-trained YOLOv3 model for object detection.
- Processes video files or webcam streams.
- Draws bounding boxes around detected objects with class labels and confidence scores.
- Applies Non-Maximum Suppression (NMS) to filter overlapping boxes.
- Displays the processed video output with detected objects.
Ensure you have the following installed:
- Python 3.x
- OpenCV
- NumPy
You can install the required dependencies using:
pip install opencv-python numpy-
Download the YOLOv3 model weights and configuration files:
-
Place these files in the project directory.
-
Run the script with a image file:
python main.py
-
Run the script with a video file:
python video.py
Run the script with a webcam:
python cam.py
- Loading the YOLO model: Reads the model weights, configuration, and class names.
- Frame processing: Converts each frame into a blob and passes it through the YOLO network.
- Detection filtering: Extracts class IDs and confidence scores, applies thresholding and NMS.
- Drawing boxes: Labels detected objects with bounding boxes and confidence scores.
- Displaying results: Shows the processed frames in a window.
- Exiting the program: Press
Escto quit.
When running the script, you should see video frames with detected objects highlighted.
- If
yolov3.weightsis missing, download it from the provided link. - If OpenCV fails to open the video, ensure the file path is correct.
- If using a webcam, verify that it's properly connected and accessible.
This project is for educational purposes and follows the YOLO open-source licensing.
Enjoy real-time object detection with YOLOv3! 🚀