How roryclear/clearcam works
Project type and purpose
• clearcam is a multi-platform AI-powered security camera solution.
• It includes:
• A Python-based NVR/inference server (clearcam.py, aes.py, experimental modules, yolox) that ingests RTSP streams, runs object detection (YOLOv8 via tinygrad), encrypts video/events, and serves a web UI on localhost:8080.
• Native mobile clients on iOS (Objective-C/Swift UI controllers under ios/clearcam) and Android (Kotlin/Jetpack Compose under android/clearcam/app) for device configuration, viewing live feeds, browsing events, and entering a premium UserID.
• A cloud relay/notification service (implied by “receive streams and notifications” for premium users).
File structure
• Top-level Python scripts and requirements.txt drive the NVR server: clearcam.py (entrypoint), aes.py (encryption), yolox/tracker and experimental/… (CV/inference).
• android/clearcam: full Android Studio project with Jetpack Compose UI, build scripts, Google services config.
• ios/clearcam.xcodeproj & ios/clearcam: Xcode project with view controllers, Storyboards, asset catalogs, Python-based Yolo integration, secret management, file server.
README for additional insights
• The system must support local NVR + inference and optional premium streaming/notifications via cloud.
• The tech stack: ffmpeg, tinygrad, numpy, OpenCV, SciPy, lap, cython_bbox for inference; Android/Kotlin, iOS/Obj-C/Swift UI.
• Web UI on port 8080, mobile UI clients, end-to-end encryption.
a. Main components
• External RTSP Cameras (IP cameras or old iPhones streaming RTSP)
• Local NVR & Inference Server
– Ingestion (ffmpeg processes)
– Inference Engine (YOLOv8 via tinygrad, yolox/tracker modules)
– Encryption Module (aes.py)
– Storage (local disk for clips/events)
– Web Server/API (serves browser UI, HTTP endpoints on 8080)
• Cloud Relay & Notification Service (premium)
– User Authentication (UserID)
– Encrypted Stream Relay
– Push Notification Gateway
• Client UIs
– Web Browser (React/Vue or simple HTML served by Python)
– Mobile Apps
• iOS (ViewControllers, SceneDelegate…)
• Android (Jetpack Compose screens)
b. Relationships and interactions
1. Cameras → RTSP Ingestion → Inference Engine → Event Detection
2. Inference Engine → Storage of clips/events → Encryption → Local disk
3. Web Browser ⇄ Python Web Server (HTTP/WebSocket) for live view & events
4. Mobile App ⇄ Local or Cloud API for live view & playback
5. Local Server → Cloud Relay (encrypted push of selected streams/events) → Mobile push notifications
c. Architectural patterns & design principles
• Layered architecture:
• Device Layer (RTSP cameras)
• Processing Layer (ingestion, inference, encryption, storage)
• Presentation Layer (web UI, mobile clients)
• Cloud Integration Layer (relay & notifications)
• Modular CV pipeline: separation of ingestion, detection, and tracking (yolox modules)
• End-to-end encryption: cryptographic module isolating data at rest/in-transit
• Micro-frontend style: independent mobile clients and web front end
d. Key technologies & frameworks
• Python: ffmpeg CLI, tinygrad, numpy, OpenCV (cv2), SciPy, lap, cython_bbox
• YOLOv8 model variants (s, m, l, x)
• Android: Kotlin, Jetpack Compose, Google Services
• iOS: Objective-C, Swift UI, Storyboards, StoreKit
• Web: HTTP server on Flask/FastAPI (implied), WebSockets (optional)
• Encryption: AES in aes.py