I'm trying to capture a highres image from the front and back cameras at the same time - I setup the AVCaptureMultiCamSession session, add preview layers - preview works fine, and then add outputs like this:
let input = inputFor(device: device)
let output = AVCapturePhotoOutput()
underlying.addOutputWithNoConnections(output)
underlying.addConnection(AVCaptureConnection( inputPorts: input.ports, output: output))
output.maxPhotoQualityPrioritization = .quality
output.isHighResolutionCaptureEnabled = true
output.isLivePhotoCaptureEnabled = false
and then take pictures like this:
let settings = AVCapturePhotoSettings()
settings.isHighResolutionPhotoEnabled = true
settings.flashMode = .off
settings.isDepthDataDeliveryEnabled = false
settings.photoQualityPrioritization = .quality
self.outputCapture.capturePhoto(with: settings, delegate: self)
but there are two problems.
Problem 1
if I capture from the front camera then the back - I do get both images, but the image from the back camera is very dark... it's there and correct, just really underexposed. If I swap the order, both seem to be exposed correctly, but I think it's a sign that I've done something wrong, as all the code to initialise each one is shared - ie I do the same thing front and back.
Problem 2 The more important problem is that I have to capture separately - and the capturephoto actually takes a signficant amount of time - playing the shutter sound and so forth - so you get two distinct sounds, and a noticeable delay between capturing each image.
I want to capture each image simultaneously - as a single atomic operation - but when I tried putting DispatchQueue.global().async {} around the capture code - suddenly one of them always comes back with an error instead of a photo in the didfinishprocessingphoto delegate.
The question
so - the important question is how do I capture from both cameras at exactly the same time, and the less important is why is my back camera image underexposed if I capture from that second?