Start a new topic

Show the target name as label when its recognised.

 I am using the following code for showing label for an recognised object.


var temp=new AR.Label("chair",0.2,{offsetY:-0.25,style:{textColor:'#00C100',backgroundColor:'#FFFFFF80'}});


        this.objectTrackable = new AR.ObjectTrackable(this.tracker, "*", {
            onObjectRecognized: function(targetName) {

            temp=new AR.Label(targetName,0.2,{offsetY:-0.25,style:{textColor:'#00C100',backgroundColor:'#FFFFFF80'}});


              World.hideInfoBar();


            },


            drawables: {
                cam: temp
            },


            onError: World.onError
        });
    },


But the label is not getting changed once its recognised. How to do this?


Hi,


This sounds more like a standard javascript implementation question that something related to the Wikitude SDK as such and its features. Did you make sure to debug the code to see what exactly is happening in the code? Also please make sure to check ObjectTrackable class and general documentation to make sure that the concepts are clear.


Thx and greetings

Nicola

I have tried this. But drawable value is not getting updated when I try to re assign it inside onObjectRecognized: property. I have even tried removing drawable before reassigning. But drawable is showing as before. It's not getting changed.
Yes I have gone through all general documents regarding object trackable. My question in a nutshell is how to dynamically update the drawable property of objecttrackable function so that I need not make a object tracker for each objects in a WTO file.

Hi,



are you sure your onObjectRecognized callback is invoked? It seems to me what you're trying to do is correct. Have you tried using the drawables.addCamDrawable and drawables.removeCamDrawable functions? If that does not work either, would you mind trying the exact same thing with image tracking instead?



- Daniel 

Its working now! I had to write World.objectTrackable.drawables.cam instead of this.objectTrackable.drawables.cam. Thanks for the support :)

Hi,



new AR.ObjectTrackable(..., {
    drawables: {
        cam: temp
    }
});


just initializes the trackable with your original label. For the change to happen you will need to re-set the cam drawables. Even though the temp variable might change on the JavaScript side, the Wikitude SDK needs to be informed of that change, it will not pick up on this automatically.


this.objectTrackable.drawables.cam = [temp];


Here's the corresponding API reference.



- Daniel

Login or Signup to post a comment