Reputation: 530
I'm trying to create an AR experience that works with both front and rear cameras (where available). I want to switch between them just like you would with a default camera app.
Does Vuforia Framework Support Front Camera, and does someone integrate Vuforia with other face tracking AR framework before and how was the experience ?
Upvotes: 1
Views: 2807
Reputation: 101
Vuforia has deprecated the front camera in his newer versions (8.x and newers).
You can use older versions of unity to force use vuforia 7.x
In my case, I used Unity 2018.2.12 and downloaded vuforia 7 here:
Vuforia-AR-Support-for-Editor-2018.2.12f1.exe
Upvotes: 0
Reputation:
In your AR camera settings, you will find this option ranging from CAMERA_DEFAULT, CAMERA_BACK and CAMERA_FRONT.
To access the camera via script, Vuforia has explained in detail in this page: https://library.vuforia.com/articles/Solution/Working-with-the-Camera
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Vuforia;
public class CameraController : MonoBehaviour
{
private bool lightOn = false;
private bool frontCamera = false;
public void CameraChange()
{
if (!frontCamera)
{
RestartCamera(CameraDevice.CameraDirection.CAMERA_FRONT);
frontCamera = true;
Debug.Log("Using Front Camera");
}
else if (frontCamera)
{
RestartCamera(CameraDevice.CameraDirection.CAMERA_BACK);
frontCamera = false;
Debug.Log("Using Back Camera");
}
else
{
Debug.Log("No camera status available.");
}
}
private void RestartCamera(CameraDevice.CameraDirection newDir)
{
CameraDevice.Instance.Stop();
CameraDevice.Instance.Deinit();
CameraDevice.Instance.Init(newDir);
CameraDevice.Instance.Start();
// Periodically check to see if still needed
VuforiaUnity.OnPause();
VuforiaUnity.OnResume();
}
}
Upvotes: 3