Skip to content

cleoanka/zevkine

Repository files navigation

🛰️ OMNIVISION

macOS için gerçek zamanlı, çok modlu yapay zekâ görüş istasyonu

YOLO26 üzerine kurulu · iPhone Continuity Camera destekli · tek komutla çalışan yerel CV platformu


Python YOLO26 FastAPI macOS License


person · car · bicycle · dog · …   +   track · zone · speed · heatmap · dwell · crossing · anomaly


OmniVision bir "object detection demo" değildir. Kamera yönetimi, ByteTrack, yedi farklı analiz modülü, canlı dashboard, video kaydı ve export içeren production-grade bir yerel AI vision workstation'dır. Tamamen kendi makinende çalışır — buluta hiçbir görüntü gitmez.


📑 İçindekiler


✨ Özellikler

ModülNe yapar?
🎯 Object DetectionCOCO 80 sınıf · sınıfa özel sabit renkler · confidence + label
🆔 ByteTrackKalıcı track ID + iz (trail) görselleştirme
🟩 Zone AnaliziCanvas'ta poligon çiz · obje say · eşik aşımında ihlal alarmı · JSON export/import
🚗 Hız Tahminiİki referans çizgi + gerçek mesafe → m/s (kalibrasyonsuz mod uyarısı)
🔥 Crowd HeatmapBirikimli yoğunluk ısı haritası · Gaussian blur · opacity slider
⏱️ Dwell TimeTrack bazlı sahnede kalma süresi · eşik aşımında highlight
↔️ Line CrossingÇizgi geçiş sayacı · yönlü (A→B / B→A)
⚠️ AnomalyObje sayısı hareketli ortalamanın 2x üzerine çıkınca banner

Ek olarak: canlı kamera hot-swap · çözünürlük seçici · model hot-swap (YOLO26 / YOLO11 / YOLOv8) · runtime confidence & IoU slider'ları · sınıf filtresi · video kaydı (MP4) · snapshot (PNG) · log export (JSON/CSV) · sistem durumu paneli (CPU / RAM / GPU / uptime).


🏗️ Mimari

   iPhone / Dahili / USB Kamera
              │
              ▼
   ┌─────────────────────────────┐
   │  OpenCV Capture Thread       │   deque(maxlen=2) → latency birikmez
   └─────────────────────────────┘
              │  en taze frame
              ▼
   ┌─────────────────────────────┐
   │  YOLO26 Inference (NMS-free) │   MPS > CUDA > CPU otomatik
   │  + ByteTrack                 │   torch.inference_mode()
   └─────────────────────────────┘
              │  Detection[]
              ▼
   ┌─────────────────────────────┐
   │  Analiz Modülleri            │   zone · speed · heatmap
   │  (her biri izole, hatayı     │   dwell · crossing · anomaly
   │   kendi yakalar)             │
   └─────────────────────────────┘
              │
     ┌────────┴─────────┐
     ▼                  ▼
 WebSocket /ws      REST /api/*
 + MJPEG /mjpeg
     │
     ▼
 Browser Dashboard (Canvas render — npm/node YOK)

Producer (kamera) ve consumer (inference) ayrı thread'lerde çalışır; main thread'de hiçbir time.sleep() yoktur. Her modül kendi hatasını yakalar — biri çökse sistem ayakta kalır.


📦 Kurulum

# Python 3.11+ önerilir
pip install -r requirements.txt

İlk çalıştırmada ultralytics, model ağırlığını (örn. yolo26x.pt) otomatik indirir.


▶️ Çalıştırma

python main.py

Ardından tarayıcıda:

http://localhost:8000

📱 iPhone'u Continuity Camera olarak kullanma (macOS 13+)

  1. iPhone ve Mac aynı Apple ID'de, Bluetooth/Wi-Fi açık olsun.
  2. iPhone'u Mac'e yaklaştır → otomatik kamera kaynağı olur.
  3. Dashboard'da CAMERA sekmesinden iPhone'u seç, GEÇİŞ YAP.

iPhone genelde 60 fps, dahili FaceTime kamerası 30 fps hedefiyle çalışır.


⚙️ Konfigürasyon

Tüm parametreler config.yaml dosyasından gelir (kod içinde magic number yok). Runtime'da POST /api/config ile güncellenir ve dosyaya yazılır.

model: yolo26x.pt     # NMS-free; yolo11x.pt / yolov8x.pt da olabilir
device: auto          # auto | mps | cuda | cpu
inference_size: 640
target_fps: 30
confidence: 0.35
iou: 0.45
modules:
  tracking: true
  heatmap: true
  zones: true
  speed: false
  dwell: true
  crossing: true
  anomaly: true

🗂️ Dosya Yapısı

omnivision/
├── main.py              # FastAPI app + lifespan
├── config.yaml          # Tüm konfigürasyon
├── pyproject.toml       # Ruff + pytest + paket metadata
├── requirements.txt
├── core/
│   ├── config.py        # Thread-safe config
│   ├── camera.py        # CameraManager (enumerate + capture thread)
│   ├── inference.py     # YOLOEngine (YOLO26, MPS/CUDA/CPU, ByteTrack)
│   ├── detection.py     # Detection veri modeli + COCO
│   ├── tracker.py       # Track iz (trail) yöneticisi
│   ├── recorder.py      # MP4 / snapshot / log export
│   ├── pipeline.py      # Producer-consumer orkestrasyon
│   └── modules/
│       ├── heatmap.py   ├── zones.py    ├── speed.py
│       ├── dwell.py     ├── crossing.py └── anomaly.py
├── api/
│   ├── routes.py        # /api/* REST
│   └── websocket.py     # WS + MJPEG yayıncı
├── static/
│   └── index.html       # Tek dosya dashboard (CSS+JS inline)
└── tests/               # pytest — saf mantık testleri

🔌 API Özeti

Method Endpoint Açıklama
GET /api/stats Canlı pipeline + sistem istatistikleri
GET POST /api/config Konfigürasyon oku / güncelle
GET /api/cameras Kameraları listele
POST /api/cameras/switch Kamera hot-swap
POST /api/filter/classes Sınıf filtresi
GET POST DELETE /api/zones Zone CRUD
POST /api/crossing/line Geçiş çizgisi ayarla
POST /api/speed/config Hız kalibrasyonu
POST /api/record/toggle Kaydı başlat/durdur
POST /api/snapshot PNG snapshot
POST /api/export/log JSON/CSV log export
WS /ws Canlı frame + meta yayını
GET /mjpeg Klasik MJPEG akışı

⚡ Performans Notları (macOS)

  • Apple Silicon (MPS) otomatik seçilir; half_precision toggle ile FP16.
  • YOLO26 NMS-free → daha hafif post-processing, düşük gecikme.
  • torch.inference_mode() her zaman aktif.
  • Frame queue deque(maxlen=2) → gecikme birikmez, daima en taze frame.
  • cv2.setNumThreads(0) → Python thread havuzuyla çakışma yok.
  • frame_skip ile düşük donanımda her N. frame işlenir.

🧪 Geliştirme & Test

pip install -e ".[dev]"   # ruff + pytest + headless OpenCV
ruff check .              # lint
pytest                    # saf mantık testleri

CI (.github/workflows/ci.yml) her push & PR'da ruff + py_compile + pytest çalıştırır. Claude Code on the web oturumları için .claude/hooks/session-start.sh bağımlılıkları otomatik kurar.


Hiçbir özellik atlanmadı. Tamamen yerel. Tamamen senin. 🚀

MIT License · YOLO26 by Ultralytics

About

zevkine

Resources

License

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages