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; hover the on-screen palette for colours + eraser.
  • finger_count/ — counts extended fingers, dots each fingertip.
  • peace_selfie/ — hold ✌ for a countdown, saves selfie_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; demonstrates max_hands=2.
  • 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.3

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.3
File Size Uploaded
openhandtrack-0.1.3.tar.gz 24.1 kB Details

Built distribution (wheel)

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

Total release size: 45.1 kB

Release files / openhandtrack-0.1.3.tar.gz

Download URL openhandtrack-0.1.3.tar.gz
Size 24.1 kB
Tags Source
SHA-256 checksum
How to use checksums
bc74f8e2d39a1a7f492f9c80d67c57922037c5923b057a6fca49998409d46a1f
BLAKE2b-256 checksum
How to use checksums
0ff9b141c9274ec511958e1982330dd262fa413c4d56816a226f643e6f178c23
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 22, 2026.

Transparency log

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

Download URL openhandtrack-0.1.3-py3-none-any.whl
Size 21.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dbbbb3138000bc5cdc1ef733c7ec1b46b99f8d42f2decf4d228dca64863d571b
BLAKE2b-256 checksum
How to use checksums
278223185410f1682855a881442129049f7fedd1a7e72b0cef0ea2014208a849
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 22, 2026.

Transparency log

Release history Release notifications | RSS feed

0.1.4

2 release files

This release

0.1.3 This release

2 release files

0.1.2

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