Skip to content

leonyap27/VideoLineCrossingAnalytics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

People Line Crossing Counter (YOLOv8 + Streamlit)

This project provides a complete web-based system to detect and count people crossing a custom-defined line in a video using YOLOv8 and ByteTrack. It features a Streamlit frontend and a Python backend with logging and video annotation.


🔧 Features

  • 🖼️ Upload video and draw counting line on the first frame
  • 🧠 YOLOv8 + ByteTrack to detect & track people (class_id = 0)
  • 🧮 Count people who cross the defined line (with deduplication)
  • 📦 Output annotated video with bounding boxes, tracker IDs, and line overlay
  • 📊 Export all detection logs to Excel (bbox, class, confidence, frame, tracker_id)
  • 📉 Live frame-by-frame processing progress in Streamlit

🛠️ Tech Stack

Layer Technology
Object Detection YOLOv8 (Ultralytics)
Tracking ByteTrack
UI Streamlit
Drawing streamlit-drawable-canvas
Frame Handling OpenCV
Annotation Supervision
Logging Excel export (via pandas)

🗂️ Folder Structure

project/
├── app.py                     # Main Streamlit UI
├── draw_line.py              # Drawing canvas logic
├── yolov8_track_count.py     # Core detection & counting logic
├── output/                   # All generated outputs
│   ├── <video_name>_result.mp4
│   ├── <video_name>_line_coords.json
│   └── <video_name>_detections.xlsx

▶️ How to Use

  1. Launch the Streamlit app:

    streamlit run app.py
  2. Upload a video (MP4 or AVI format)

  3. Draw a line across the first frame (this is the crossing line)

  4. Run detection – people crossing the line will be counted

  5. Download Excel file to view all detections and bounding boxes


📋 Excel Output Columns

Column Description
frame Frame number
tracker_id Unique person tracker ID
class_id Object class (0 = person)
conf Detection confidence score
x1, y1, x2, y2 Bounding box coordinates

⚠️ Notes

  • Only class_id = 0 (person) is counted
  • The same person is counted only once when crossing the line
  • All logic assumes one custom-drawn line per video
  • If using older versions of supervision, the direction-based counting is disabled

📦 Setup

pip install -r requirements.txt

Requirements (manually ensure):

  • ultralytics
  • opencv-python
  • pandas
  • supervision >= 0.6.0 (for direction-aware line zones)
  • streamlit
  • streamlit-drawable-canvas
  • openpyxl (for Excel export)

📍 Next Steps

  • Support multiple lines/zones
  • Add filtering (e.g., count only adults, helmets, etc.)
  • Heatmap visualization from detection logs

👤 Author

Developed by LTA Data Scientists Team

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages