Я пытаюсь сделать снимок с iPhone с помощью AVFoundation, но у меня возникают проблемы с поиском того, что мне нужно.
Я создал AVCaptureSession и добавил предустановку в AVCaptureSessionPresetHigh.
self.session.sessionPreset = AVCaptureSessionPresetHigh;
Я отображаю videoPreviewLayer в своем представлении, и я могу сделать снимок с кодом:
AVCapturePhotoSettings *settings = [AVCapturePhotoSettings photoSettingsWithFormat: @{AVVideoCodecKey:AVVideoCodecJPEG}];
[self.stillImageOutput capturePhotoWithSettings:settings delegate:self]
И я получаю изображение FHD (1920x1080), так что это хорошо работает.
Но теперь я хочу сохранить хорошее отображаемое изображение, поэтому сохраняйте заранее установленное высокое значение, но снимайте изображение с разрешением 640x480.
Возможно ли это?
Есть идеи?
Я пробовал это:
NSDictionary *outputSetting = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithDouble:1280], (id)kCVPixelBufferHeightKey,
[NSNumber numberWithDouble:960], (id)kCVPixelBufferWidthKey,
[NSNumber numberWithUnsignedInt:kCVPixelFormatType_32BGRA], (id)kCVPixelBufferPixelFormatTypeKey,
nil];
AVCapturePhotoSettings *settings = [AVCapturePhotoSettings photoSettingsWithFormat: outputSetting];
[self.stillImageOutput capturePhotoWithSettings:settings delegate:(id)self];
Но я получаю эту ошибку:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[AVCapturePhotoSettings photoSettingsWithFormat:] Unsupported keys specified: {(
Height,
Width
)}. Supported keys are {(
PixelFormatType
)}'