we have several apps in the Store that use ARFaceTrackingConfiguration
to detect the users face in iOS devices with FaceID cameras.
As you might have seen, ARKit will also track picture of faces you put in front of your iPad Pro/iPhoneX, as if they were faces. E.g. take a picture from one of our apps (to replicate one can download&run Apples example app for ARFaceTrackingConfiguration):
Now I have noticed that internally ARKit treats real faces differently then it does pictures of faces. Because generally (both for ARWorldTrackingConfiguration
as well as ARFaceTrackingConfiguration
) ARKit
tries to match real world sizes and virtual object sizes, i.e. and object that is 10x10cm in your 3D editing software will match a real world object of the same 10x10cm.
BUT when face-tracking is used, and the phone detects an abnormally sized face (small 4cm wide face as in the picture above or a poster of a person where the face is much bigger) it will scale the FaceGeometry as if the detected face is a normal sized head, i.e. the measurements will be around ~14cm for the head width. All virtual objects will then be scaled accordingly which will make then the wrong size in the real world. C.f. the next picture:
The glasses 3D model is about 14cm wide, yet they are only presented as a 4cm object.
In comparison, if you put the glasses on a real 3D face, they will be the correct size, on a small persons head (like 12cm) they will be slightly too big, on a big persons head (like 16cm) they will be slightly too small (as they will be their real 14cm in both cases).
I can even see ARKit switching between:
- Flat Face-detection using just the camera image
- Face-Detection using the FaceID TrueDepth camera.
which is especially prominent when you hold a baby in front of the app.
With a babys head, ARKit
will first attempt to scale up everything so that the babys head is 14cm wide in the virtual scene and the glasses fit like on an adult.
Then, usually 1-2s after the head appears in the camera ARFaceTrackingConfiguration
will switch from mode (1) to mode (2) and show the real size of the 3D Object, which leads to supercute pictures of small baby heads with adult sized glasses (not shown here as SO isn't for sharing baby pictures).
So, now for the question:
Is there a way of determining whether ARKit is in mode 1 or 2 ?