Start a new topic

Two ImageTracker

Hi, do you have an example on how to switch between trackers? I have two trackers and I cant make it enable/disable. Thank you


1 person has this problem

Hi Katrina,


Please refer to the documentation section here https://www.wikitude.com/external/doc/documentation/latest/android/imagerecognition.html#different-targets to see how you can switch between two different image trackers.


Thanks

Eva

Hi, I understand that multiple trackers can be done but how can I switch between trackers?

 

Hi Katrina,


The example I provided above shows how you can switch between two different Image Targets. So when you refer to trackers, do you mean Image Targets or do you mean .wtc file?


Thanks

Eva

Hi,


I meant two wtc.

Hi Katrina,


Since our sdk only allows a single tracker (.wtc), you just need to create a new tracker (with the new wtc). Please refer to the documentation section here https://www.wikitude.com/external/doc/documentation/latest/Reference/JavaScript%20API/classes/ImageTracker.html and also see below code to better understand how it works.


// a Tracker referencing a target collection on a server
var targetCollection1 = new AR.TargetCollectionResource("http://myserver.com/targetCollection1.wtc");
var tracker1 = new AR.ImageTracker(resource1 , {
  onDisabled : function(){
    //tracker has been disabled by the system
  }
});
var enabled = tracker1.enabled; //true

// a second tracker, which will cause tracker1 to be disabled
var targetCollection2 = new AR.TargetCollectionResource("http://myserver.com/targetCollection2.wtc");
var tracker2 = new AR.ImageTracker(resource2);

enabled = tracker1.enabled; //false
enabled = tracker2.enabled; //true


Eva

Login or Signup to post a comment