Is it possible to run ARWorldTracking Session and ARFaceTracking Session at the same time on iPhoneX?

1.1k views Asked by At

I'm trying to run ARWorldTracking Session and ARFaceTracking Session at the same time on iPhoneX, but the first running session stopped after the later session begun to run.

Is is impossible to implement? This is my ViewController.swift code.

import UIKit
import ARKit

class ViewController: UIViewController, ARSCNViewDelegate, 
ARSessionDelegate {
    @IBOutlet weak var frontView: ARSCNView!
    @IBOutlet weak var backView: ARSCNView!
    override func viewDidLoad() {
       super.viewDidLoad()
       startTracking()
    }

   func startTracking() {
       let backConfiguration = ARWorldTrackingConfiguration()
       backView.session.run(backConfiguration)

       let frontConfiguration = ARFaceTrackingConfiguration()
       frontConfiguration.isLightEstimationEnabled = true      
       frontView.session.run(frontConfiguration)
  }
}
2

There are 2 answers

1
rickster On BEST ANSWER

Nope.

ARKit relies upon the AVCapture system, and that doesn’t support using more than one capture device (camera) at a time. If you start a capture session using the front camera while another session is using the back camera, the existing session stops.

2
Josh Homann On

ARSession is a singleton, so changing the configuration is going to change the state of the shared session. from the docs:

ARSession A shared object that manages the device camera and motion processing needed for augmented reality experiences.