tasks-vision package

Classes

Class Description
DrawingUtils Helper class to visualize the result of a MediaPipe Vision task.
FaceDetector Performs face detection on images.
FaceLandmarker Performs face landmarks detection on images. This API expects a pre-trained face landmarker model asset bundle.
FilesetResolver Resolves the files required for the MediaPipe Task APIs. The returned filesets require that the Wasm files are published without renaming. If this is not possible, you can invoke the MediaPipe Tasks APIs using a manually created WasmFileset.
GestureRecognizer Performs hand gesture recognition on images.
HandLandmarker Performs hand landmarks detection on images.
HolisticLandmarker Performs holistic landmarks detection on images.
ImageClassifier Performs classification on images.
ImageEmbedder Performs embedding extraction on images.
ImageSegmenter Performs image segmentation on images.
ImageSegmenterResult The output result of ImageSegmenter.
InteractiveSegmenter Performs interactive segmentation on images using split mode architecture. Interactive Segmenter splits segmentation into two distinct steps: 1. Set an image with setImage() (executes heavy feature extraction once). 2. Segment with segment() one or more times efficiently providing strokes, allowing the user to fine tune the produced segmentation mask.
InteractiveSegmenterLegacy Performs interactive segmentation on images. Users can represent user interaction through RegionOfInterest, which gives a hint to InteractiveSegmenterLegacy to perform segmentation focusing on the given region of interest. The API expects a TFLite model with mandatory TFLite Model Metadata. Input tensor: (kTfLiteUInt8/kTfLiteFloat32) - image input of size [batch x height x width x channels]. - batch inference is not supported (batch is required to be 1). - RGB inputs is supported (channels is required to be 3). - if type is kTfLiteFloat32, NormalizationOptions are required to be attached to the metadata for input normalization. Output tensors: (kTfLiteUInt8/kTfLiteFloat32) - list of segmented masks. - if output_type is CATEGORY_MASK, uint8 Image, Image vector of size 1. - if output_type is CONFIDENCE_MASK, float32 Image list of size channels. - batch is always 1
InteractiveSegmenterLegacyResult The output result of InteractiveSegmenterLegacy.
MPImage The wrapper class for MediaPipe Image objects. Images are stored as ImageData, ImageBitmap or WebGLTexture objects. You can convert the underlying type to any other type by passing the desired type to getAs...(). As type conversions can be expensive, it is recommended to limit these conversions. You can verify what underlying types are already available by invoking has...(). Images that are returned from a MediaPipe Tasks are owned by by the underlying C++ Task. If you need to extend the lifetime of these objects, you can invoke the clone() method. To free up the resources obtained during any clone or type conversion operation, it is important to invoke close() on the MPImage instance. Converting to and from ImageBitmap requires that the MediaPipe task is initialized with an OffscreenCanvas. As we require WebGL2 support, this places some limitations on Browser support as outlined here: https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas/getContext
MPMask The wrapper class for MediaPipe segmentation masks. Masks are stored as Uint8Array, Float32Array or WebGLTexture objects. You can convert the underlying type to any other type by passing the desired type to getAs...(). As type conversions can be expensive, it is recommended to limit these conversions. You can verify what underlying types are already available by invoking has...(). Masks that are returned from a MediaPipe Tasks are owned by by the underlying C++ Task. If you need to extend the lifetime of these objects, you can invoke the clone() method. To free up the resources obtained during any clone or type conversion operation, it is important to invoke close() on the MPMask instance.
ObjectDetector Performs object detection on images.
PoseLandmarker Performs pose landmarks detection on images.
PoseLandmarkerResult Represents the pose landmarks deection results generated by PoseLandmarker. Each vector element represents a single pose detected in the image.
TaskRunner Base class for all MediaPipe Tasks.
VisionTaskRunner Base class for all MediaPipe Vision Tasks.

Enumerations

Enumeration Description
BrushMode Specifies the polarity or mode of a brush stroke. Represents whether the brush stroke is meant to add, subtract, or lasso from the selection.

Interfaces

Interface Description
BaseOptions Options to configure MediaPipe model loading and processing.
BoundingBox An integer bounding box, axis aligned.
Category A classification category.
Classifications Classification results for a given classifier head.
ClassifierOptions Options to configure a MediaPipe Classifier Task.
Connection A connection between two landmarks.
Detection Represents one detection by a detection task.
DetectionResult Detection results of a model.
DrawingOptions Options for customizing the drawing routines
EmbedderOptions Options to configure a MediaPipe Embedder Task
Embedding List of embeddings with an optional timestamp. One and only one of the two 'floatEmbedding' and 'quantizedEmbedding' will contain data, based on whether or not the embedder was configured to perform scalar quantization.
FaceDetectorOptions Options to configure the MediaPipe Face Detector Task
FaceDetectorResult Detection results of a model.
FaceLandmarkerOptions Options to configure the MediaPipe FaceLandmarker Task
FaceLandmarkerResult Represents the face landmarks deection results generated by FaceLandmarker.
GestureRecognizerOptions Options to configure the MediaPipe Gesture Recognizer Task
GestureRecognizerResult Represents the gesture recognition results generated by GestureRecognizer.
HandLandmarkerOptions Options to configure the MediaPipe HandLandmarker Task
HandLandmarkerResult Represents the hand landmarks deection results generated by HandLandmarker.
HolisticLandmarkerOptions Options to configure the MediaPipe HolisticLandmarker Task
HolisticLandmarkerResult Represents the holistic landmarks detection results generated by HolisticLandmarker.
ImageClassifierOptions Options to configure the MediaPipe Image Classifier Task.
ImageClassifierResult Classification results of a model.
ImageEmbedderOptions Options for configuring a MediaPipe Image Embedder task.
ImageEmbedderResult Embedding results for a given embedder model.
ImageProcessingOptions Options for image processing. If both region-or-interest and rotation are specified, the crop around the region-of-interest is extracted first, then the specified rotation is applied to the crop.
ImageSegmenterOptions Options to configure the MediaPipe Image Segmenter Task
InteractiveSegmenterLegacyOptions Options to configure the MediaPipe Interactive Segmenter Task
InteractiveSegmenterOptions Options to configure the MediaPipe Interactive Segmenter Task.
InteractiveSegmenterWasmModule The WasmModule interface for Interactive Segmenter, defining the native methods exported by the C++ WebAssembly wrapper.
Landmark Landmark represents a point in 3D space with x, y, z coordinates. The landmark coordinates are in meters. z represents the landmark depth, and the smaller the value the closer the world landmark is to the camera.
LandmarkData Data that a user can use to specialize drawing options.
Matrix A two-dimensional matrix.
NormalizedKeypoint A keypoint, defined by the coordinates (x, y), normalized by the image dimensions.
NormalizedLandmark Normalized Landmark represents a point in 3D space with x, y, z coordinates. x and y are normalized to [0.0, 1.0] by the image width and height respectively. z represents the landmark depth, and the smaller the value the closer the landmark is to the camera. The magnitude of z uses roughly the same scale as x.
ObjectDetectorOptions Options to configure the MediaPipe Object Detector Task
ObjectDetectorResult Detection results of a model.
Point Represents a single 2D coordinate point in normalized [0, 1] space.
PoseLandmarkerOptions Options to configure the MediaPipe PoseLandmarker Task
RectF Defines a rectangle, used e.g. as part of detection results or as input region-of-interest. The coordinates are normalized with respect to the image dimensions, i.e. generally in [0,1] but they may exceed these bounds if describing a region overlapping the image. The origin is on the top-left corner of the image.
RegionOfInterest A Region-Of-Interest (ROI) to represent a region within an image.
Stroke Represents a single user-drawn stroke for interactive segmentation.
TaskRunnerOptions Options to configure MediaPipe Tasks in general.
VisionTaskOptions The options for configuring a MediaPipe vision task.
WasmFileset An object containing the locations of the Wasm assets
WasmModule Declarations for Emscripten's WebAssembly Module behavior, so TS compiler doesn't break our various JS/C++ bridges. For internal usage.

Variables

Variable Description
DEFAULT_CATEGORY_TO_COLOR_MAP A color map with 22 classes. Used in our demos.

Type Aliases

Type Alias Description
Callback A user-defined callback to take input data and map it to a custom output value.
CategoryToColorMap A category to color mapping that uses either a map or an array to assign category indexes to RGBA colors.
EmptyPacketListener A listener that receives the current MediaPipe packet timestamp. This is invoked even for empty packet.
ErrorListener A listener that will be invoked with an absl::StatusCode and message.
HolisticLandmarkerCallback A callback that receives the result from the holistic landmarker detection. The returned result are only valid for the duration of the callback. If asynchronous processing is needed, the masks need to be copied before the callback returns.
ImageSegmenterCallback A callback that receives the computed masks from the image segmenter. The returned data is only valid for the duration of the callback. If asynchronous processing is needed, all data needs to be copied before the callback returns.
ImageSource Valid types of image sources which we can run our GraphRunner over.
InteractiveSegmenterLegacyCallback A callback that receives the computed masks from the interactive segmenter. The returned data is only valid for the duration of the callback. If asynchronous processing is needed, all data needs to be copied before the callback returns.
PoseLandmarkerCallback A callback that receives the result from the pose detector. The returned masks are only valid for the duration of the callback. If asynchronous processing is needed, the masks need to be copied before the callback returns.
RGBAColor A four channel color with values for red, green, blue and alpha respectively.
RunningMode The two running modes of a vision task. 1) The image mode for processing single image inputs. 2) The video mode for processing decoded frames of a video.
SimpleListener A listener that receives the contents of a non-empty MediaPipe packet and its timestamp.
VectorListener A listener that receives a single element of vector-returning output packet. Receives one element at a time (in order). Once all elements are processed, the listener is invoked with data set to unknown and done set to true. Intended for internal usage.

BrushMode

Specifies the polarity or mode of a brush stroke. Represents whether the brush stroke is meant to add, subtract, or lasso from the selection.

Signature:

export declare enum BrushMode

DEFAULT_CATEGORY_TO_COLOR_MAP

A color map with 22 classes. Used in our demos.

Signature:

export declare const DEFAULT_CATEGORY_TO_COLOR_MAP: number[][];

Callback

A user-defined callback to take input data and map it to a custom output value.

Signature:

export declare type Callback<I, O> = (input: I) => O;

CategoryToColorMap

A category to color mapping that uses either a map or an array to assign category indexes to RGBA colors.

Signature:

export declare type CategoryToColorMap = Map<number, RGBAColor> | RGBAColor[];

EmptyPacketListener

A listener that receives the current MediaPipe packet timestamp. This is invoked even for empty packet.

Signature:

declare type EmptyPacketListener = (timestamp: number) => void;

ErrorListener

A listener that will be invoked with an absl::StatusCode and message.

Signature:

declare type ErrorListener = (code: number, message: string) => void;

HolisticLandmarkerCallback

A callback that receives the result from the holistic landmarker detection. The returned result are only valid for the duration of the callback. If asynchronous processing is needed, the masks need to be copied before the callback returns.

Signature:

export declare type HolisticLandmarkerCallback = (result: HolisticLandmarkerResult) => void;

ImageSegmenterCallback

A callback that receives the computed masks from the image segmenter. The returned data is only valid for the duration of the callback. If asynchronous processing is needed, all data needs to be copied before the callback returns.

Signature:

export declare type ImageSegmenterCallback = (result: ImageSegmenterResult) => void;

ImageSource

Valid types of image sources which we can run our GraphRunner over.

Signature:

export declare type ImageSource = TexImageSource;

InteractiveSegmenterLegacyCallback

A callback that receives the computed masks from the interactive segmenter. The returned data is only valid for the duration of the callback. If asynchronous processing is needed, all data needs to be copied before the callback returns.

Signature:

export declare type InteractiveSegmenterLegacyCallback = (result: InteractiveSegmenterLegacyResult) => void;

PoseLandmarkerCallback

A callback that receives the result from the pose detector. The returned masks are only valid for the duration of the callback. If asynchronous processing is needed, the masks need to be copied before the callback returns.

Signature:

export declare type PoseLandmarkerCallback = (result: PoseLandmarkerResult) => void;

RGBAColor

A four channel color with values for red, green, blue and alpha respectively.

Signature:

export declare type RGBAColor = [ number, number, number, number ] | number[];

RunningMode

The two running modes of a vision task. 1) The image mode for processing single image inputs. 2) The video mode for processing decoded frames of a video.

Signature:

declare type RunningMode = "IMAGE" | "VIDEO";

SimpleListener

A listener that receives the contents of a non-empty MediaPipe packet and its timestamp.

Signature:

declare type SimpleListener<T> = (data: T, timestamp: number) => void;

VectorListener

A listener that receives a single element of vector-returning output packet. Receives one element at a time (in order). Once all elements are processed, the listener is invoked with data set to unknown and done set to true. Intended for internal usage.

Signature:

declare type VectorListener<T> = (data: T, done: boolean, timestamp: number) => void;