Transparent macOS webcam puppet widget built with Rust, Tao, Wry, and client-side face tracking.
README.md

Webcam Puppet #

Webcam Puppet is a transparent, always-on-top desktop widget that uses your webcam to animate an illustrated puppet. Face position and head tilt move the character, while mouth movement switches between its closed- and open-mouth frames.

Version 0.3 introduces a single offline application core shared by macOS and Windows. Both builds contain the same camera picker, tracking calculations, animation model, controls, puppet art, and MediaPipe runtime.

Privacy and offline operation #

The application does not upload webcam frames. Face tracking runs locally in the operating system's embedded browser:

  • macOS uses WKWebView.
  • Windows uses Microsoft Edge WebView2.

The HTML, JavaScript, SVGs, MediaPipe Face Mesh model, and WebAssembly runtime are embedded into the executable. After installation, tracking does not require an internet connection.

Features #

  • Transparent, borderless, always-on-top window on macOS and Windows
  • One shared camera picker with a remembered physical-camera preference
  • Calibrated head position with no platform-specific centering offset
  • Smoothed head position and tilt
  • Mouth-state hysteresis to prevent sticky or rapidly flickering animation
  • Replaceable animation-model interface, initially using open and closed frames
  • Small, medium, and large sizes plus 10% resize steps
  • Fading toolbar, right-click menu, and bottom-right tracking indicator
  • Fully bundled MediaPipe runtime for offline use
  • A hidden console in Windows release builds, with a transparent WebView2 backing surface and no Windows 11 DWM border

How it works #

On launch, Webcam Puppet requests camera access, prefers a built-in or physical camera over a known virtual camera, and remembers the selected device for the next launch. The first detected face becomes the neutral pose automatically.

MediaPipe Face Mesh then tracks one face. The puppet moves relative to the neutral pose, tilts with the line between the eyes, and changes to its open-mouth frame when the measured lip gap crosses the configured sensitivity threshold. Movement and rotation are smoothed, and separate open/close thresholds prevent the mouth animation from flickering.

The status in the bottom-right reports Starting camera, Looking for face, Tracking, or an error. The optional mirrored camera preview is for setup only and is hidden by default.

Getting started #

  1. Launch Webcam Puppet.app on macOS or Webcam-Puppet.exe on Windows.
  2. Allow camera access when the operating system asks.
  3. Face the camera in a comfortable neutral position until the status reads Tracking.
  4. Drag anywhere on the puppet while the menu is closed to move the window.
  5. Move the pointer to the top-left, or right-click anywhere, to open the menu.

Use Recenter tracking whenever you change your sitting position. The menu also lets you select a camera, adjust mouth sensitivity, movement, and smoothing, show the camera preview, choose a preset size, resize by 10%, or quit. Native resizing is constrained to 180–1200 logical pixels per side.

Controls #

The menu button fades after 1.6 seconds when it is not in use. Hover over the top-left corner or right-click the widget to reveal it again.

Shortcut Action
Command/Ctrl + + Make the widget larger
Command/Ctrl + - Make the widget smaller
Command/Ctrl + R Reload the application
Command/Ctrl + , Open the menu
Escape Close the menu or quit

Architecture #

For a detailed walkthrough of the Rust shell, web core, event flow, libraries, and common extension points, see Internal Architecture.

There are two release artifacts but only one application implementation:

Shared web application
  camera + tracking + calibration + animation + controls
                         |
          +--------------+--------------+
          |                             |
   macOS adapter                  Windows adapter
   Tao + WKWebView                Tao + WebView2
          |                             |
       .app/.zip                       .exe/.zip

Rust owns native window behavior, local asset serving, permissions, dragging, resizing, and closing. The shared web application owns every behavior that must remain identical between platforms.

The application uses Wry's puppet:// custom protocol to serve compile-time embedded files. Behavioral JavaScript is never injected by a platform wrapper.

Project layout #

src/
  main.rs                    Shared native startup and IPC
  assets.rs                  Embedded local protocol responses
  platform/macos.rs          WKWebView-specific configuration
  platform/windows.rs        WebView2-specific configuration
web/
  index.html                 Shared application shell
  styles.css                 Shared transparent layout and controls
  src/camera.js              Camera enumeration and selection
  src/tracking.js            Pure calibration and pose calculations
  src/animation-model.js     Replaceable renderer interface
  src/main.js                MediaPipe and UI orchestration
  assets/                    Puppet animation frames
  mediapipe/                 Vendored Face Mesh JS, model, and WASM
tests/
  tracking.test.js           Cross-platform tracking invariants

Future animation systems should implement the same renderer contract used by TwoFrameAnimationModel: accept a platform-independent pose and render it. Tracking must not know whether the character uses two sprites, several mouth shapes, independently moving layers, or a skeletal rig.

Build on macOS #

Install the Apple command-line tools and Rust, then run:

xcode-select --install
chmod +x build-macos.command
./build-macos.command

Outputs:

  • dist/Webcam Puppet.app
  • dist/Webcam-Puppet-v0.3.0-macOS-arm64.zip

The local build is ad-hoc signed. Public distribution without Gatekeeper warnings requires an Apple Developer ID signature and notarization.

Build on Windows #

Install Rust and the Visual Studio C++ Build Tools, then run in PowerShell:

Set-ExecutionPolicy -Scope Process Bypass
.\build-windows.ps1

Outputs:

  • dist/Webcam-Puppet.exe
  • dist/Webcam-Puppet-v0.3.0-Windows-x64.zip

Windows 10 and 11 normally include WebView2. If it is absent, install the Microsoft WebView2 Evergreen Runtime. Release builds use the Windows GUI subsystem, so launching the packaged executable does not open a console window.

Test the shared core #

Node.js is only required to run the JavaScript unit tests; it is not a runtime dependency of the desktop application.

cd web
npm test

The tests assert that calibration maps a neutral face to the exact visual center, horizontal movement contains no fixed offset, and mouth hysteresis closes at the intended threshold. Both packaging scripts run these tests when Node.js is available, then build the native release and create its archive.

Versioning and feature parity #

Every release tag should build both platforms from the same commit. A feature is not complete until its shared-core tests pass and both native packages build. Do not maintain a separate copy of the web application for either platform.

Third-party software #

The vendored MediaPipe Face Mesh package is version 0.4.1633559619 and is licensed under Apache License 2.0. Its license is included beside the vendored runtime in web/mediapipe/LICENSE.

License #

The Webcam Puppet source is licensed under the MIT License.