Simple end-to-end video pipeline using OpenCV + YOLO + EasyOCR.
- Vehicle detection + tracking (unique IDs)
- Vehicle crossing count on a virtual line
- Vehicle speed estimation (km/h, approximate)
- Road segmentation overlay
- Pedestrian pose keypoints/skeleton
- Basic license plate OCR
src/main.py- main video loopsrc/traffic_analyzer.py- pipeline modulessrc/speed_estimator.py- speed logicdata/traffic.mp4- input video
cd C:\Users\Purunjay\Downloads\Computer_Vision_Project-main
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install --upgrade pip
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
pip install -r requirements.txtpython src/main.pyPress q to quit.
MAX_FRAMES- stop after N framesCOUNT_LINE_ORIENTATION-horizontalorverticalCOUNT_LINE_Y_RATIO- horizontal line position (0.0 to 1.0)COUNT_LINE_X_RATIO- vertical line position (0.0 to 1.0)SPEED_METERS_PER_PIXEL- speed scale calibration
Example:
$env:COUNT_LINE_ORIENTATION="vertical"; $env:COUNT_LINE_X_RATIO="0.5"; $env:SPEED_METERS_PER_PIXEL="0.05"; $env:MAX_FRAMES="300"; python src/main.py- Place your input video at
data/traffic.mp4. - YOLO model files are auto-downloaded on first run if missing.
- Speed is an estimate and depends on camera angle +
SPEED_METERS_PER_PIXEL. - Large files are not committed:
*.ptweights,data/*.mp4, andoutputs/(see.gitignore). - If your counting line isn't working for a specific sample video, it might be due to low visual quality! For example, YOLO can notoriously misclassify blurry rectangular cars as cell phones (class 67). Adjust the
vehicle_clsinsrc/traffic_analyzer.pyif this occurs!
I cannot log in to your GitHub account from here. After you create an empty repository on GitHub (no README/license if you already have a local commit), run:
cd C:\Users\Purunjay\Downloads\Computer_Vision_Project-main
git remote add origin https://github.com/YOUR_USERNAME/YOUR_REPO.git
git branch -M main
git push -u origin mainIf your default branch is master instead of main:
git push -u origin masterUse SSH if you prefer:
git remote add origin git@github.com:YOUR_USERNAME/YOUR_REPO.git
git push -u origin main