Skip to main content

Fastest MediaPipe-compatible hand tracker: hand landmarks on the Apple Neural Engine at 0.7 ms/frame

Project description

fasthands

The fastest MediaPipe-compatible hand tracker. MediaPipe Hands' official models running on the Apple Neural Engine via CoreML — 0.55 ms per tracked frame on Apple Silicon (1800 FPS), ~6× faster than MediaPipe itself, with a faithful port of the full HandLandmarker pipeline (SSD anchors, weighted NMS, ROI tracking, landmark projection, deduplication).

macOS / Apple Silicon only.

Install

pip install fasthands

Use

import cv2
import fasthands

tracker = fasthands.load(num_hands=1)

image = cv2.cvtColor(cv2.imread("hand.jpg"), cv2.COLOR_BGR2RGB)
hands = tracker(image)                 # single image
# hands = tracker.detect_video(frame)  # video: tracks between frames, ~0.7 ms

for hand in hands:
    print(hand["handedness"], hand["score"])
    print(hand["landmarks"])        # 21 x (x, y, z), normalized image coords
    print(hand["world_landmarks"])  # 21 x (x, y, z), meters, hand-centered

Pipelined streaming (overlaps CPU pre/post with Neural Engine inference, ~15% faster end-to-end — see below):

import cv2, fasthands
tracker = fasthands.load(num_hands=1)
cap = cv2.VideoCapture(0)
def frames():
    while True:
        ok, f = cap.read()
        if not ok: break
        yield f
for frame_bgr, hands in fasthands.stream(tracker, frames()):
    ...  # draw/use hands; this runs concurrently with the next inference

Or from the command line:

fasthands photo.jpg --out annotated.jpg
fasthands-webcam --mirror     # live demo (pipelined) with FPS overlay

Speed (Apple M4, 540×720 frame, one hand)

tracking detect + track
fasthands (ANE) 0.55 ms (1800 FPS) 1.65 ms (600 FPS)
mediapipe (XNNPACK CPU) 3.25 ms (310 FPS) 8.77 ms (115 FPS)
5.9× faster 5.3× faster

Landmarks agree with MediaPipe to ~9e-4 (Neural Engine fp16); the pipeline logic itself is verified to MediaPipe's own float32 reproducibility floor.

How

The hand_landmarker.task models are converted to CoreML, and every MediaPipe calculator in the pipeline (anchors, decode, weighted NMS, rect transforms, rotated crops, projections, VIDEO-mode ROI tracking, dedup) is reimplemented in numpy with float32 op-order fidelity. Model weights © Google, Apache 2.0.

Source, the PyTorch reference implementation, and the full verification harness: https://github.com/VimalMollyn/Mediapipe-Hands-PyTorch-CoreML

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fasthands-0.3.0.tar.gz (5.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fasthands-0.3.0-py3-none-any.whl (5.8 MB view details)

Uploaded Python 3

File details

Details for the file fasthands-0.3.0.tar.gz.

File metadata

  • Download URL: fasthands-0.3.0.tar.gz
  • Upload date:
  • Size: 5.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for fasthands-0.3.0.tar.gz
Algorithm Hash digest
SHA256 17bd943cfedbe5884743c7189b502affff714f9e2bf4a5d34aada502cc33bea0
MD5 6f80ffe0a15311ef06dd6c5a1d0b7285
BLAKE2b-256 958e36fb336f0e52dae432fbf670ab26bc25c8e9bbc676e27bed04f6a9a14295

See more details on using hashes here.

File details

Details for the file fasthands-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: fasthands-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for fasthands-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d9544bcc937cb3a205f638750a79230db42855a0046f8349600cd8ef063d4c6e
MD5 d8150a50eef8bb5b245002cf8e6f36af
BLAKE2b-256 e6637efb15e6bb486856a35d51409230645fe7d4f89ac0d113fefdee266301c8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page