Log in or register to post comments

Switching device camera issue

July 8, 2015 - 11:58am #1

I have a button that calls this method when pressed to switch device cameras from back to front and vice versa:

 

public void ToggleCam()
    {
        // turn off one camera
        Vuforia.CameraDevice.Instance.Stop();
        Vuforia.CameraDevice.Instance.Deinit();

        // turn on another camera
        Vuforia.CameraDevice.Instance.Init(getNextCamera());
        Vuforia.CameraDevice.Instance.Start();
    }

    private Vuforia.CameraDevice.CameraDirection getNextCamera()
    {
        // decide which camera to turn on
        switch (Vuforia.CameraDevice.Instance.GetCameraDirection())
        {
            case Vuforia.CameraDevice.CameraDirection.CAMERA_BACK:
            case Vuforia.CameraDevice.CameraDirection.CAMERA_DEFAULT:
            default:
                return Vuforia.CameraDevice.CameraDirection.CAMERA_FRONT;
            case Vuforia.CameraDevice.CameraDirection.CAMERA_FRONT:
                return Vuforia.CameraDevice.CameraDirection.CAMERA_BACK;
        }
    }

 

The problem, is, if the user switches to the front camera, then leaves the scene and comes back, the orientation is flipped on the AR, up is down and down is up, and the content is all over the place. So user flips camera, leaves scene, comes back to scene, tracking is upside down and backwards....

So in an awake function I manually set the camera to the back camera when the scene is loaded, but having to stop, deinit, init, start, adds significant delay to an already long load time due to the amount of content in the scene. 

 

Is there a fast way to reset the orientation quicker than this?? 

Switching device camera issue

July 14, 2015 - 4:23pm #2

What device and OS version are you experiencing this on?

Log in or register to post comments