OpenHandTrack — Python
Real-time 3D hand tracking for Python, wrapping MediaPipe's Hand Landmarker
task behind a small, clean API — no fighting mediapipe.tasks internals.
- 21 landmarks per hand (x, y, z), up to 2 hands
- Handedness with confidence, mirrored-camera quirk handled for you
- Gesture helpers (
is_fist,is_open_palm,is_pinch, …) - One-Euro smoothing so the tracking feels solid instead of twitchy
- Auto-downloads the model on first use (cached locally, not in git)
- Works on macOS, Windows, Linux — pure stdlib for model download
Install
python3.12 -m venv .venv
.venv/bin/pip install -e "python/[examples]" # library + example deps
Requires Python 3.11 or 3.12 — MediaPipe does not ship wheels for newer
Pythons yet, so on 3.13+ pip install fails with No matching distribution found for mediapipe. Use a 3.11/3.12 interpreter to create the venv.
Hello world
import cv2
from openhandtrack import HandTracker
cap = cv2.VideoCapture(0)
with HandTracker() as tracker: # model auto-downloads on first run
while True:
ok, frame = cap.read()
if not ok:
break
result = tracker.process(frame) # BGR frame in, clean result out
print(f"{len(result)} hand(s)", *(h.handedness for h in result))
cv2.imshow("tracking", frame)
if cv2.waitKey(1) == ord("q"):
break
cap.release()
result.hands is empty (never an error) when no hand is in frame.
API at a glance
| Symbol | What it is |
|---|---|
HandTracker(max_hands, min_detection_confidence, min_tracking_confidence, running_mode, mirrored) |
The main class. Context manager; running_mode supports "VIDEO" and "LIVE_STREAM". |
HandTracker.process(frame) -> HandResult |
Track one BGR numpy frame. |
HandResult |
.hands, len(), iter(), truthy when a hand is present. |
Hand |
.landmarks (21×Landmark), .handedness ("Left"/"Right"), .confidence, .world_landmarks. |
Landmark |
.x, .y, .z in normalized units. |
LandmarkSmoother(num_hands, min_cutoff, beta, …) |
One-Euro smoothing across frames. smoother.update(result.hands) → smoothed hands. |
OneEuroFilter / ExponentialMovingAverage |
Raw filters, if you want them standalone. |
gestures.finger_states(hand) |
[bool] × 5 per-finger extension flags, thumb → pinky. |
gestures.count_extended_fingers(hand) |
0–5. Rotation-invariant, jitter-stable. |
gestures.is_fist(hand) / is_open_palm(hand) |
Boolean pose checks. |
gestures.is_pinch(hand, threshold) |
(bool, distance) — distance is useful for pinch-to-grab. |
gestures.pinch_distance(hand) |
Thumb↔index gap normalized by hand size. |
gestures.pointing_direction(hand) |
(dx, dy) unit vector of the index finger. |
Full docstrings live in the source (openhandtrack/tracker.py,
smoothing.py, gestures.py) — that's the reference.
The mirrored-camera quirk
MediaPipe labels handedness assuming the input image is mirrored (a
selfie-style webcam feed). HandTracker defaults to mirrored=True to match
the common "mirror your webcam view" setup. If you process unmirrored frames
(rear camera, video files), pass mirrored=False and the labels are swapped
for you. Hold up your right hand: if it reports Left, flip the flag.
Examples
Short, readable projects that reuse this library — see examples/:
air_draw/— pinch to draw in the air, palm to lift, fist to clear; hover the on-screen palette for colours + eraser.finger_count/— counts extended fingers, dots each fingertip.peace_selfie/— hold ✌ for a countdown, savesselfie_N.png.virtual_mouse/— cursor control with the index finger, pinch to click (pynput).air_scroll/— point up/down to scroll pages, fist locks (pynput).pinch_ruler/— live normalized pinch-distance meter; shows why we divide by hand size.two_hand_zoom/— spread/squeeze two hands to zoom; demonstratesmax_hands=2.six_seven_detector/— rainbow-alert meme detector for 6 or 7 fingers.six_seven_detector/— rainbow alert when you hold up six or seven fingers. A meme, but a working one.volume_control/— thumb/index spread controls system volume (with a platform-agnostic mock fallback).presentation_remote/— swipe gestures send arrow keys to your slides.
Tests
.venv/bin/python -m pytest python/
License
Apache-2.0 — same as MediaPipe, so you can build on it freely.
Metadata
Release files for openhandtrack 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| openhandtrack-0.1.4.tar.gz | 25.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| openhandtrack-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 47.0 kB
Release files / openhandtrack-0.1.4.tar.gz
| Download URL | openhandtrack-0.1.4.tar.gz |
|---|---|
| Size | 25.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
75a0b51956e17ae77a4d7f782d6b202a243bf0739f370e46bbe171e5cc7ce965
|
|
BLAKE2b-256 checksum How to use checksums |
8992e32bafb01db11d8bca4f47494600e880b5b4cf62b6559d4174263e621886
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 23, 2026.
Transparency logRelease files / openhandtrack-0.1.4-py3-none-any.whl
| Download URL | openhandtrack-0.1.4-py3-none-any.whl |
|---|---|
| Size | 21.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bb0f1bbdfe0a7df88d882ae49979656937f94a7374373b02f7d792313bb45dc4
|
|
BLAKE2b-256 checksum How to use checksums |
4e37994065b50d9f77d25874bbb2ba41b4e40ecb7021d3e16bce1e0175d097f1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 23, 2026.
Transparency log