MpFaceTrackingMultiElement Op

MpFaceTrackingMultiElement

Get face mesh from webcam/video using mediapipe library


read more on the mediapipe project page: https://chuoling.github.io/mediapipe/solutions/face_mesh.html

some info about the mesh data: https://github.com/lysdexic-audio/n4m-facemesh

Overview of Improvements markdown_content = """# FaceMesh Operator: Multi-Face Tracking Documentation Update

Overview of Improvements

The upgraded operator transitions from a single-face tracking prototype to a production-ready, multi-face tracking node with improved frame scheduling, coordinate stabilization, and resource cleanup.

  • Simultaneous Multi-Face Tracking: Tracks up to $N$ faces simultaneously instead of hardcoding detection to a single face.
  • Spatial Index Sorting: Eliminates index-swapping jitter across frames by sorting detected faces along the X-axis.
  • Bounding Box Generation: Computes normalized 2D bounding boxes (center X/Y, width, height) in real time for each detected face.
  • Custom Render Loop & State Protection: Replaces the third-party Camera utility with an asynchronous requestAnimationFrame loop featuring concurrency gating (isProcessing) and video readyState checks to prevent MediaPipe freezes.
  • Lifecycle & Memory Management: Implements op.onDelete to cancel active animation frames and call faceMesh.close(), preventing WebAssembly (WASM) memory leaks on operator recompilation or deletion.

New Input Parameters

  • Max Faces (inMaxFaces | Integer, default: 4): Defines the maximum number of faces MediaPipe should detect and track simultaneously.
  • Min Detection Confidence (inMinConfidence | Float Slider, default: 0.5): Sets the minimum confidence score ($[0.0, 1.0]$) for the face detection model to consider a detection successful.
  • Min Tracking Confidence (inMinTracking | Float Slider, default: 0.5): Sets the minimum confidence score ($[0.0, 1.0]$) for landmark tracking; higher values reduce jitter but drop fast-moving faces.
  • Sort Faces (L to R) (inSortFaces | Boolean, default: true): Orders output arrays from left to right based on face center X coordinates, preventing target index swapping when people shift positions.
  • Flip X (inFlipX | Boolean, default: false): Inverts coordinates along the horizontal axis, providing mirrored mapping suitable for standard selfie/webcam feeds.

Output Changes

  • Points (outPoints | Array): Now outputs an array of point arrays (allPoints[faceIndex]), where each nested array contains the normalized 3D coordinates $(x, y, 0)$ for that face.
  • Bounding Boxes (outBoxes | Array): Emits an array of 4D bounding boxes formatted as [centerX, centerY, boxWidth, boxHeight] for each detected face.
  • Found Faces (outFound | Number): Outputs the total number of faces successfully identified in the current frame.


Full Name
  • Ops.Patch.PR5Jn1t.MpFaceTrackingMultiElement
VisibilityLicense
  • MIT
AuthorCreated
  • Aug 22, 2026 at 13:00
Dependencies
  • mp_face.js (commonjs)



Multi Face Tracking Bounding box & video Element

Multiface tracking Op with bounding box and videoTextureElement Op example

Open In Editor

INPUT PORTS


Element (Object)

Source webcam/video as HTML element

Max Faces (Number: integer)

Maximum number of faces to detect simultaneously in the frame

Min Detection Confidence (Number)

Minimum confidence threshold required to successfully detect a new face

Min Tracking Confidence (Number)

Minimum confidence threshold required to maintain tracking on an existing face across frames

Sort Faces (L to R) (Number: boolean)

Automatically sorts detected faces from left to right to prevent index swapping between frames

Refine LandMarks (Number: boolean)

Enables detailed eyes and lips landmarks and adds landmarks for iris

Flip X (Number: boolean)

Horizontally mirrors the output coordinates and bounding boxes

OUTPUT PORTS


Result (Object)
Found Faces (Number)
Points (Array)
Bounding Boxes (Array)

Changelog

Patches using MpFaceTrackingMultiElement

  • Examples
  • Public
  • My Patches