我是整个AVFoundation的新手。在我使用旧的UIImagePickerControllerSourceTypeCamera之前。
我基本上想要组合添加半透明覆盖层的叠加以及操纵像素以创建黑色&白色效果,棕褐色等。
我正在显示它并使用AVFoundation框架捕获它,我可以拍摄静止帧,但我不知道如何添加叠加层。
请帮忙。感谢。
答案 0 :(得分:1)
如果您要对图像进行任何大量处理,我建议您使用OpenGL ES。如果它很简单,例如叠加层,那么您可以使用CoreGraphics。
这是一个快速剪切它来获取像素。
void modifyImage(CMSampleBufferRef source) {
CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(source);
CVPixelBufferLockBaseAddress(imageBuffer,0);
size_t bytesPerRow = CVPixelBufferGetBytesPerRow(imageBuffer);
size_t width = CVPixelBufferGetWidth(imageBuffer);
size_t height = CVPixelBufferGetHeight(imageBuffer);
void *src_buff = CVPixelBufferGetBaseAddress(imageBuffer);
int32_t *src = (int32_t*) src_buff;
//modify the image
CVPixelBufferUnlockBaseAddress(imageBuffer, 0);
return;
}
使用OpenGL ES处理视频的好起点,请参阅Brad Larson's博客。