ARKit face tracking

Does anyone know offhand how to hide the camera feed while doing ARKit face tracking? I am working on an Animoji like app.


I can't seem to figure it out from the demos and docs.

Replies

I am exploring something like this too but seems like nobody has explored it yet? or was this discussed on different threads?

You can simply set up an ARSession (no ARSCNView or ARSKView required), here is a small example which shows how you can set up your own ARSession and use its data outside of an ARSCNView:


import ARKit

class ViewController: UIViewController, ARSessionDelegate {
   
    let session = ARSession()
   
    override func viewDidLoad() {
        super.viewDidLoad()
       
        session.run(ARFaceTrackingConfiguration())
        session.delegate = self
       
    }
   
   
    func session(_ session: ARSession, didAdd anchors: [ARAnchor]) {
        print(anchors)
    }
   
    func session(_ session: ARSession, didUpdate anchors: [ARAnchor]) {
        for anchor in anchors {
            if let faceAnchor = anchor as? ARFaceAnchor {
                print(faceAnchor.blendShapes[ARFaceAnchor.BlendShapeLocation.mouthClose])
            }
        }
    }
   
}


Of course, you probably want to render something with that data, so you could use a plain SCNView to do so.