captureStillImageAsynchronouslyFromConnection没有JPG中介
我试图从相机中获得尽可能好的图像,但只能findcaptureStillImageAsynchronouslyFromConnection
示例,然后直接进入:
NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageSampleBuffer]; UIImage *image = [[UIImage alloc] initWithData:imageData];
JPEG是有损的,所有,有没有办法将数据作为PNG,甚至只是RGBA(BGRA,你有什么?)。 AVCaptureStillImageOutput似乎没有任何其他NSData *方法….
实际上看着CMSampleBufferRef,它似乎已经被locking为JPEG〜
formatDescription = <CMVideoFormatDescription 0xfe5e1f0 [0x3e5ac650]> { mediaType:'vide' mediaSubType:'jpeg' mediaSpecific: { codecType: 'jpeg' dimensions: 2592 x 1936 } extensions: {(null)} }
有没有其他的方式来获取全面的照片,并获得原始数据?
您需要使用不同的像素格式设置outputSettings。 例如,如果你想要32位BGRA,你可以设置:
NSDictionary *outputSettings = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithUnsignedInt:kCVPixelFormatType_32BGRA], (id)kCVPixelBufferPixelFormatTypeKey, nil];
-
kCMVideoCodecType_JPEG
-
kCVPixelFormatType_420YpCbCr8BiPlanarFullRange
-
kCVPixelFormatType_32BGRA
当然,如果你不使用JPEG输出,你不能使用jpegStillImageNSDataRepresentation:
,但是这里有一个例子: 如何将CVImageBufferRef转换为UIImage
只需更改连接的输出设置:
outputSettings输出的压缩设置。
@property(nonatomic, copy) NSDictionary *outputSettings
你可以通过一个retreive支持值的NSDictionary
availableImageDataCodecTypes可以在outputSettings中指定的支持的图像编解码器格式。 (只读)
@property(nonatomic, readonly) NSArray *availableImageDataCodecTypes