Vision Hands β€” HandPortal

Stretch a portal between your fingertips β€” reality gets a different skin inside. Hold up both hands and an energy-rimmed portal stretches between your index fingertips; everything inside the portal is replaced with a processed version of itself. Pinch thumb and index finger on either hand to cycle through the effects. Built by Noorullah Zamindar β€” original app at NoorullahZamindar-007/vision-hands.

This is a hand-tracking application, not a trained neural network of his own. There are no weights trained by Noorullah and no training data. The "model" is MediaPipe's pre-trained HandLandmarker (hand_landmarker.task, Google's model, shipped in this repo) plus his application code β€” the 8 effects, the portal renderer, the pinch-gesture state machine, the quad smoothing and the HUD β€” taken from his vision-hands repository (version 1.1.0) and packaged so it can run and be tested without a webcam.

All 8 effects

Portal before / after

The 8 effects

# Effect What it does
1 Thermal Infrared heat-map colorization (JET colormap)
2 Edge Mesh Canny edges on a dark void β€” wireframe reality
3 Posterize Neon Quantized color bands with cranked saturation
4 Invert Glitch Inverted colors with per-channel shift
5 Sketch Pencil-drawing dodge-burn
6 Chromatic RGB channel separation β€” lens aberration
7 Pixel Mosaic Chunky pixel-art downscale with visible seams
8 Duotone Luminance mapped onto a deep-indigo β†’ electric-cyan ramp

How it works

  1. The webcam frame (1280Γ—720) goes to MediaPipe's HandLandmarker (up to 2 hands, 21 landmarks each).
  2. The two index fingertips (landmark 8) are the diagonal corners of an axis-aligned bounding box β€” the portal. The box is cropped, the effect is applied to the crop completely undistorted (never perspective-warped), pasted back and masked to the portal shape with a feathered edge.
  3. Pinch detection reads thumb tip (landmark 4) and index tip directly and uses an armed/disarmed edge trigger with hysteresis (enter 0.055, release 0.070), so holding a pinch fires exactly once.
  4. The portal quad is smoothed with an exponential moving average (alpha 0.35); the rim has a pulsing glow, corner-bracket accents, energy particles and a cinematic vignette.

Controls: pinch (either hand) cycles effects; 1–8 jump to an effect; f fullscreen; s screenshot; d downscaled detection; v vignette; +/- pinch sensitivity; r reset sensitivity; q quit.

How to use

Webcam app (needs a camera):

pip install -r requirements.txt
pip install -e .
handportal

On first launch the MediaPipe hand landmark model (~7 MB) is downloaded automatically and verified with SHA-256 before use; it is already shipped in this repo as hand_landmarker.task, so no download is needed. Run handportal --help for the camera, size and threshold flags.

As a library (no camera needed):

from handportal import PinchTrigger, ensure_model, thermal

model_path = ensure_model("hand_landmarker.task")  # checksum-verified

trigger = PinchTrigger()
for distance in pinch_distances:  # thumb-tip to index-tip per frame
    if trigger.update([distance]):
        print("pinch started")  # fires once per pinch

stylized = thermal(frame)  # any of the 8 effects works on a plain BGR frame

Measured results

Everything below was measured with evaluate.py (run it to reproduce) on Python 3.12.3, OpenCV 5.1.0, MediaPipe 1.2.3, NumPy 2.5.5, Pillow 13.0.0. Note: requirements.txt pins MediaPipe 0.10.x, the version the app targets; the evaluation ran on 1.2.3 and the APIs used here are unchanged between them. Timings are approximate β€” they vary run to run on the shared-CPU machine they were measured on.

The 8 effects on a 1280Γ—720 test frame

Mean absolute per-pixel difference vs the input, fraction of pixels changed, and time per frame (mean of 10 runs after warmup):

Effect Mean abs diff Pixels changed ms / frame
Thermal 72.969 100% ~1.1
Edge Mesh 110.961 99.9% ~15
Posterize Neon 30.241 100% ~19
Invert Glitch 84.655 100% ~1.0
Sketch 118.713 99.4% ~1.6
Chromatic 18.117 99.9% ~21
Pixel Mosaic 20.438 100% ~11
Duotone 45.666 100% ~20

Every effect preserves the frame shape and uint8 dtype.

Portal compositing

Fingertips at normalized (0.30, 0.30) and (0.70, 0.65) on a 1280Γ—720 frame give the quad (384, 216) β†’ (896, 468). Rendering the Thermal effect into it:

  • 100% of pixels inside the quad changed; 1.17% outside it changed β€” that is the feathered edge band, which blends a few pixels past the quad boundary by design.
  • alpha=0 leaves the frame byte-identical (portal fully hidden); crossfading halfway between Thermal and Edge Mesh differs from full Thermal by a mean of 9.602 per pixel.
  • Rim glow + corner accents change 4.54% of the frame, concentrated around the portal.
  • Vignette layer: corners 201 vs centre 255 (mean brightness, 0–255).
  • A NaN fingertip landmark returns no quad for that frame instead of rendering garbage; the quad smoother (EMA, alpha 0.5) maps 0 β†’ 10 to 5.0, and a NaN frame keeps the last good quad.

Pinch trigger

For the distance sequence 0.10, 0.04, 0.04, 0.04, 0.08, 0.04, NaN, 0.04, 0.10, 0.04 the trigger fired at indices 1, 5, 7 and 9: it fires once per pinch, holding the pinch does not re-fire, and a NaN reading is dropped and treated like a missing hand β€” so it re-arms the trigger and a pinch on the next good frame fires again. adjust() / reset() restore the 0.055 / 0.070 defaults.

Hand detection on real photos

MediaPipe HandLandmarker with the shipped hand_landmarker.task (SHA-256 verified, matches the checksum in handportal/model.py) on two CC BY-SA 4.0 Wikimedia Commons palm photos:

Photo Hands Landmarks Handedness Score
samples/palm_left.jpg 1 21 Left 0.959
samples/palm_right.png 1 21 Right 0.927

Controls: a blank image and a random-noise image both detect 0 hands. A missing model file raises a clear RuntimeError instead of failing silently. Annotated versions of both photos are in samples/.

Repo test suite

The repository's own webcam-independent test suite: 73 passed, 0 failed (python -m pytest tests, after pip install -e .).

Files

  • portal_app.py β€” the webcam app: portal rendering, glow, particles, vignette, HUD, main loop (his code, unchanged).
  • handportal/ β€” effects.py (the 8 effects), gestures.py (PinchTrigger), model.py (verified model download), config.py, cli.py.
  • hand_landmarker.task (7.8 MB) β€” Google's pre-trained MediaPipe HandLandmarker, SHA-256 fbc2a30080c3c557093b5ddfc334698132eb341044ccee322ccf8bcf3607cde1.
  • evaluate.py, metrics.json β€” the evaluation that produced every number above; run python evaluate.py to reproduce it (needs OpenCV + MediaPipe).
  • tests/ β€” the repo's own test suite.
  • samples/ β€” the 8-effect grid, a portal before/after, the two palm photos and their landmark-annotated versions.

Limitations

  • The live webcam app was NOT tested end to end β€” there is no webcam in the evaluation environment, so the camera loop, fullscreen mode, screenshots and the HUD animation were exercised only through the repo's headless tests, not by running the app on a real camera.
  • The hand model is Google's pre-trained MediaPipe model, not trained by Noorullah; this repo contains no trained weights of his own.
  • The portal needs two hands in view (two index fingertips); with one hand there is no portal.
  • Pinch detection depends on landmark quality; a glitchy (NaN) landmark frame is treated as a missing hand.
  • Effect timings depend on the machine; the numbers above are from a shared-CPU VM.

License

MIT β€” see LICENSE. Palm photos in samples/ are CC BY-SA 4.0 (Wikimedia Commons), as in the original evaluation.

Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support