captureStillImageAsynchronouslyFromConnection without JPG intermediary

送分小仙女□ 提交于 2019-11-30 20:33:25
squidpickles

You'll need to set the outputSettings with a different pixel format. If you want 32-bit BGRA, for example, you can set:

NSDictionary *outputSettings = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithUnsignedInt:kCVPixelFormatType_32BGRA], (id)kCVPixelBufferPixelFormatTypeKey, nil];

From https://developer.apple.com/library/mac/#documentation/AVFoundation/Reference/AVCaptureStillImageOutput_Class/Reference/Reference.html, the "recommended" pixel formats are:

  • kCMVideoCodecType_JPEG
  • kCVPixelFormatType_420YpCbCr8BiPlanarFullRange
  • kCVPixelFormatType_32BGRA

Of course, if you're not using JPEG output, you can't use jpegStillImageNSDataRepresentation:, but there's an example here: how to convert a CVImageBufferRef to UIImage

Just change the Output settings of your connection:

outputSettings The compression settings for the output.

@property(nonatomic, copy) NSDictionary *outputSettings

You can retreive an NSDictionary of the supported values with

availableImageDataCodecTypes The supported image codec formats that can be specified in outputSettings. (read-only)

@property(nonatomic, readonly) NSArray *availableImageDataCodecTypes
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!