iOS – Scale and crop CMSampleBufferRef/CVImageBufferRef

If you use vimage you can work directly on the buffer data without converting it to any image format. outImg contains the cropped and scaled image data. The relation between outWidth and cropWidth sets the scaling. int cropX0, cropY0, cropHeight, cropWidth, outWidth, outHeight; CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer); CVPixelBufferLockBaseAddress(imageBuffer,0); void *baseAddress = CVPixelBufferGetBaseAddress(imageBuffer); size_t bytesPerRow = … Read more