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

Copying Core Video Pixel Buffers to vImage Buffers

vImageBuffer_InitWithCVPixelBuffer

Initializes a vImage buffer with the contents of a Core Video pixel buffer.

Copying vImage Buffers to Core Video Pixel Buffers

vImageBuffer_CopyToCVPixelBuffer

Copies the contents of a vImage buffer to a Core Video pixel buffer.

Initializing vImage Buffers from Core Video Pixel Buffers

vImageBuffer_InitForCopyFromCVPixelBuffer

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

vImageBuffer_InitForCopyToCVPixelBuffer

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 Interoperation

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.

Real-Time Video Effects with vImage

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