配置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格式
_captureOutput = [[AVCaptureStillImageOutpu
回调 [_captureOutput captureStillImageAsynchr
// Get a CMSampleBuffer's Core Video image buffer for the media data
}
、、、、总体来说,还不知道算不算成功,先马克一下再说
后来查了下资料: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
如果这段东西没理解错。。那么取出来的数据是BGRA格式