Skip to content

mwihoti/computer_vision

Repository files navigation

🚗 Room Attendance & Traffic CV

A high-performance, edge-native Computer Vision system for real-time traffic sensing, person tracking, and multi-class object counting. This project implements state-of-the-art YOLO-based perception in both Python and Rust.

🌟 Key Features

  • Real-time Traffic Analysis: Calculate vehicle speeds (km/h), detect traffic jams, and monitor flow patterns.
  • Physics-Informed Tracking: USes homography (in-progress) and pixel-to-meter calibration for science-grade speed data.
  • Dual-Stack Architecture:
    • Python: Easy prototyping with Ultralytics and DeepFace (adds gender analysis).
    • Rust: High-performance, edge-optimized inference using ort (ONNX Runtime) and OpenCV.
  • Edge-Native: Designed to run locally on low-power devices (e.g., NVIDIA Jetson) to ensure data privacy and zero latency.
  • Automatic Reconnect: Smart reconnection logic for unstable V4L2/RTSP camera streams.

🚀 Getting Started

1. Python Implementation (Gender Analysis + Proto)

The Python version is the primary implementation and includes people tracking plus gender detection using DeepFace.

Setup:

  1. Ensure you have Python 3.10+ and a webcam connected.
  2. Activate the virtual environment:
    source venv/bin/activate
  3. Run the desired script:
    • python main.py: Attendance with gender analysis.
    • python traffic_analyzer.py: Road traffic monitor.

2. Rust Implementation (High Performance)

The Rust version is a high-performance port located in the rust_cv directory. It uses ONNX Runtime and OpenCV with direct V4L2 support on Linux.

Setup:

  1. Install system dependencies (e.g., libopencv-dev on Debian/Ubuntu).
  2. Ensure yolov8s.onnx and yolov8m.onnx are in the project root.
  3. Navigate to the Rust directory:
    cd rust_cv
  4. Run a specific binary in release mode:
    • Traffic: cargo run --release --bin traffic_analyzer
    • Attendance: cargo run --release --bin attendance
    • Objects: cargo run --release --bin object_counter

🛠 Project Structure

.
├── rust_cv/               # Rust source code and Cargo projects
│   ├── src/bin/           # Executables (traffic_analyzer, attendance, etc.)
│   └── src/lib/           # Perception & Tracking library
├── main.py                # Main Python attendance entry point
├── traffic_analyzer.py    # Python traffic sensing prototype
├── tracker.py             # Base Python tracking logic
├── yolov8s.onnx           # Compiled ONNX model (Small)
└── yolov8m.onnx           # Compiled ONNX model (Medium)

🛣 Production Roadmap

This project is evolving into a city-scale sensing layer. Key milestones include:

  • Homography Transform: Automated birds-eye-view mapping for sub-1km/h speed accuracy.
  • RTSP Support: Integration with municipal IP camera infrastructure.
  • DB Integration: Sending real-time mobility events to PostgreSQL/MQTT.
  • Model Distillation: Optimizing models for ultra-low power hardware (NVIDIA Jetson).

📜 License

Open-sourced for urban science and public mobility research.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors