Skip to main content

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.count_extended_fingers(hand) 0–5.
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.
  • 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.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openhandtrack 0.1.2
File Size Uploaded
openhandtrack-0.1.2.tar.gz 23.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for openhandtrack 0.1.2
File Interpreter ABI Platform
openhandtrack-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 44.2 kB

Release files / openhandtrack-0.1.2.tar.gz

Download URL openhandtrack-0.1.2.tar.gz
Size 23.4 kB
Tags Source
SHA-256 checksum
How to use checksums
da61c0adfc2b9c0c5ed451ed9d87ccaf4bcd0be4cef8c43ea60ed000a2d2027c
BLAKE2b-256 checksum
How to use checksums
26a09ddc6bea6376459952478bd39f5195f863f9ce94a5b71e6840cc89b98fd0
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 21, 2026.

Transparency log

Release files / openhandtrack-0.1.2-py3-none-any.whl

Download URL openhandtrack-0.1.2-py3-none-any.whl
Size 20.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d3064bd21029b47bb5733030514cd630060639903f6a72c89b76c693b17e3731
BLAKE2b-256 checksum
How to use checksums
4922c029af1e99d49bf011dc8b2a58498c6960061be755ed1167e5df42afceeb
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 21, 2026.

Transparency log

Release history Release notifications | RSS feed

0.1.4

2 release files

0.1.3

2 release files

This release

0.1.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page