MPMask
final class MPMask: Sendable, EquatableSingle-channel MediaPipe segmentation mask supporting conversion between 0...255 and 0.0...1.0 representations.
-
Creates a
.float32mask by copyingwidth * heightelements fromfloat32Data.Declaration
Swift
convenience init(float32Data: UnsafePointer<Float>, width: Int, height: Int) -
Creates a
.uInt8mask by copyingwidth * heightelements fromuint8Data.Declaration
Swift
convenience init(uint8Data: UnsafePointer<UInt8>, width: Int, height: Int) -
Primary native data type of the segmentation mask.
Declaration
Swift
final let dataType: MaskDataType -
Mask values in
0.0...1.0.When
dataTypeis.uInt8, each element is scaled by1.0 / 255.0.Declaration
Swift
final var float32Elements: [Float] { get } -
Height of the segmentation mask in pixels.
Declaration
Swift
final let height: Int -
Total number of pixels in the mask (
width * height).Declaration
Swift
final let pixelCount: Int -
Mask values in
0...255.When
dataTypeis.float32, each element is clamped to0.0...1.0(mappingNaNto0) and scaled by255.0.Declaration
Swift
final var uint8Elements: [UInt8] { get } -
Width of the segmentation mask in pixels.
Declaration
Swift
final let width: Int -
Invokes
bodywith anUnsafeBufferPointer<Float>covering allwidth * heightpixels.Declaration
Swift
final func withUnsafeFloat32BufferPointer<Result>(_ body: (UnsafeBufferPointer<Float>) throws -> Result) rethrows -> Result -
Invokes
bodywith anUnsafeBufferPointer<UInt8>covering allwidth * heightpixels.Declaration
Swift
final func withUnsafeUInt8BufferPointer<Result>(_ body: (UnsafeBufferPointer<UInt8>) throws -> Result) rethrows -> Result