AR Smart Mirror
Real-time interactive AR virtual try-on system designed for retail fashion.
The Problem
In-store clothing fitting is slow, creates long queues in fitting rooms, and increases garment wear. Retailers need an instant, hygienic, and engaging digital mirror that lets shoppers visualize outfits without undressing.
My Role
Built solo with AI-assisted development — computer vision pipeline design, MediaPipe pose detection integration, Canvas AR overlay engine, FastAPI backend services, Docker multi-container topology, and Cloudflare Zero Trust ingress.
Highlights
- Sub-30ms real-time body tracking and landmark extraction using MediaPipe Pose
- Dynamic Canvas AR garment warping and affine transformation for realistic clothing drape
- FastAPI backend with PostgreSQL catalog and Redis session pub/sub synchronization
- Mobile controller pairing allowing customers to browse catalogs and trigger try-ons from their smartphones
- Production-grade Docker Compose architecture with Nginx reverse proxy and Cloudflare Tunnel
Stack
Constraints
- Hard real-time latency target (<33ms per frame / 30 FPS) to avoid motion sickness and visual lag.
- Zero customer biometric persistence — video feeds must process in memory without saving raw footage to disk.
- Compatibility with standard consumer hardware (e.g. RTX 3060) without requiring specialized depth cameras.
System Architecture
Key Trade-offs
The decisions worth defending — what I chose, what I turned down, and why.
Pose tracking execution model
Chose
Client-side MediaPipe Pose on Canvas API with GPU acceleration
Rejected
Server-side video streaming and frame-by-frame inference
Server inference introduces network jitter, high bandwidth overhead, and privacy concerns streaming raw camera feeds over the network.
Garment deformation approach
Chose
Real-time 2D affine mesh deformation keyed to skeletal anchor landmarks
Rejected
Full 3D physics-based volumetric cloth simulation
3D cloth simulation cannot sustain 30+ FPS on edge kiosk hardware; 2D mesh triangulation provides fluid response with low computational cost.
Remote store interconnect
Chose
Cloudflare Tunnel over outbound HTTPS
Rejected
Direct port forwarding and dynamic DNS on store routers
Retail store Wi-Fi and ISP firewalls prevent inbound port forwarding; Cloudflare Tunnels punch through NAT securely without public IPs.
What I'd Do Differently
An honest retrospective — the stuff I'd change with more time, more users, or a second pass.
- 1Implement WebGPU shaders for cloth lighting and shadow blending to improve realism under dynamic store lighting.
- 2Add an offline fallback queue for store analytics so telemetry buffers locally during internet interruptions.
- 3Optimize landmark smoothing filters (OneEuro filter) to eliminate micro-jitter when shoppers stand at edge distances.
Computer Vision & Pose Tracking Shell
Benchmark the real-time AR try-on pipeline (status, camera init, pose detect, mesh align -shirt, latency bench).
Technical Deep-Dive
Architecture, specifications, and implementation details.
01 — Master Specification: AR Smart Mirror System
#1. Purpose
The AR Smart Mirror enables retail customers to virtually try on clothing items using real-time AI body pose detection and canvas-based garment overlay.
#2. System Goals
- 30fps real-time garment overlay on live camera feed
- <100ms render latency from pose detection to display
- Zero fitting room dependency — full try-on without undressing
- Accessible from any WiFi via Cloudflare Tunnel
- 100% on-premises — no cloud compute, no per-request cost
#3. Functional Requirements
| ID | Requirement | Priority |
|---|---|---|
| F01 | Detect body pose from webcam at ≥30fps | Critical |
| F02 | Overlay selected garment on detected body | Critical |
| F03 | Mobile WebApp Controller for remote catalog browsing | Critical |
| F04 | QR Code dynamic pairing to link mobile phone to mirror | Critical |
| F05 | Real-time WebSocket sync between phone and mirror (<100ms) | Critical |
| F06 | Support top, bottom, and full outfit garment types | Critical |
| F07 | Adapt garment size to detected body proportions | Critical |
| F08 | Staff can add new garments in <5 minutes | High |
| F09 | Session analytics — try-on count per garment | High |
| F10 | Remote access via Cloudflare Tunnel | High |
| F11 | Share/save current look as image to mobile device | Medium |
#4. Non-Functional Requirements
| ID | Requirement | Target |
|---|---|---|
| NF01 | Pose detection FPS | ≥30fps |
| NF02 | Garment render latency | <100ms |
| NF03 | System uptime | 99.9% |
| NF04 | API response time p95 | <200ms |
| NF05 | Docker cold start | <5 seconds |
| NF06 | Max GPU VRAM usage | <8GB |
#5. Constraints
- Runs on-premises: RTX 3060 12GB, i5 14th gen, 16GB RAM
- No recurring cloud compute cost
- All software open-source
- Docker Desktop on Windows 11
#6. Out of Scope (v1.0)
- Mobile native app
- 3D garment simulation
- Purchasing flow
- Multi-camera support