How sophiamyang/finger-frame-effect-lucy works
Purpose and entry points
This is a static browser demo for a “finger frame” effect: a user frames an area with both hands, and the framed region displays a live AI video-to-video transformation. The app is served directly as static files, with index.html as the browser entry point and main.js containing the application behavior. examples/lucy.mp4 is a demonstration asset, not part of the live pipeline.
Browser UI and rendering surface
index.html defines the full-screen interactive page, including controls for API-key entry, style selection, and custom prompts. main.js owns webcam setup, UI event handling, and composition of camera and transformed video onto a canvas. The camera view is mirrored; the AI output is clipped/mapped to the detected finger-frame quadrilateral.
Paths: index.html, main.js
Camera acquisition and local fallback
The primary source is a 1280×720, 30fps webcam MediaStream, requested from the browser after user permission. That stream supplies both local rendering and the remote AI session. If no Decart key/session is available, the framed region falls back to a local color-filter effect so hand tracking remains usable. A ?demo mode substitutes a synthetic feed/fake hands and disables AI.
Paths: main.js, index.html
Hand tracking and frame geometry
MediaPipe Hand Landmarker runs client-side against the camera feed. Its output is converted into an ordered four-corner “finger frame” quad. The tracking stage includes gesture qualification and temporal stabilization described by the project: anatomical corner ordering, hysteresis, teleport rejection, velocity-adaptive smoothing, and temporary dropout holding. This is the key boundary between raw hand landmarks and rendering geometry.
Paths: main.js
Realtime AI transport
With a user-provided Decart platform key, the camera stream is sent to Decart Lucy 2.5 through a WebRTC session. The service returns a transformed live video track; the browser draws this returned track only inside the tracked quad while retaining the original mirrored camera outside it. API-key storage and use remain browser-side, but the key is necessarily passed to Decart for session establishment.
Paths: main.js, index.html
Prompt/style control flow
Keyboard shortcuts 1–6 and UI controls select predefined visual styles. A custom style uses the prompt entered in the key/prompt panel. Prompt changes update the active Lucy session rather than reconnecting, separating session lifecycle from style mutation.
Paths: main.js, index.html
Runtime and deployment boundary
There is no backend in this repository. The runtime is a modern browser with camera permission, Canvas/video APIs, MediaPipe hand tracking, WebRTC, and the external Decart realtime model service. Development/deployment is static hosting; the documented local server is sufficient because browser camera access requires an HTTP(S) origin.
Paths: README.md, index.html, main.js
Components 13
Browser app
Static client-side runtime.
- Interactive page · Full-screen controls and rendering surface.
index.html - Application controller · Owns camera, UI, sessions, and canvas composition.
main.js - Webcam stream · 1280×720 30fps camera input after permission.
main.js - Demo feed · Fake camera and hands for ?demo mode.
main.js - Key and style controls · API key, presets, and custom prompt input.
index.html - Static hosting · Serves the app from an HTTP(S) origin.
README.md
Tracking and compositing
- Canvas compositor · Mirrors camera and clips AI output to the finger frame.
main.js - Hand Landmarker · Runs locally on camera frames.
main.js - Finger-frame geometry · Qualifies gestures and stabilizes the ordered four-corner quad.
main.js - Local color fallback · Used when no Decart session is available.
main.js
Decart realtime service
- Lucy WebRTC session · Separates session lifecycle from prompt updates.
main.js - Decart Lucy 2.5 · Transforms the submitted live video stream.
- Transformed video track · Returned WebRTC video used inside the quad.
main.js
Connections 17
- Static hosting → Interactive page: serves
- Interactive page → Application controller: loads
- Key and style controls → Application controller: events and prompt
- Application controller → Webcam stream: requests permission
- Demo feed → Application controller: replaces input in ?demo
- Webcam stream → Hand Landmarker: video frames
- Hand Landmarker → Finger-frame geometry: landmarks
- Webcam stream → Canvas compositor: mirrored base video
- Finger-frame geometry → Canvas compositor: clip quad
- Webcam stream → Lucy WebRTC session: outbound video
- Application controller → Lucy WebRTC session: key and session control
- Key and style controls → Lucy WebRTC session: style/prompt updates
- Lucy WebRTC session → Decart Lucy 2.5: WebRTC session
- Decart Lucy 2.5 → Transformed video track: transformed stream
- Transformed video track → Canvas compositor: draw inside quad
- Local color fallback → Canvas compositor: fallback framed output
- Application controller → Local color fallback: when no session