Start a new topic
Solved

Random scene selection on image recognition.

Hello,


The effect i am trying to accomplish is a randomly selected scene from a small array of scenes to be displayed when a user scans the object they just purchased. The image of the items are going to be the same, slight modifications can be made to the time but we prefer not to have any tell tale signs if we can help it. Is there a way to inject this logic into the code for random scene selection with the ability to control the probability as well? Any tips or suggestion would be greatly appreciated. 


Hey Daniel,


Thank you for the detailed response! Yes that would work. I would need to probably set a timer or accept the first generated value as the true value. Either way you pointed me in the direction i needed. Thanks again.


Best

Hello Denis,



I believe that should be fairly easy to accomplish with a single image/object target.


The idea is to simply select a random augmentation/scene upon successful recognition. I'm assuming you are using the JavaScript SDK in one form or another because the question does not really make sense in the context of the native SDK.


I have something like the following in mind.



 

World.trackable = new AR.ImageTrackable(this.tracker, "some_image_target", {

    drawables: {

        cam: [some_default_augmentation]

    },

    onImageRecognized: function() {

        removePreviousAugmentation();

        addRandomAugmentation();

    }

});


removePreviousAugmentation: function() {

    World.trackable.drawables.removeCamDrawable(0);

}


addRandomAugmentation: function() {

    randomId = Math.random() * 10; // generate the random ID any way you like

    randomAugmentation = getAugmentationForId(randomId);

    World.trackable.drawables.addCamDrawable(randomAugmentation);

}


getAugmentationForId: function(id) {

    // choose from some container of augmentations

    return World.possibleAugmentations[id];

}



This will, however, select a new augmentation even if the tracking lost for just an instant. To keep the augmentation consistent in that case you would need to work with some sort of timer to re-use the existing augmentation for brief interruptions of tracking.


Will this work for your use case?



- Daniel



1 person likes this
Login or Signup to post a comment