Start a new topic

Cloud Continuous Recognition

Cloud Continuous Recognition


Hi,

I'm having trouble on cloud continuous recognition. Everytime i try to scan targets, only the first one can be scanned. I can't retrieve response for the next scans. I'm using sample code from Wikitude SDK Sample, and this is my code so far.

===============================================================================

var World = {
    tracker: null,

    init: function initFn() {
        this.createTracker();
        this.createOverlays();
    },

    createTracker: function createTrackerFn() {
        World.tracker = new AR.CloudTracker("__CLIENT_TOKEN__", "__TARGET_COLLECTION_ID__", {
            onLoaded: this.trackerLoaded,
            onError: this.trackerError
        });
    },
    startContinuousRecognition: function startContinuousRecognitionFn(interval) {
        this.tracker.startContinuousRecognition(interval, this.onRecognition, this.onRecognitionError, this.onInterruption);
    },

    trackerError: function trackerErrorFn(errorMessage) {
        alert(errorMessage);
    },

    createOverlays: function createOverlaysFn() {
        // Create overlay
        
    },

    onRecognition: function onRecognitionFn(recognized, response) {
        if (recognized) {
            var cssDivInstructions = " style='display: table-cell;vertical-align: middle; text-align: right; width: 50%; padding-right: 15px;'";
            document.getElementById('loadingMessage').innerHTML =
                "<div" + cssDivInstructions + ">"+response.targetInfo.name+"</div>";
        }
    },

    onRecognitionError: function onRecognitionErrorFn(errorCode, errorMessage) {
        alert("error code: " + errorCode + " error message: " + JSON.stringify(errorMessage));
    },

    onInterruption: function onInterruptionFn(suggestedInterval) {
        World.tracker.stopContinuousRecognition();
        World.tracker.startContinuousRecognition(suggestedInterval);
    },

    trackerLoaded: function trackerLoadedFn() {
        World.startContinuousRecognition(750);
        World.worldLoaded();
    },

    worldLoaded: function worldLoadedFn() {
        var cssDivInstructions = " style='display: table-cell;vertical-align: middle; text-align: right; width: 50%; padding-right: 15px;'";
        document.getElementById('loadingMessage').innerHTML =
                "<div" + cssDivInstructions + ">Scan any image targets</div>";
    }
};

World.init();

=====================================================================

I try to show the response.targetInfo.name on div, but only the first scan can be shown, the rests are failed.

Is there any ways to achieve that?

 

Regards

 

So the code from the sample app is working as expected but using the same with your WTC makes troubles?
If so please check the WTC file you created (especially the rating of the used target images) and ensure to use latest SDK version.
In case you have issues with the sample app itself please post details about the used device, OS and Wikitude Version.

Yes, that's exactly the problem. the samples work fine, but the cloud continuous recognition doesn't work with my WTC.

All my target images has 2 stars rating, and it works fine on offline image recognition.

Anyway, I'll try to use latest SDK version, hope it will work somehow.

Thanks.

I have found the solution. On my previous code I haven't defined AR.Trackable2DObject. So I change my code to

...
onRecognition: function onRecognitionFn(recognized, response) {
if (recognized) {
if (World.trackable2DObject!== undefined) {
World.trackable2DObject.destroy();
}

World.trackable2DObject= new AR.Trackable2DObject(World.tracker, response.targetInfo.name , {
drawables: {
cam:
},
onEnterFieldOfVision: function onEnterFieldOfVision(targetName) {
document.getElementById('loadingMessage').innerHTML =
                   "<div>targetName: "+targetName+"</div>";
}
});
}
},
...


 

and the problem's gone.

 

Thanks
Login or Signup to post a comment