Skip to main content
←API Reference

toYUV420PixelBuffer


Declaration​

func toYUV420PixelBuffer(width: Int, height: Int) -> CVPixelBuffer?

Summary​

Converts the CGImage to a CVPixelBuffer in YUV420NV12 (bi-planar) format for use as a camera feed.
Uses Core Image to perform the color conversion. Returns nil if buffer creation or render fails.

Parameters​

NameTypeSummary
widthInt
Target width for the pixel buffer (typically the image width).
heightInt
Target height for the pixel buffer (typically the image height).