用AVFoundation扫描时直接获得图像…

配置captureOutputSetting时按这个参数来(还有别的参数可以查API)
_captureOutput = [[AVCaptureStillImageOutpu t alloc] init];
      NSDictionary *outputSettings = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:kCVPixelFormatType_32BGRA] forKey:(id)kCVPixelBufferPixelForma tTypeKey];
      [_captureOutput setOutputSettings:outputSettings];

回调 [_captureOutput captureStillImageAsynchr onouslyFromConnection:videoConnection completionHandler:
        ^(CMSampleBufferRef imageSampleBuffer, NSError *error){
// Get a CMSampleBuffer's Core Video image buffer for the media data
                          CVImageBufferRef imageBuffer = CMSampleBufferGetImageBu ffer(imageSampleBuffer);
                        // Lock the base address of the pixel buffer
                        CVPixelBufferLockBaseAdd ress(imageBuffer, 0);
                        Byte *buf = (Byte*)CVPixelBufferGetBaseAddr ess(imageBuffer);
                        NSLog(@"%d,%d,%d,%d,%d",buf[0],buf[1],buf[2],buf[3],buf[4]);



、、、、总体来说,还不知道算不算成功,先马克一下再说

后来查了下资料:You can use the videoSettings property to specify a custom output format. The video settings property is a dictionary; currently, the only supported key is kCVPixelBufferPixelForma tTypeKey. The recommended pixel format choices for iPhone 4 are kCVPixelFormatType_420YpCbCr8BiPlanarVideoR ange or kCVPixelFormatType_32BGRA; for iPhone 3G the recommended pixel format choices are kCVPixelFormatType_422YpCbCr8 or kCVPixelFormatType_32BGRA. Both Core Graphics and OpenGL work well with the BGRA format:

如果这段东西没理解错。。那么取出来的数据是BGRA格式
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值