I'm having an issue with depth values using iOS 16. I'm getting noisier depth data from my AVFCaptureSession
on iOS 16 than iOS 15 and below. Has something changed for iOS 16?
I'm using the dual wide camera. My session initialization (minus some exception handling for when the session fails to initialize) looks like:
let depthDataOutput = AVCaptureDepthDataOutput()
let defaultVideoDevice: AVCaptureDevice? =
AVCaptureDevice.default(
.builtInDualWideCamera,
for: AVMediaType.video, position: .back
)
let videoDeviceInput = AVCaptureDeviceInput(device: videoDevice)
session.beginConfiguration()
session.sessionPreset = AVCaptureSession.Preset.hd1920x1080
guard session.canAddInput(videoDeviceInput) else { return }
...
var depthFormat: AVCaptureDevice.Format?
if session.canAddOutput(depthDataOutput) {
session.addOutput(depthDataOutput)
depthDataOutput.alwaysDiscardsLateDepthData = true
depthDataOutput.isFilteringEnabled = false
guard let connection = depthDataOutput.connection(with: .depthData) else { return }
connection.isEnabled = true
// Search for highest resolution available (by width)
depthFormat = videoDevice.activeFormat.supportedDepthDataFormats.filter({
kCVPixelFormatType_DepthFloat32
== CMFormatDescriptionGetMediaSubType($0.formatDescription)
}).max(by: {
fmt1, fmt2 in
CMVideoFormatDescriptionGetDimensions(fmt1.formatDescription).width
< CMVideoFormatDescriptionGetDimensions(fmt2.formatDescription).width
})
}
...
session.commitConfiguration()