Unable to retrieve ARDirectionalLightEstimate

Hi All,


I am unable to retrieve the "ARDirectionalLightEstimate" instance from the ARFrame in a face-tracking AR session.


The "lightEstimate" property of ARFrame gives me a "ARLightEstimate" object and not an "ARDirectionalLightEstimate". The below code return "false"


ARsession.currentFrame?.lightEstimate is ARDirectionalLightEstimate


It would be great if someone can please share as to how we can extract the "ARDirectionalLightEstimate" instance in a face tracking AR session.
Thanks for your help _/\_
Best Regards,

Sumit

Accepted Reply

Thanks for the suggestion @gchiste _/\_. It helped to to arrive at correct solution using ARSCNViewDelegate


I use the below code snippet to retrieve the directional light estimate

extension MyViewController: ARSCNViewDelegate {
    func renderer(_ renderer: SCNSceneRenderer, updateAtTime time: TimeInterval) {
        DispatchQueue.global(qos: .default).async {
            guard let frame = self.specScnView.session.currentFrame else { return }
            if frame.lightEstimate is ARDirectionalLightEstimate
            {
                self.dirLightEst = frame.lightEstimate as? ARDirectionalLightEstimate
            }
        }
    }

Replies

Are you checking the ARFrame whenever it is updated in session(_:didUpdate:)? They will not be available at first, but once a face is detected, you should start receiving ARDirectionalLightEstimates.

Thanks for the suggestion @gchiste _/\_. It helped to to arrive at correct solution using ARSCNViewDelegate


I use the below code snippet to retrieve the directional light estimate

extension MyViewController: ARSCNViewDelegate {
    func renderer(_ renderer: SCNSceneRenderer, updateAtTime time: TimeInterval) {
        DispatchQueue.global(qos: .default).async {
            guard let frame = self.specScnView.session.currentFrame else { return }
            if frame.lightEstimate is ARDirectionalLightEstimate
            {
                self.dirLightEst = frame.lightEstimate as? ARDirectionalLightEstimate
            }
        }
    }