This project implements real-time object detection using the YOLOv8 model from Ultralytics and OpenCV. The script captures video from a webcam, processes frames using YOLOv8, and displays detected objects with bounding boxes and labels.
- Uses YOLOv8m for object detection.
- Displays bounding boxes with class labels and confidence scores.
- Real-time FPS display.
- Supports CUDA (GPU) if available.
- Custom colors for different object classes.
Make sure you have the following dependencies installed:
pip install torch numpy opencv-python ultralytics supervision- Clone the Repository (if applicable):
git clone https://github.com/yourusername/yolo-object-detection.git cd yolo-object-detection - Run the Script:
python detection.py
- Press
ESCto Exit.
project-folder/
│── detection.py # Main script for object detection
│── README.md # Documentation file
- Initialize Model: Loads YOLOv8m and sets up device (CPU/GPU).
- Capture Frames: Reads frames from the webcam.
- Run Predictions: Detects objects using YOLO.
- Draw Bounding Boxes: Uses OpenCV to annotate frames.
- Show Output: Displays annotated video with FPS.
- Ensure your webcam is working properly.
- If running on GPU, make sure CUDA is installed and compatible.
- If
supervisionmodule causes errors, update it:pip install --upgrade supervision
This project is open-source and available under the MIT License.