Log in or register to post comments

camDevice.Init() and camDevice.Start()

February 28, 2018 - 5:15am #1

Hello,

I am experiencing an issue with Vuforia in Unity 2017.0.0f3 for iOS (on Mac) where when I go to init() and start() my camera after having stop()'d and deinit()'d my camera for a pause in Vuforia use, where the applications screen goes completely black and hangs for a second before returning to the application.

Has anybody else experienced this problem?

Is there a way to resolve?

This is what the code looks like for starting the camera:

CameraDevice camDevice = CameraDevice.Instance;

        if (camDevice != null && !camDevice.IsActive())

        {

            Debug.Log("got the camera instance - Starting the camera");

            camDevice.Init(CameraDevice.CameraDirection.CAMERA_BACK);

            camDevice.Start();

           

        }

 

This is what the code looks like for stopping the camera:

CameraDevice camDevice = CameraDevice.Instance;

        if (camDevice != null && camDevice.IsActive()) {

            Debug.Log("got the camera instance - Stopping the camera");

            camDevice.Stop();

            camDevice.Deinit();

        }

 

Thanks in advance!

camDevice.Init() and camDevice.Start()

February 28, 2018 - 9:55am #2

Hello oliverRandom42,

Could you try also stopping and starting the tracker here and see if that helps? For reference, here is a function from the samples that restarts the camera.

public bool RestartCamera(CameraDevice.CameraDirection direction)
    {
        ObjectTracker tracker = TrackerManager.Instance.GetTracker<ObjectTracker>();
        if (tracker != null)
        {
            tracker.Stop();
        }
        CameraDevice.Instance.Stop();
        CameraDevice.Instance.Deinit();

        if (!CameraDevice.Instance.Init(direction))
        {
            Debug.Log("Failed to init camera for direction: " + direction.ToString());
            return false;
        }
        if (!CameraDevice.Instance.Start())
        {
            Debug.Log("Failed to start camera for direction: " + direction.ToString());
            return false;
        }

        if (tracker != null)
        {
            if (!tracker.Start())
            {
                Debug.Log("Failed to restart the Tracker.");
                return false;
            }
        }

        return true;
    }

Thanks,

Vuforia Support

Log in or register to post comments