iPad Pro issues with playground ARFaceTracking

I'm trying to do something with ARFaceTracking but on PlaygroundBook it doesn't work.. But I have an iPad Pro. I really cannot understand where is the mistake.. I see only a black screen on the right while I should see the front camera


This is my simple code:

//

import PlaygroundSupport

import ARKit




var sceneView: ARSCNView! = ARSCNView(frame: CGRect(x: 0, y: 0, width: 300, height: 300))

let configuration = ARFaceTrackingConfiguration()

sceneView.session.run(configuration)

PlaygroundPage.current.needsIndefiniteExecution = true

PlaygroundPage.current.liveView = sceneView

//

Replies

Hey Rascione,


The main problem that I figured out why it wouldn't work with me, is that the ARSCNView, which is a view for displaying AR experiences and that uses the camera, was not set to the view of the class itself.


//Set a global variable of ARSCNView
var sceneView = ARSCNView!

//Set sceneView to its own view
self.view = sceneView


I would recommend to uses in the form of classes. So make a class like FaceTrackViewController or something and handle all your code in this way. You can also easier use inheritance of UIViewController and implement the delegate methods of ARSCNViewDelegate and ARSCNViewSession.


For other people reading this post:


This is the point where my camera works just fine, but the renderer methods (nodeFor anchor etc...) don't get called. Yes, I set the delegates of the earlier mentioned interfaces to self.

With some help of some friends on the interwebs, I got a possible answer to why it doesn't work. Apparently Swift Playgrounds uses iOS 12.0 SDK, and TrueDepth support was added in 12.1. So unless Apple updates the playgrounds app, I think we're out of luck of using the FaceTracking API.

See this forum post for some clarification on the issue: https://forums.developer.apple.com/thread/114609