Log in or register to post comments

Dynamically Loading and Activating Datasets

March 5, 2018 - 2:41pm #1

Hello all,

With the launch of Model Targets and its restriction of only a single Model Target dataset being activated at a time, we have seen an increase in the number of questions related to loading and activating datasets programmatically.

I've attached a script to this post that provides two examples for doing this. One function within this script will de-activate all currently active datasets in your project and then activate the dataset given in the function's signature. The second function will directly load and activate a single dataset without de-activating any others. The script contains additional information about the process via in-line comments.

Please note that the file is attached as a .txt. You'll need to change the extension to .cs in order for it to work within your project.

Also note that the provided script is only meant as an example and not a comprehensive guide. For additional information on loading and activating datasets, please refer to the library and api documentation.

Thanks,

Vuforia Support

AttachmentSize
Plain text icon LoadDataset.txt2.72 KB

Dynamically Loading and Activating Datasets

October 22, 2021 - 10:22am #8

Thank you so much for your answer!

I think it's getting clearer how targets work, but to be honest the Vuforia Core Samples are kind of daunting. Working with Trained (Advanced) Model Targets it's difficult to understand how to switch focus from one target to another when a target has started being tracked. If I code Destroy(firstTarget) after being finished with actions related to firstTarget, it will disengage firstTarget so that I can continue looking for the other targets, but then how do you initiate the same target again? And is there maybe a way to disengage a tracked target without having to destroy the gameObject?

Dynamically Loading and Activating Datasets

October 21, 2021 - 10:35am #7

Hello,

anagrams wrote:

I am wondering if maybe there is something I am missing in this definition of what is possible: What is the difference between tracking and detecting?

Detection is an object being "found" by Engine SDK in the camera's field of view (FOV), and returning an initial 6DoF pose. Tracking is the continued, real-time return of 6DoF poses from the object that was detected. Note that detection usually takes 1-2 camera frames (very brief), while tracking is continuous while the object is in the camera's FOV.

In the case of Advanced Model Targets, several Model Targets can be bundled into a single device database. When that database is activated, Engine SDK will try to detect all the targets in that database. However, once a target from that set is detected, only one of the targets can be tracked at any given time.

anagrams wrote:

I only need to recognize one model target and perform a full screen action (play a video) and then if another model target appears when back in main screen (after the video), switch to that. I have no need for several at the same time but then how do you switch between them if you cannot track them all at the same time? When I try using more than one model target in my program it will only detect the first one in chronology in Unity, the others are initialized, but never tracked/detected.

My understanding is that you can only activate a single device database containing Model Targets at any given time. Untrained (non-Advanced) Model Targets can only have one object in the device database. Trained (Advanced) Model Targets are recommended for a maximum of 20 objects.

It sounds like a decision on how to create the UX. You could have the user actively select the object and thus you'd activate the corresponding Untrained device database, or you can use a trained device database that contains multiple objects. The SDK will 'detect' the targets in the camera's view, and then it is up to application logic on which one to track.

This use case is covered in the Core Samples (corrected link below), so I suggest your review that Unity Project for more details.

anagrams wrote:

By the way, the second link you sent does not work.

Thanks. Looks like the ending period was included in the URL. Please try this:

https://assetstore.unity.com/packages/templates/packs/vuforia-core-samples-99026

Thanks,

Vuforia Engine Support

Dynamically Loading and Activating Datasets

October 20, 2021 - 2:52pm #6

Thank you for your help! I have gone over to using Advanced Model Targets, but still it doesn't seem like it is possible to recognize several model targets even though I just need to recognize one at a time. I am wondering if maybe there is something I am missing in this definition of what is possible: What is the difference between tracking and detecting? I only need to recognize one model target and perform a full screen action (play a video) and then if another model target appears when back in main screen (after the video), switch to that. I have no need for several at the same time but then how do you switch between them if you cannot track them all at the same time? When I try using more than one model target in my program it will only detect the first one in chronology in Unity, the others are initialized, but never tracked/detected.

By the way, the second link you sent does not work.

Dynamically Loading and Activating Datasets

October 20, 2021 - 9:46am #5

Hello,

Untrained Model Targets only supports the detection and tracking of a one (1) Model Target at a time: https://library.vuforia.com/model-targets/how-create-model-target

If you're looking for the ability to package multiple Model Targets in the same device database, you can use Advanced Model Targets. However, this still has the same limitation as it can only track a single Model Target at any given time, but it can detect multiple Model Targets: https://library.vuforia.com/model-targets/advanced-model-target-databases

I strongly suggest that you closely review our free Unity Core Samples for best coding practices when using Untrained Model Targets and Advanced Model Targets: https://assetstore.unity.com/packages/templates/packs/vuforia-core-samples-99026.

Thanks,

Vuforia Engine  Support

 

 

Dynamically Loading and Activating Datasets

October 19, 2021 - 12:00pm #4

Hi, is there anyone that has been able to replicate this code for Vuforia 10? I am new to vuforia and struggling to turn this example code into Vuforia10.

I'm having a lot of trouble trying to scale my project up from 1 model target to 3 (or even 2) to be detected one at a time.

When I try adding more than one model target I get this "Exception in callback: Failed to activate observer for behaviour "myTarget"".

I was hoping to fix it with some dynamic loading and activating but am new to both Vuforia and Unity and am having trouble adjusting this code to Vuforia10.

Hope someone can help me or direct me to the right place to ask if it's not here. Thank you!

 

I'm using Vuforia 10.2 in Unity 2020.3.19f1 

Attached is a picture of the error message.

AttachmentSize
Image icon Screenshot 2021-10-19 at 20.55.34.png243.68 KB

Dynamically Loading and Activating Datasets

May 31, 2018 - 12:21am #3

This helped me as even with having only one model target (and no other targets, not event the mars sample even present in the unity project) nothing got activated (licence, latest tools, everything checked). 

Only activating on load with your script helped :/.

Dynamically Loading and Activating Datasets

April 6, 2018 - 7:56am #2

Thanks so much! :D

Log in or register to post comments