Contents

vImageCVImageFormat_GetChannelCount(_:)

Returns the number of channels, including alpha, for the Core Video image format.

Declaration

func vImageCVImageFormat_GetChannelCount(_ format: vImageConstCVImageFormat) -> UInt32

Parameters

  • format:

    The Core Video image format to query.

Return Value

The number of channels.

Discussion

This function returns the number of interleaved or planar channels.

The functions that create Core Video image formats, such as vImageCVImageFormat_CreateWithCVPixelBuffer(_:), return a vImageCVImageFormat. The following code shows how you create a vImageConstCVImageFormat representation of a vImageCVImageFormat instance to pass to vImageCVImageFormat_GetChannelCount(_:):

let channelCount = withUnsafeBytes(of: cvImageFormat) { bytes in
    let format = bytes.assumingMemoryBound(
        to: vImageConstCVImageFormat.self).first!
    
    return vImageCVImageFormat_GetChannelCount(format)
}

See Also

Related Documentation

Querying and setting channel information