MPPMask
@interface MPPMask : NSObject <NSCopying>
The wrapper class for MediaPipe segmentation masks.
Masks are stored as UInt8 *
or float *
objects.
Every mask has an underlying type which can be accessed using dataType
. You can access the
mask as any other type using the appropriate properties. For example, if the underlying type is
uInt8
, in addition to accessing the mask using uint8Data
, you can access float32Data
to get
the 32 bit float data (with values ranging from 0.0 to 1.0). The first time you access the data
as a type different from the underlying type, an expensive type conversion is performed.
Subsequent accesses return a pointer to the memory location for the same type converted array. As
type conversions can be expensive, it is recommended to limit the accesses to data of types
different from the underlying type.
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 copy()
method.
-
The width of the mask.
Declaration
Objective-C
@property (nonatomic, readonly) NSInteger width;
-
The height of the mask.
Declaration
Objective-C
@property (nonatomic, readonly) NSInteger height;
-
The data type of the mask.
Declaration
Objective-C
@property (nonatomic, readonly) MPPMaskDataType dataType;
-
The pointer to the memory location where the underlying mask as a single channel
UInt8
array is stored. Uint8 values use the full value range and range from 0 to 255.Declaration
Objective-C
@property (nonatomic, readonly) const UInt8 *_Nonnull uint8Data;
-
The pointer to the memory location where the underlying mask as a single channel float 32 array is stored. Float values range from 0.0 to 1.0.
Declaration
Objective-C
@property (nonatomic, readonly) const float *_Nonnull float32Data;
-
Initializes an
Mask
object of typeuInt8
with the givenUInt8*
data, width and height.If
shouldCopy
is set totrue
, the newly creat