A Jupyter anywidget that streams live MediaPipe hand-landmark and gesture data from your webcam into Python.
Project description
gesture-recognizer-widget
A Jupyter anywidget that runs the MediaPipe Gesture Recognizer on your webcam and streams the results straight into Python. Each of the 21 hand landmarks is a live traitlet, so you can read finger positions, the recognized gesture, and handedness directly in a notebook — and drive anything you like with them (plots, robots, a Blender rig, …).
All inference happens in the browser via @mediapipe/tasks-vision; Python just
receives the numbers.
Install
pip install gesture-recognizer-widget
Use it in a notebook
from gesture_widget import GestureRecognizerWidget
w = GestureRecognizerWidget()
w # display the cell, then click "Start Camera"
# Individual landmarks as [x, y, z], normalized 0..1 (empty list when no hand):
w.index_finger_tip # -> [0.51, 0.42, 0.0]
w.thumb_tip
w.wrist
# High-level result for the primary (most confident) hand:
w.gesture # -> "Victory"
w.confidence # -> 0.93
w.handedness # -> "Right"
w.num_hands # -> 1
# Everything at once:
w.finger_positions() # {"wrist": [...], "thumb_cmc": [...], ...} (21 entries)
w.hands # full per-hand data for every detected hand
# React to changes:
w.observe(lambda ch: print(ch["new"]), "index_finger_tip")
# Control from Python:
w.start(); w.stop() # toggle the camera
w.mirror = False
w.max_num_hands = 1
w.sync_interval_ms = 50 # how often landmarks are pushed to Python (default 100ms)
Camera access requires a browser context: start it from the rendered widget's button (a user gesture) or via
w.start(). The model and WASM runtime are fetched from the MediaPipe CDN on first load, so the first run needs internet.
Using the development version
If you've cloned the repo and want to run against your local checkout (e.g. to hack on the widget while using the notebook), install it in editable mode after building the front-end bundle:
npm install
npm run build:widget # bundles src/widget.ts -> src_widget/gesture_widget/static/widget.js
pip install -e . # editable install of the local package
pip install -e . makes from gesture_widget import GestureRecognizerWidget
resolve to your working tree, so Python changes are picked up immediately and
rebuilding the bundle refreshes the front-end. If you're working inside an
embedded interpreter (such as Blender's bundled Python), point its pip at the
repo instead:
import subprocess, sys
subprocess.check_call([sys.executable, "-m", "pip", "install", "-e", "/path/to/caputre_motion"])
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gesture_recognizer_widget-0.1.0.tar.gz.
File metadata
- Download URL: gesture_recognizer_widget-0.1.0.tar.gz
- Upload date:
- Size: 50.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea73e79ac8bd1a562101e76128f5d63949298b953c8fa9cdd19d3b35d8189989
|
|
| MD5 |
d3b4e6250328a518e1a9baf18163dbd1
|
|
| BLAKE2b-256 |
b5f785bfdefa8a67bc938c982e45a777f3bcdebd8da79c05b47359ecbc7d70c7
|
File details
Details for the file gesture_recognizer_widget-0.1.0-py3-none-any.whl.
File metadata
- Download URL: gesture_recognizer_widget-0.1.0-py3-none-any.whl
- Upload date:
- Size: 51.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
970bb76e240a2fd47d271584af0372a3b50c5c36c0c0ea1497e633cc1d1a2360
|
|
| MD5 |
478af64d84a89fb4fe4e78d663b54f09
|
|
| BLAKE2b-256 |
0b320d803931f9ebc2ec2cf2eb09119011958df0c048e97dc7bca7f3b3718141
|