objc vImage PixelBuffer crop

I need for an objc implementation exactly the functionality of this swift documentation: https://developer.apple.com/documentation/accelerate/vimage/pixelbuffer/3951652-cropped?changes=_7_1&language=objc

It seems that there is no objc documentation present. Does anyone know how to call the crop function in objc?

Answered by Engineer in 737637022

Take a look at Applying vImage Operations to Regions of Interest.

In summary, you need to create a vImage buffer that shares data with your source buffer but with a data pointer that points to the top-left pixel of your region of interest and a height and width that matches your region of interest. Then call vImageCopyBuffer to copy from the source to your crop destination.

Accepted Answer

Take a look at Applying vImage Operations to Regions of Interest.

In summary, you need to create a vImage buffer that shares data with your source buffer but with a data pointer that points to the top-left pixel of your region of interest and a height and width that matches your region of interest. Then call vImageCopyBuffer to copy from the source to your crop destination.

Is that than ensured that the underlying data layout is not changed? I need an image buffer that is densly packed without some 16bit alignment like here: https://developer.apple.com/documentation/accelerate/vimage_buffer?changes=_7_1&language=objc

Or do i than have to ensure 16byte aligned cropping, to get dense packed crop area?

objc vImage PixelBuffer crop
 
 
Q