Depth capture for iPhone X back camera not working

359 views Asked by At

I'm running into an issue where isDepthDataDeliveryEnabled is false for me on an iPhone X and using .builtInDualCamera.

The weird thing is that this is only happening on one specific iPhone X. I've tested on other iPhone Xs and iPhone 11s, and everything works as expected. All devices I've tested on have been running iOS 13.3.

Just wanted to see if there might be any device-specific reason why capturing depth data might not be enabled on a device.

     lazy var frontCamera: AVCaptureDevice? = {  
        let discoverySession = AVCaptureDevice.DiscoverySession(deviceTypes:  
            [.builtInDualCamera, .builtInDualWideCamera, .builtInUltraWideCamera, .builtInTelephotoCamera, .builtInWideAngleCamera, .builtInTrueDepthCamera, .builtInTripleCamera],  
        mediaType: .video, position: .back)  
        let devices = discoverySession.devices  
        for device in devices {  
            print("\(device) supports \(device.activeFormat.supportedDepthDataFormats)")  
        }  
        let depthSupportedDevices = devices.filter({ return $0.activeFormat.supportedDepthDataFormats.count != 0 })  
        print("depth supported devices are: \(depthSupportedDevices)")  

        return depthSupportedDevices.first  
    }()  

    func sessionPrepare() {  
        guard let captureDevice = frontCamera else { return }  

        do {  
            let deviceInput = try AVCaptureDeviceInput(device: captureDevice)  
            session.beginConfiguration()  
            session.sessionPreset = .photo  

            if session.canAddInput(deviceInput) {  
                session.addInput(deviceInput)  
            }  

            if session.canAddOutput(output) {  
                session.addOutput(output)  

                output.isDepthDataDeliveryEnabled = output.isDepthDataDeliverySupported  
                output.isPortraitEffectsMatteDeliveryEnabled = output.isPortraitEffectsMatteDeliverySupported  
            }  

            session.commitConfiguration()  
        } catch {  
            self.dismiss(animated: true, completion: nil)  
        }  
    }  
0

There are 0 answers