相关疑难解决方法(0)

如何从CMSampleBuffer获取Y组件来自AVCaptureSession?

嘿,我试图使用AVCaptureSession iphone相机访问原始数据.我按照Apple(提供的指南链接点击这里).

从samplebuffer的原始数据是在YUV格式(我是正确这里有关原始视频帧格式??),如何直接获得为Y分量的数据从存储在samplebuffer原始数据.

iphone stream avcapturesession

10
推荐指数
3
解决办法
1万
查看次数

如何从相机中抓取YUV格式的视频,显示并处理它

我正在编写一个iphone(IOS 4)程序,它可以从摄像头捕获实时视频并实时处理.

我更喜欢用kCVPixelFormatType_420YpCbCr8BiPlanarFullRange格式捕获以便于处理(我需要处理Y通道).如何以这种格式显示数据?我想我需要以某种方式将其转换为UIImage,然后将其放入一些ImageView?

目前我有代码显示kCVPixelFormatType_32BGRA数据,但自然它不适用于kCVPixelFormatType_420YpCbCr8BiPlanarFullRange.

这是我现在用于转换的代码,有关如何对kCVPixelFormatType_420YpCbCr8BiPlanarFullRange执行相同操作的任何帮助/示例将不胜感激.(也批评我目前的方法).

// Create a UIImage from sample buffer data
- (UIImage *) imageFromSampleBuffer:(CMSampleBufferRef) sampleBuffer 
{
    // Get a CMSampleBuffer's Core Video image buffer for the media data
    CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer); 
    // Lock the base address of the pixel buffer
    CVPixelBufferLockBaseAddress(imageBuffer, 0); 

    // Get the number of bytes per row for the pixel buffer
    void *baseAddress = CVPixelBufferGetBaseAddress(imageBuffer); 

    // Get the number of bytes per row for the pixel buffer
    size_t bytesPerRow = CVPixelBufferGetBytesPerRow(imageBuffer); 
    // Get …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch objective-c uikit ios4

9
推荐指数
1
解决办法
9823
查看次数