This project demonstrates real-time human (person) detection using the YOLOv8 model from Ultralytics.
It works on both webcam streams and video files, highlighting detected persons with bounding boxes and a total count.
The goal of this project is to build a real-time person detection system using the YOLOv8 deep learning model.
The system can process input from:
- A webcam (live detection)
- A video file (offline detection)
It identifies all persons in each frame, draws bounding boxes, labels them, and counts the total persons detected.
- Python 3.8+ – Core programming language
- OpenCV (cv2) – Video processing and visualization
- YOLOv8 (Ultralytics) – Deep learning object detection model
- PyWin32 – Windows-specific utilities (mutex handling)
- 🔍 Detect humans in real-time using webcam
- 🎥 Detect humans from video files
- 📦 Uses YOLOv8n / YOLOv8s (lightweight and accurate)
- 📊 Displays total number of persons detected in each frame
- ✅ Easy to customize for different YOLOv8 variants
├── person_video.py
├── person_webcam.py
├── input_video.mp4
├── output_video.mp4
├── README.md
├── yolov8n.pt
└── requirements.txt
After installing the dependencies, you can run the project in two modes:
Start real-time person detection using your laptop/PC webcam:
python person_webcam.py
Run detection on an existing video file:
python person_video.py
⏹️ Exit the Program
Press q on your keyboard anytime to stop detection and close the window.
-
Persons are detected with bounding boxes and labels (Person 1, Person 2, etc.)
-
The total number of persons per frame is displayed
-
Works on both live webcam and offline videos
-
Demo Video
output.mp4
Muqadas Ejaz
BS Computer Science (AI Specialization)
AI/ML Engineer
Data Science & Gen AI Enthusiast
📫 Connect with me on LinkedIn
🌐 GitHub: github.com/muqadasejaz
This project is open-source and available under the MIT License.