AVCaptureSessionPreset:如果最大预设为 1088x1920,为什么标准 iPhone 相机保存 2448 × 3264?
AVCaptureSessionPreset: why does standard iPhone camera save 2448 × 3264, if max preset is 1088x1920?
我正在编写使用相机的小型 iOS 应用程序。我使用 AVFoundation
框架 API,并考虑 AVCaptureSessionPreset
的最大质量。在我的具体设备上是:
CaptureQualityPhoto = (640 852)
CaptureQualityHigh = (1088 1920)
CaptureQualityMedium = (368 480)
CaptureQuality1280x720 = (720 1280)
CaptureQuality640x480 = (480 640)
CaptureQualityiFrame960x540 = (540 960)
标准相机应用程序保存分辨率为 2448 × 3264
的照片。
假设我想以相同的分辨率保存照片,但我能达到的最高质量是 1088 x 1920
。
当然,我可以调整大小 UIImage
,但这是最好的方法吗?
标准应用程序是否可以访问更高分辨率或仅使用一些缩放和插值?
编辑:
现在我使用 2248x3264 照片预设的工作代码如下所示:
-(void) initCapturingDevice
{
[self releaseCapturingDevice];
self.capture_session = [[AVCaptureSession alloc] init];
[self.capture_session beginConfiguration];
self.video_data_output = [[AVCaptureVideoDataOutput alloc] init];
self.video_data_output.videoSettings = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:kCVPixelFormatType_32BGRA] forKey:(id)kCVPixelBufferPixelFormatTypeKey];
[self.video_data_output setSampleBufferDelegate:self queue:dispatch_get_main_queue()];
[self.capture_session addOutput:self.video_data_output];
self.capture_session.sessionPreset = AVCaptureSessionPresetPhoto;
// some code here ...
}
您可以获得最高质量的照片(在我的 phone 上是 4032 x 3024)AVCaptureSessionPresetPhoto
和 AVCaptureStillImageOutput
:
let captureDevice = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo)
let input = try! AVCaptureDeviceInput(device: captureDevice)
captureSession.addInput(input)
captureSession.sessionPreset = AVCaptureSessionPresetPhoto
let stillImageOutput = AVCaptureStillImageOutput()
captureSession.addOutput(stillImageOutput)
captureSession.startRunning()
let connection = stillImageOutput.connectionWithMediaType(AVMediaTypeVideo)
stillImageOutput.captureStillImageAsynchronouslyFromConnection(connection) { (sampleBuffer, error) in
print("maximum quality photo: \(sampleBuffer)\n")
}
我正在编写使用相机的小型 iOS 应用程序。我使用 AVFoundation
框架 API,并考虑 AVCaptureSessionPreset
的最大质量。在我的具体设备上是:
CaptureQualityPhoto = (640 852)
CaptureQualityHigh = (1088 1920)
CaptureQualityMedium = (368 480)
CaptureQuality1280x720 = (720 1280)
CaptureQuality640x480 = (480 640)
CaptureQualityiFrame960x540 = (540 960)
标准相机应用程序保存分辨率为 2448 × 3264
的照片。
假设我想以相同的分辨率保存照片,但我能达到的最高质量是 1088 x 1920
。
当然,我可以调整大小 UIImage
,但这是最好的方法吗?
标准应用程序是否可以访问更高分辨率或仅使用一些缩放和插值?
编辑: 现在我使用 2248x3264 照片预设的工作代码如下所示:
-(void) initCapturingDevice
{
[self releaseCapturingDevice];
self.capture_session = [[AVCaptureSession alloc] init];
[self.capture_session beginConfiguration];
self.video_data_output = [[AVCaptureVideoDataOutput alloc] init];
self.video_data_output.videoSettings = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:kCVPixelFormatType_32BGRA] forKey:(id)kCVPixelBufferPixelFormatTypeKey];
[self.video_data_output setSampleBufferDelegate:self queue:dispatch_get_main_queue()];
[self.capture_session addOutput:self.video_data_output];
self.capture_session.sessionPreset = AVCaptureSessionPresetPhoto;
// some code here ...
}
您可以获得最高质量的照片(在我的 phone 上是 4032 x 3024)AVCaptureSessionPresetPhoto
和 AVCaptureStillImageOutput
:
let captureDevice = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo)
let input = try! AVCaptureDeviceInput(device: captureDevice)
captureSession.addInput(input)
captureSession.sessionPreset = AVCaptureSessionPresetPhoto
let stillImageOutput = AVCaptureStillImageOutput()
captureSession.addOutput(stillImageOutput)
captureSession.startRunning()
let connection = stillImageOutput.connectionWithMediaType(AVMediaTypeVideo)
stillImageOutput.captureStillImageAsynchronouslyFromConnection(connection) { (sampleBuffer, error) in
print("maximum quality photo: \(sampleBuffer)\n")
}