Core Video Interoperability

Pass image data between Core Video and vImage.

Overview

vImage provides two approaches for conversion between Core Video pixel buffers and vImage buffers:

vImageBuffer_InitWithCVPixelBuffer(_:_:_:_:_:_:) and vImageBuffer_CopyToCVPixelBuffer(_:_:_:_:_:_:)

Use these functions to copy pixel data between Core Video pixel buffers and vImage buffers. When you initialize a vImage buffer with vImageBuffer_InitWithCVPixelBuffer(_:_:_:_:_:_:), vImage allocates new memory and, after you're finished with the buffer, you must deallocate that memory using free(). The Core Video pixel buffers don't need to be locked when you use these functions.

vImageBuffer_InitForCopyFromCVPixelBuffer(_:_:_:_:) and vImageBuffer_InitForCopyToCVPixelBuffer(_:_:_:_:)

Use these functions in conjunction with vImageConvert_AnyToAny(_:_:_:_:_:) to create vImage buffers that share memory with Core Video pixel buffers. When you initialize vImage buffers using these functions, no additional memory is allocated—that is, you always pass the kvImageNoAllocate flag—so there's no need to free the buffers' data after you're finished using them. However, the Core Video pixel buffers must be locked and unlocked using CVPixelBufferLockBaseAddress(_:_:) and CVPixelBufferUnlockBaseAddress(_:_:), respectively.

To learn how to convert images using vImageConvert_AnyToAny(_:_:_:_:_:), see Building a Basic Conversion Workflow.

Topics

Initializing vImage Buffers from Core Video Pixel Buffers

func vImageBuffer_InitForCopyFromCVPixelBuffer(UnsafeMutablePointer<vImage_Buffer>, vImageConverter, CVPixelBuffer, vImage_Flags) -> vImage_Error

Initializes an array of vImage buffers in the order required to copy from a Core Video pixel buffer.

func vImageBuffer_InitForCopyToCVPixelBuffer(UnsafeMutablePointer<vImage_Buffer>, vImageConverter, CVPixelBuffer, vImage_Flags) -> vImage_Error

Initializes an array of vImage buffers in the order required to copy to a Core Video pixel buffer.

Managing Core Video Image Formats

Core Video Image Format Utilities

Create, copy, and query Core Video Image format descriptions.

See Also

Core Video Interoperability

Reading From and Writing to Core Video Pixel Buffers

Transfer image data between Core Video pixel buffers and vImage buffers to integrate vImage operations into a Core Image workflow

Applying vImage Operations to Video Sample Buffers

Use vImage’s convert-any-to-any function to perform real-time image processing of video frames streamed from your device’s camera.

Converting Luminance and Chrominance Planes to an ARGB Image

Create a displayable ARGB image from the luminance and chrominance information supplied by your device’s camera.

Real-Time Video Effects with vImage

Use vImage to apply effects to a video feed in real time.