RSS

Vuforia: Delayed Initialization Explained

11 Dec

Vuforial is a widely used AR toolkit, and if you use it for some time, you will find “Delayed Initialization” for sure.

image

You would like to try it, right?

Go and do it, cry please, you will see below errors:

Vuforia cannot be started before it is initialized.Please disable Delayed Initialization in the Vuforia configuration or initialize Vuforia manually with the VuforiaRuntime-class.

image

You would Google this, frustrated, as you can hardly find good answers, and here is why this article comes into play.

Why you prefer the delayed initialization? Simple, your app does not always start from an AR mode, and maybe you have a button , and only when you click button, do you start the target recognition.

A 2nd reason for delayed initialization is the speed, you don’t want to start from the AR mode, and then manually disable it, right?

A 3rd reason, if you start by initialize the AR mode, and then disable it, you will see your camera’s light flashes, though it is very quick. Connect your web cam, run a Vuforia powered app with default settings, you will see that clearly:

ezgif.com-cropCool. We need you, delayed initialization. But how?

To enable this, first you need turn off a script first:

  • Select your ARCamera object
  • You will see a “Vuforia Behaviour (Script)” component
  • Disable this component
  • Enable/Check delayed initialization option in Vuforia Configuration Panel

image

Run it. Aha, it worked! No errors, no warning, no camera flashes, super fast!

Go and grab a coffee. Emm, let’s turn on the AR mode and start Vuforia again when needed. It is not as easy as imagined:

  • Disable/Uncheck delayed initialization programmatically
    VuforiaAbstractConfiguration.Instance.Vuforia.DelayedInitialization = false;
  • Enable the “Vuforia Behaviour (Script)” component, programmatically
    ARCamera.GetComponent<VuforiaBehaviour>().enabled = true;

Cry again, it does not work!

So to manually start/initialize Vuforia again, there is a simple trick, read the aforementioned warning message, you will see:

initialize Vuforia manually with the VuforiaRuntime-class.

So just use below code when you click button, to start the target recognition:

                      VuforiaRuntime.Instance.InitVuforia();

That is it! Happy coding!

One bonus you will see is that, when you start and then stop the App, if you don’t use delayed initialization, you will see below errors:


image

If you use delayed initialization, for whatever reasons, the above errors are gone. Weird? Cool? You can tell …

Advertisements
 
1 Comment

Posted by on December 11, 2017 in Programming, Unity 3d, Vuforia (QCAR)

 

Tags: , , , , ,

One response to “Vuforia: Delayed Initialization Explained

  1. Fatin Nawaz

    April 9, 2018 at 10:06 pm

    Can you help me with this? It’s still not working

     

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

 
%d bloggers like this: