MPMask
Wrapper for a mask produced by a Segmentation Task.
Properties
Methods
clone()
clone(): MPMask;
Creates a copy of the resources stored in this MPMask. You can
invoke this method to extend the lifetime of a mask returned by a
MediaPipe Task. Note that performance critical applications should aim to
only use the MPMask within the MediaPipe Task callback so that
copies can be avoided.
Returns
MPMask
close()
close(): void;
Frees up any resources owned by this MPMask instance.
Note that this method does not free masks that are owned by the C++
Task, as these are freed automatically once you leave the MediaPipe
callback. Additionally, some shared state is freed only once you invoke
the Task's close() method.
Returns
void
Export
getAsFloat32Array()
getAsFloat32Array(): Float32Array;
Returns the underlying mask as a single channel Float32Array. Note that
this involves an expensive GPU to CPU transfer if the current mask is
only available as a WebGLTexture.
Returns
Float32Array
The current mask as a Float32Array.
getAsUint8Array()
getAsUint8Array(): Uint8Array;
Returns the underlying mask as a Uint8Array. Note that this involves an expensive GPU to CPU transfer if the current mask is only available as a WebGLTexture`.
Returns
Uint8Array
The current data as a Uint8Array.
getAsWebGLTexture()
getAsWebGLTexture(): WebGLTexture;
Returns the underlying mask as a WebGLTexture object. Note that this
involves a CPU to GPU transfer if the current mask is only available as
a CPU array. The returned texture is bound to the current canvas (see
.canvas).
Returns
WebGLTexture
The current mask as a WebGLTexture.
hasFloat32Array()
hasFloat32Array(): boolean;
Returns whether this MPMask contains a mask of type Float32Array.
Returns
boolean
hasUint8Array()
hasUint8Array(): boolean;
Returns whether this MPMask contains a mask of type Uint8Array.
Returns
boolean
hasWebGLTexture()
hasWebGLTexture(): boolean;
Returns whether this MPMask contains a mask of type WebGLTexture.
Returns
boolean