Hand Mask Node ππ ‘π £π
Turn MediaPipe's 21 Hand Points Into a Mask of Just the Thumb (or the Whole Fist)
- image
- hand_data
- IMAGE
- MASK
Hand tracking gives you a skeleton, but skeletons don't composite over video. What you actually want for real-time work is a cut-out - a mask of the hand you can blur, tint, replace, or gate an effect on. Hand Mask Node is the bridge between MediaPipe's 21 landmarks and a usable MASK.
It consumes the HAND_DATA output from this pack's Hand Tracking Node and builds a filled mask from the landmarks. The clever part is mask_type. Pick full_hand and it computes the convex hull of all 21 points - a chunky silhouette of the whole hand. Pick palm_only and it uses just the wrist and the five knuckle bases (landmarks 0, 1, 5, 9, 13, 17) to isolate the palm. Or go granular: fingers_only masks all five fingers, and thumb, index, middle, ring, pinky give you a single finger each - those use the classic MediaPipe finger index ranges (thumb 1β4, index 5β8, middle 9β12, ring 13β16, pinky 17β20).
Mechanically it's OpenCV doing what OpenCV is good at: scale the normalized landmarks to the image dimensions, take a convexHull of the selected points, and fillConvexPoly it into a zeroed mask. It loops over both detected hands, so a two-hand frame gets both silhouettes. If no hands are present, you get an empty (all-black) mask rather than an error - which is the right behavior when the output drives a gate.
Inputs and outputs
- image - the frame you tracked. It's passed through unchanged.
- hand_data - the
HAND_DATAfrom Hand Tracking Node. This is not an image; don't try to feed the debug image. - mask_type - the eight-choice enum above. This is the whole show.
Outputs are IMAGE (your input, untouched) and MASK. That passthrough is convenient: one branch of your graph gets the original frame, the other gets the hand cut-out, and you don't need a separate reroute.
What to use it for
Real-time compositing mostly. Hand masks are great for painting "your hand is the subject" effects onto a live stream - the kind of thing you see in the pack's motion-detection demos. They also make decent inpainting masks if you're regenerating just the hand region. One honest caveat: these are hard-edged filled polygons, not soft alpha mattes. There's no feathering, no anti-aliasing. If you need a soft edge, blur the mask downstream - a small Gaussian is enough.
Install & gotchas
Same pack, same route: ryanontheinside/ComfyUI_RealtimeNodes via ComfyUI Manager, or
cd ComfyUI/custom_nodes
git clone https://github.com/ryanontheinside/ComfyUI_RealtimeNodes
cd ComfyUI_RealtimeNodes
pip install -r requirements.txt
Two things to know. The hand pipeline is built on the legacy MediaPipe solutions API, and it downloads the hand-landmark model (~5 MB) automatically on first run - no manual model fetch, but the first frame will hang for a second. And the whole hand-tracking feature is explicitly marked experimental in the source, so treat it as "works, but young." If your mask looks like it's in the wrong place, double-check that the input image and the frame the hand data was computed from are the same size and aspect ratio - the landmarks are normalized, so a mismatch scales them wrong.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | β | |
| hand_data | HAND_DATA | β | |
| mask_type | COMBO | 8 options: full_hand, palm_only, fingers_only, thumb, index, middle, +2 |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | β |
| MASK | MASK | β |