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 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.
Initializes an Mask object of type uInt8 with the given UInt8* data, width and height.
If shouldCopy is set to true, the newly created Mask stores a reference to a deep copied
uint8Data. Since deep copies are expensive, it is recommended to not set shouldCopy unless
the Mask must outlive the passed in uint8Data.
Initializes an Mask object of type float32 with the given float* data, width and height.
If shouldCopy is set to true, the newly created Mask stores a reference to a deep copied
float32Data. Since deep copies are expensive, it is recommended to not set shouldCopy unless
the Mask must outlive the passed in float32Data.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-05-08 UTC."],[],[],null,["# MediaPipeTasksVision Framework Reference\n\nMask\n====\n\n class Mask : NSObject, NSCopying\n\nThe wrapper class for MediaPipe segmentation masks.\n\nMasks are stored as `UInt8 *` or `float *` objects.\nEvery mask has an underlying type which can be accessed using `dataType`. You can access the\nmask as any other type using the appropriate properties. For example, if the underlying type is\n`uInt8`, in addition to accessing the mask using `uint8Data`, you can access `float32Data` to get\nthe 32 bit float data (with values ranging from 0.0 to 1.0). The first time you access the data\nas a type different from the underlying type, an expensive type conversion is performed.\nSubsequent accesses return a pointer to the memory location for the same type converted array. As\ntype conversions can be expensive, it is recommended to limit the accesses to data of types\ndifferent from the underlying type.\n\nMasks that are returned from a MediaPipe Tasks are owned by by the underlying C++ Task. If you\nneed to extend the lifetime of these objects, you can invoke the `copy()` method.\n- `\n ``\n ``\n `\n\n ### [width](#/c:objc(cs)MPPMask(py)width)\n\n `\n ` \n The width of the mask. \n\n #### Declaration\n\n Swift \n\n var width: Int { get }\n\n- `\n ``\n ``\n `\n\n ### [height](#/c:objc(cs)MPPMask(py)height)\n\n `\n ` \n The height of the mask. \n\n #### Declaration\n\n Swift \n\n var height: Int { get }\n\n- `\n ``\n ``\n `\n\n ### [dataType](#/c:objc(cs)MPPMask(py)dataType)\n\n `\n ` \n The data type of the mask. \n\n #### Declaration\n\n Swift \n\n var dataType: ../Enums/MaskDataType.html { get }\n\n- `\n ``\n ``\n `\n\n ### [uint8Data](#/c:objc(cs)MPPMask(py)uint8Data)\n\n `\n ` \n The pointer to the memory location where the underlying mask as a single channel `UInt8` array is\n stored. Uint8 values use the full value range and range from 0 to 255. \n\n #### Declaration\n\n Swift \n\n var uint8Data: UnsafePointer\u003cUInt8\u003e { get }\n\n- `\n ``\n ``\n `\n\n ### [float32Data](#/c:objc(cs)MPPMask(py)float32Data)\n\n `\n ` \n The pointer to the memory location where the underlying mask as a single channel float 32 array\n is stored. Float values range from 0.0 to 1.0. \n\n #### Declaration\n\n Swift \n\n var float32Data: UnsafePointer\u003cFloat\u003e { get }\n\n- `\n ``\n ``\n `\n\n ### [init(uInt8Data:width:height:shouldCopy:)](#/c:objc(cs)MPPMask(im)initWithUInt8Data:width:height:shouldCopy:)\n\n `\n ` \n Initializes an `Mask` object of type `uInt8` with the given `UInt8*` data, width and height.\n\n If `shouldCopy` is set to `true`, the newly created `Mask` stores a reference to a deep copied\n [uint8Data](../Classes/Mask.html#/c:objc(cs)MPPMask(py)uint8Data). Since deep copies are expensive, it is recommended to not set `shouldCopy` unless\n the `Mask` must outlive the passed in [uint8Data](../Classes/Mask.html#/c:objc(cs)MPPMask(py)uint8Data). \n\n #### Declaration\n\n Swift \n\n init?(uInt8Data uint8Data: UnsafePointer\u003cUInt8\u003e, width: Int, height: Int, shouldCopy: Bool)\n\n #### Parameters\n\n |--------------------|-------------------------------------------------------------|\n | ` `*uint8Data*` ` | A pointer to the memory location of the `UInt8` data array. |\n | ` `*width*` ` | The width of the mask. |\n | ` `*height*` ` | The height of the mask. |\n | ` `*shouldCopy*` ` | The height of the mask. |\n\n #### Return Value\n\n A new `Mask` instance with the given `UInt8*` data, width and height.\n- `\n ``\n ``\n `\n\n ### [init(float32Data:width:height:shouldCopy:)](#/c:objc(cs)MPPMask(im)initWithFloat32Data:width:height:shouldCopy:)\n\n `\n ` \n Initializes an `Mask` object of type `float32` with the given `float*` data, width and height.\n\n If `shouldCopy` is set to `true`, the newly created `Mask` stores a reference to a deep copied\n [float32Data](../Classes/Mask.html#/c:objc(cs)MPPMask(py)float32Data). Since deep copies are expensive, it is recommended to not set `shouldCopy` unless\n the `Mask` must outlive the passed in [float32Data](../Classes/Mask.html#/c:objc(cs)MPPMask(py)float32Data). \n\n #### Declaration\n\n Swift \n\n init?(float32Data: UnsafePointer\u003cFloat\u003e, width: Int, height: Int, shouldCopy: Bool)\n\n #### Parameters\n\n |---------------------|-------------------------------------------------------------|\n | ` `*float32Data*` ` | A pointer to the memory location of the `float` data array. |\n | ` `*width*` ` | The width of the mask. |\n | ` `*height*` ` | The height of the mask. |\n\n #### Return Value\n\n A new `Mask` instance with the given `float*` data, width and height.\n- `\n ``\n ``\n `\n\n ### [-init](#/c:objc(cs)MPPMask(im)init)\n\n `\n ` \n Unavailable.\n- `\n ``\n ``\n `\n\n ### [+new](#/c:objc(cs)MPPMask(cm)new)\n\n `\n ` \n Undocumented"]]