Simple real-time counter that tracks how many people enter or exit a scene using YOLOv8.
Great for monitoring doors, hallways, stores, or any fixed camera view.
object_counting_output.mp4
git clone https://github.com/mahdi-marjani/mahdi-marjani-object-tracking-entry-exit.git
cd mahdi-marjani-object-tracking-entry-exit
pip install -r requirements.txt
python main.py- Live view with tracking and counting line
- Counts people crossing the line (in/out separately)
- Saves result video →
./videos/object_counting_output.mp4 - Logs every event with timestamp →
report.txt
Example log:
1 person entered 2025-12-28 14:30:15
2 person exited 2025-12-28 14:32:40
- Replace
./videos/people.mp4with your own video or webcam (0) - Move
line_pointsinmain.pyto set the counting line - Change
classes_to_countto track other objects (e.g. cars = [2])
enjoy! 🚀