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
UInt8array 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
Maskobject of typeuInt8with the givenUInt8*data, width and height.If
shouldCopyis set totrue, the newly createdMaskstores a reference to a deep copieduint8Data. Since deep copies are expensive, it is recommended to not setshouldCopyunless theMaskmust outlive the passed inuint8Data.Declaration
Objective-C
- (nullable instancetype)initWithUInt8Data:(nonnull const UInt8 *)uint8Data width:(NSInteger)width height:(NSInteger)height shouldCopy:(BOOL)shouldCopy;Parameters
uint8DataA pointer to the memory location of the
UInt8data array.widthThe width of the mask.
heightThe height of the mask.
shouldCopyThe height of the mask.
Return Value
A new
Maskinstance with the givenUInt8*data, width and height. -
Initializes an
Maskobject of typefloat32with the givenfloat*data, width and height.If
shouldCopyis set totrue, the newly createdMaskstores a reference to a deep copiedfloat32Data. Since deep copies are expensive, it is recommended to not setshouldCopyunless theMaskmust outlive the passed infloat32Data.Declaration
Objective-C
- (nullable instancetype)initWithFloat32Data:(nonnull const float *)float32Data width:(NSInteger)width height:(NSInteger)height shouldCopy:(BOOL)shouldCopy;Parameters
float32DataA pointer to the memory location of the
floatdata array.widthThe width of the mask.
heightThe height of the mask.
Return Value
A new
Maskinstance with the givenfloat*data, width and height. -
Unavailable.
Declaration
Objective-C
- (nonnull instancetype)init; -
Undocumented
Declaration
Objective-C
+ (instancetype)new NS_UNAVAILABLE;