Setup FaceAnchor
Before you begin, please update iOS ARCloud SDK to version 0.4.16
or later. You may reset the package cache in Xcode if a new function did not show up.
FaceAnchor only works with Apple devices that support FaceID. You can see the device list to learn more https://support.apple.com/en-us/HT209183 (opens in a new tab)
To add face detection to AR experience, simply add startFaceAnchor(Bool)
when you init service. An AR session will be switched to the front camera.
let arCloudUIView = ARCloudUIView(service: self.graffityARCloud, startFaceAnchor: true, nodeTouchDelegate: self)
To work with both front and back cameras, you can create them in 2 views separately. For example in the code block below:
// This is just an example code in UIViewController class.
let arCloudUIViewFront = ARCloudUIView(
service: self.graffityARCloud,
startFaceAnchor: true,
nodeTouchDelegate: self)
let arCloudUIViewBack = ARCloudUIView(
service: self.graffityARCloud,
nodeTouchDelegate: self)
// Open each ARView with an iOS button action
@objc func openFrontAR() {
self.present(arCloudUIViewFront)
}
@objc func openBackAR() {
self.present(arCloudUIViewBack)
}