Topic locked

Switching cloud database access key and secret key

June 24, 2014 - 9:07pm #1

Hi there! 

I am thinging of switching vuforia cloud database, access key and secret key, in my application during run time.  Doing so, i can category image target to be tracking to avoid confused tracking when there are many uploaders upload the same or similare image target. 

I am using the following code  but it  works only when i assign values within start function

 

			mCloudRecoBehaviour.enabled = false;
			mCloudRecoBehaviour.AccessKey = "";
			mCloudRecoBehaviour.SecretKey = "";
			mCloudRecoBehaviour.enabled = true;

 

Switching cloud database access key and secret key

July 14, 2014 - 11:50pm #4

You're welcome.

Switching cloud database access key and secret key

July 14, 2014 - 6:40pm #3

Thank you alot AlessandroB, it's such an excellent help.

Switching cloud database access key and secret key

June 27, 2014 - 4:56am #2

Hi,

for a scenario like this, the cleanest option is to re-initialize the TargetInder with the new keys, and then start it again;

so, first you need to Stop and Deinit the Cloud Reco TargetFinder :

if ( GUI.Button (new Rect (100,300,200,50), "Switch Cloud Database")) {			
  ImageTracker itr = TrackerManager.Instance.GetTracker<ImageTracker>();
  if (itr.TargetFinder.Stop ())
  {
	mRecoWasStopped = true;
  }
  itr.TargetFinder.Deinit();

if (itr.TargetFinder.StartInit(" YOUR_NEW_DB_ACCESS_KEY ", 
				           " YOUR_NEW_DB_SECRET_KEY "))
{
	Debug.Log (" TargetFinder --> StartInit with new keys is OK");
}

then, you can add some code to your MonoBehaviour "void Update()" method to Start the Recognition, for example:

if  ( mRecoWasStopped )
{
    Debug.Log ("--> TargetFinder Trying to Restart Recognition.......");
    ImageTracker itr = TrackerManager.Instance.GetTracker<ImageTracker>();
    if (itr.TargetFinder.StartRecognition())
    {
	Debug.Log ("==== TargetFinder StartRecognition OK");
	mRecoWasStopped = false;
   }
}

In the code above, you will need to define a variable:

bool mRecoWasStopped.

I tested this approach and verified that it works.

I hope this helps.

 

Topic locked