【发布时间】:2018-09-04 10:37:11
【问题描述】:
我正在做一个项目,我使用AVCaptureSession 捕获用户的视频输入。问题是我需要 BGRA 格式的输出才能使用 OpenCV 渲染它,但是我需要将其更改回默认的 420f 格式以将其显示给用户。所以,我将videoSettings中的PixelFormatType设置为kCVPixelFormatType_32BGRA,
[videoOutput setVideoSettings:[NSDictionary dictionaryWithObject:[NSNumber numberWithInt:kCVPixelFormatType_32BGRA] forKey:(id)kCVPixelBufferPixelFormatTypeKey]];
我想在 captureOutput 中将采样缓冲区转换为 420f:
- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection {
[self doSomeOpenCV:sampleBuffer]; // the OpenCV part
//convert sampleBuffer to kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange
}
有没有办法做到这一点?或者,有一个函数可以在给定输入的情况下返回指定格式的样本缓冲区?
【问题讨论】:
-
你如何向用户显示框架?为什么需要 yuv?
-
@RhythmicFistman 我正在使用谷歌的 webRTC 框架,它使用 yuv pixelFormatType
-
@Valérian 它似乎不适用于 iOS
标签: ios objective-c opencv avfoundation avcapturesession