Log in or register to post comments

Flipped front camera

February 23, 2018 - 1:35am #1

By using the front camera in mode without finding the marker it turns over (flipped) the objects of the scene upside down. Objects are placed in front of the camera. How it’s possible to make the placement of the objects in front mode of the camera in the same way like they are placed in mode of back camera (with no turning them upside down)?

Thanks in advance!

P.S.: we have tried to do as it was described in the following topic, unfortunately it has caused another problem: in the front camera mode it doesn’t placed the objects on the marker, but mirrors them to the opposite side

 

 

 

 

private VuforiaBehaviour vuforiaBehaviour;

    void Start()

    {

        vuforiaBehaviour = (VuforiaBehaviour)FindObjectOfType(typeof(VuforiaBehaviour));

    }

    public void SwapCamera()

    {

        CameraDevice.CameraDirection currentDir = CameraDevice.Instance.GetCameraDirection();

        if (currentDir == CameraDevice.CameraDirection.CAMERA_BACK || currentDir == CameraDevice.CameraDirection.CAMERA_DEFAULT)

        {

            RestartCamera(CameraDevice.CameraDirection.CAMERA_FRONT, false);

            StartCoroutine(TriggerAutoFocusAndEnableContinuousFocusIfSet());

        }

        else

        {

            RestartCamera(CameraDevice.CameraDirection.CAMERA_BACK, false);

            StartCoroutine(TriggerAutoFocusAndEnableContinuousFocusIfSet());

        }

    }

    private IEnumerator TriggerAutoFocusAndEnableContinuousFocusIfSet()

    {

        CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_TRIGGERAUTO);

        yield return new WaitForSeconds(1.0f);

        CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO);

    }

    private void RestartCamera(CameraDevice.CameraDirection newDir, bool mirror)

    {

        CameraDevice.Instance.Stop();

        CameraDevice.Instance.Deinit();

        CameraDevice.Instance.Init(newDir);

        var config = VuforiaRenderer.Instance.GetVideoBackgroundConfig();

        config.reflection = mirror ? VuforiaRenderer.VideoBackgroundReflection.ON : VuforiaRenderer.VideoBackgroundReflection.OFF;

        VuforiaRenderer.Instance.SetVideoBackgroundConfig(config);

        CameraDevice.Instance.Start();

    }

Log in or register to post comments