This project is a real-time object detection and counting application built using Python and the YOLOv8 model.
The program captures video from a webcam and uses the YOLO object detection model to identify objects in each frame. Detected objects are highlighted with bounding boxes and labels, and the total number of detected objects is displayed on the screen.
This project demonstrates how modern deep learning models can be used for real-time computer vision applications.
- Python
- OpenCV (cv2)
- YOLOv8 (Ultralytics)
- NumPy
- The program loads the YOLOv8 object detection model.
- The webcam captures live video frames.
- Each frame is processed by the YOLO model.
- The model detects objects in the frame.
- Bounding boxes and labels are drawn around detected objects.
- The system counts the number of detected objects.
- The total object count is displayed on the screen in real time.
Install the required libraries:
pip install ultralytics
pip install opencv-python
pip install numpy
Run the program:
python main.py
Make sure the YOLO model file (yolov8n.pt) is available or downloaded automatically by the Ultralytics library.
The program opens the webcam and displays:
- Bounding boxes around detected objects
- Object labels (person, car, etc.)
- A real-time counter showing the number of detected objects
Example display:
Objects detected: 5
This project demonstrates how deep learning object detection models such as YOLO can be used for real-time video analysis.
Applications of similar systems include:
- traffic monitoring
- people counting in buildings
- security surveillance
- smart retail analytics
Possible improvements include:
- Counting specific object classes (e.g., only people or cars)
- Saving detection results to a file
- Adding a graphical interface
- Using video files instead of a webcam
- Improving performance with GPU acceleration
Sean Michaeli