Start a new topic

OnTargetsLoaded not being called

I have tried to create a simple app, but can't get the image tracking to work.

I'm using Xamarin to create an android app.

We start an architectView in our MainActivity for simplicity. The architectView loads fine, the camera turns on, the HTML loads fine, and the javascript file runs. 

However, the onTargetsLoaded delegate method is never called, the "loading" bar never vanishes, and image recognition doesn't start. If we call the delegate method manually before or after the call to create a new AR.ImageTracker, the delegate works as expected, and hides the loading bar. 

Our OnError function is not called either. Our javascript code is as follows:


//// Initialize ImageTracker
//// Important: If you replace the tracker file with your own, make sure to change the target name accordingly.
//// Use a specific target name to match only a certain target or use a wildcard to match any or a certain group of targets.

//this.targetCollectionResource = new AR.TargetCollectionResource("assets/", {
//this.tracker = new AR.ImageTracker(this.targetCollectionResource, {
//    onTargetsLoaded: this.worldLoaded

//// Create overlay for page one
//var imgOne = new AR.ImageResource("assets/annebrerot02.jpg");
//var overlayOne = new AR.ImageDrawable(imgOne, 1, {
//    translate: {
//        x: -0.15,
//    }

//var pageOne = new AR.ImageTrackable(this.tracker, "*", {
//    drawables: {
//        cam: overlayOne
//    }

var World = {

    init: function initFn() {

    createOverlays: function createOverlaysFn() {
            First a AR.TargetCollectionResource is created with the path to the Wikitude Target Collection(.wtc) file.
            This .wtc file can be created from images using the Wikitude Studio. More information on how to create them
            can be found in the documentation in the TargetManagement section.
            Each target in the target collection is identified by its target name. By using this
            target name, it is possible to create an AR.ImageTrackable for every target in the target collection.
        this.targetCollectionResource = new AR.TargetCollectionResource("wikitude_assets/", {
            onError: World.onError

            This resource is then used as parameter to create an AR.ImageTracker. Optional parameters are passed as
            object in the last argument. In this case a callback function for the onTargetsLoaded trigger is set. Once
            the tracker loaded all of its target images this callback function is invoked. We also set the callback
            function for the onError trigger which provides a sting containing a description of the error.
        this.tracker = new AR.ImageTracker(this.targetCollectionResource, {
            onTargetsLoaded: World.showInfoBar,
            onError: World.onError

            The next step is to create the augmentation. In this example an image resource is created and passed to the
            AR.ImageDrawable. A drawable is a visual component that can be connected to a Trackable
            (AR.ImageTrackable, AR.InstantTrackable or AR.ObjectTrackable) or a geolocated object (AR.GeoObject). The
            AR.ImageDrawable is initialized by the image and its size. Optional parameters allow for transformations
            relative to the recognized target.

        /* Create overlay for page one of the magazine. */
        var imgOne = new AR.ImageResource("wikitude_assets/annebrerot02.jpg", {
            onError: World.onError
        var overlayOne = new AR.ImageDrawable(imgOne, 1, {
            translate: {
                x: -0.15

            The last lines combine everything by creating an AR.ImageTrackable with the previously created tracker,
            the name of the image target and the drawable that should augment the recognized image.

            Important: If you replace the tracker file with your own, make sure to change the target name accordingly.
            Use a specific target name to respond only to a certain target or use a wildcard to respond to any or a
            certain group of targets.
        this.pageOne = new AR.ImageTrackable(this.tracker, "pageOne", {
            drawables: {
                cam: overlayOne
            onImageRecognized: World.hideInfoBar,
            onError: World.onError

    onError: function onErrorFn(error) {
        document.getElementById("loadingMessage").textContent = "FEJL"

    hideInfoBar: function hideInfoBarFn() {
        document.getElementById("infoBox").style.display = "none";

    showInfoBar: function worldLoadedFn() {
        document.getElementById("infoBox").style.display = "table";
        document.getElementById("loadingMessage").style.display = "none";


 The assets are in a folder called "wikitude_assets", a subfolder of where the javascript file is. I have tried with the file from the xamarin samples (they work fine on my phone), and with my own wtc file, but neither seems to load properly. 

My ArchitectStartupConfiguration is as follows:


var experience = new ArExperience(
				camera2Enabled: true

			var startupConfiguration = new ArchitectStartupConfiguration // Creates a config with its default values.
				LicenseKey = Constants.WIKITUDE_SDK_KEY, // Has to be set, to get a trial license key visit
				CameraPosition = Com.Wikitude.Common.Camera.CameraSettings.CameraPosition.Back, // The default camera is the first camera available for the system.
				CameraResolution = Com.Wikitude.Common.Camera.CameraSettings.CameraResolution.Auto, // The default resolution is 640x480.
				CameraFocusMode = Com.Wikitude.Common.Camera.CameraSettings.CameraFocusMode.Continuous, // The default focus mode is continuous auto focus.
				Camera2Enabled = true, // The camera2 api is enabled by default on devices that support it.
				ArFeatures = (int)experience.FeaturesMask // This tells the ArchitectView which AR-features it is going to use, the default is all of them.

			architectView = new ArchitectView(this);
			SetContentView(architectView); // Adds the architectView to the activity.

 I've been looking for solutions for the past two days, and honestly have no idea what the problem is.

We're using the Wikitude nuget package in the project, which we got from the Nuget Package Manager in Visual Studio.  

1 Comment

We found the problem. Turns out, we forgot to change the name of the target image in the line starting with this.pageOne. We changed the name to that of the image in our target collection, and everything suddenly worked.

Login or Signup to post a comment