Closed Sterling-Malory-Archer closed 3 years ago
All you have to do is set the ARCameraManager's requestedFacingDirection.
Facing direction is considered a "feature", and not all features are compatible simultaneously. For example, if you request plane detection and the user-facing camera, both of these are not supported on all devices (e.g., Android), so ARFoundation will choose a mode of operation that maximizes the number of requested features. You can read more about that here.
The easiest way to debug this is to build a Development Player and watch the logcat output. It will tell you which features were requested, which were satisfied, and which could not be satisfied.
All you have to do is set the ARCameraManager's requestedFacingDirection.
Facing direction is considered a "feature", and not all features are compatible simultaneously. For example, if you request plane detection and the user-facing camera, both of these are not supported on all devices (e.g., Android), so ARFoundation will choose a mode of operation that maximizes the number of requested features. You can read more about that here.
The easiest way to debug this is to build a Development Player and watch the logcat output. It will tell you which features were requested, which were satisfied, and which could not be satisfied.
I only have Tracked Image Manager attached to my AR Session Origin, should I disable this when trying to switch to the front facing camera?
I have added the CameraSwapper.cs from the examples here, it says that it's switched the facing direction to User, but it doesn't switch it in the build on the phone
I only have Tracked Image Manager attached to my AR Session Origin, should I disable this when trying to switch to the front facing camera?
This is a feature which requires the world-facing camera. Again, if you look at the logcat output, it should have told you why it is not entering the user-facing camera mode.
I only have Tracked Image Manager attached to my AR Session Origin, should I disable this when trying to switch to the front facing camera?
This is a feature which requires the world-facing camera. Again, if you look at the logcat output, it should have told you why it is not entering the user-facing camera mode.
Thank you for the answer, Tim
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
@tdmowrer Is it possible to run HumanBodyTracking3D with the front facing camera on iPhone 12 with iOS 13? I tried changing Facing Direction to User but it still uses the rear camera
@jameslin101 Human Body tracking is only supported on the world-facing camera.
Hi Tim,
I have added this code that flips the camera between user and world using requestedFacingDirection
public ARCameraManager cameraManager
{
get => m_CameraManager;
set => m_CameraManager = value;
}
public ARTrackedImageManager m_ARTrackedImageManager;
public GameObject infoCanvas;
public GameObject selfieCanvas;
public ImageTracking imageTracking;
[SerializeField]
ARCameraManager m_CameraManager;
/// <summary>
/// On button press callback to toggle the requested camera facing direction.
/// </summary>
public void OnSwapCameraButtonPress()
{
Debug.Assert(m_CameraManager != null, "camera manager cannot be null");
CameraFacingDirection newFacingDirection;
switch (m_CameraManager.requestedFacingDirection)
{
case CameraFacingDirection.World:
newFacingDirection = CameraFacingDirection.User;
m_ARTrackedImageManager.enabled = false;
infoCanvas.SetActive(false);
selfieCanvas.SetActive(true);
imageTracking.TurnOffAnimals();
break;
case CameraFacingDirection.User:
default:
newFacingDirection = CameraFacingDirection.World;
m_ARTrackedImageManager.enabled = true;
infoCanvas.SetActive(true);
selfieCanvas.SetActive(false);
break;
}
Debug.Log($"Switching ARCameraManager.requestedFacingDirection from {m_CameraManager.requestedFacingDirection} to {newFacingDirection}");
m_CameraManager.requestedFacingDirection = newFacingDirection;
}
It works on Android, however, when I try it on my iOS devices, the XCode console prints out "Switching from world to user, but the camera selected is still rear.
Any idea on how can I achieve it on iOS?
Thanks.
This might be helpful: https://youtu.be/jBRxY2KnrUs?t=680
This might be helpful: https://youtu.be/jBRxY2KnrUs?t=680
Thank you for this, I've already added the CustomConfigurationChooser and as I said, everything works as intended on Android, but on iOS it doesn't, even though the game objects that are associated with when the front-facing camera is on, become active.
I even added the ARKit Face Tracking package and tested it on my iPhone 11 Pro Max.
Does this sample work for you?
Note that different phones and iOS versions have different capabilities. In a development build on iOS, there should be console output (in Xcode) telling you which features (including facing direction) were requested, satisfied, and not satisfied.
hello,
when i use the user direction the mesh and face are set up , but when ever i swap the camera to world, the application does not set my face (i checked and my camera app in the phone actually detects my face so it's not a device problem) how can i make this to work?
world tracking from the front camera yet?
I think it was definitely a bug in UnityARKit that it not get the front facing camera properly in older iphone (11 in particular)
I have tried to use everything, especially the chooser logic. And found out that the camera descriptions it returned was all world facing. Even if the WebCamTextures totally have front and rear camera as it should
And it is definitely impossible that selfie camera in iphone are not support AR system for face. More likely that, unity AR system written in obj-c are not trying to get camera properly
Still, if I remember correctly, the camera system in ios have some bug that it will not return all camera the first time the app requested. There might need to be workaround like request camera until it return all camera before continuing the AR description logic
Below is the debug log from xcode
No Camera Floor Offset GameObject specified for XR Origin, using attached GameObject.
Camera "AR Camera" does not use a Tracked Pose Driver (Input System), so its transform will not be updated by an XR device. In order for this to be updated, please add a Tracked Pose Driver (Input System) with bindings for position and rotation of the center eye.
Configuration Descriptor 0x2089d4770 (rank 2): Rotation and Orientation, Plane Tracking, Light Estimation (Ambient Intensity), Light Estimation (Ambient Color), Raycast
Configuration Descriptor 0x2089d5b20 (rank 0): World Facing Camera, Rotation and Orientation, Plane Tracking, Image Tracking, Object Tracking, Environment Probes, 2D Body Tracking, Human Occlusion Stencil, Human Occlusion Depth, Collaboration, Auto-Focus, Light Estimation (Ambient Intensity), Light Estimation (Ambient Color), Raycast
Configuration Descriptor 0x2089d6d90 (rank 1): World Facing Camera, Rotation Only, 2D Body Tracking, Human Occlusion Stencil, Human Occlusion Depth, Auto-Focus, Light Estimation (Ambient Intensity), Light Estimation (Ambient Color)
Configuration Descriptor 0x2089d4540 (rank 1): World Facing Camera, Rotation Only, Image Tracking, 2D Body Tracking, Human Occlusion Stencil, Human Occlusion Depth, Auto-Focus, Light Estimation (Ambient Intensity), Light Estimation (Ambient Color)
Configuration Descriptor 0x2089d40e0 (rank -1): World Facing Camera, Rotation and Orientation, Plane Tracking, Image Tracking, Environment Probes, 2D Body Tracking, 3D Body Tracking, 3D Body Scale Estimation, Auto-Focus, Light Estimation (Ambient Intensity), Light Estimation (Ambient Color), Raycast
Requested Features: User Facing Camera, Auto-Focus
features not satisfied: User Facing Camera
@Thaina have you enabled face tracking in the ARKit settings? Apple has additional submission requirements for apps that use face tracking, so you must explicitly enable it for it to be available at runtime. See https://docs.unity3d.com/Packages/com.unity.xr.arkit@5.1/manual/project-configuration-arkit.html#enable-face-tracking for details.
Thank you very much, I will take a look tomorrow
Seem like that was my mistake when upgrading project. Thank you very much
As the title says, I am looking for a way to change the camera facing direction in runtime, is that possible?
Or do I make another AR Camera with facing direction set to user and then turn it on, whilst simultaneously turning off the ARCamera with facing direction set to world?
Thank you and any help is kindly appreciated.
The purpose of this is that I want my user to have the ability to switch to the front-facing camera to use as a selfie to take pictures with some filters.
I tried implementing CameraSwapper.cs from the arfoundation-samples but when I test it on my Android it doesn't do anything, although it detects that the button has been pressed.