Start a new topic
Solved

Cloud recognition continues image recognition is not working as expected.

I have the following code and I know for a fact that I have valid target ids as I have tested this with Manager API and they indeed return targets with valid data. I have personally created targets with images. However, The image recognition never recognizes my targets. I am following the sample code for continues recognition and my code is as follows:


   

initTargets: function() {

    World.cloudRecognitionService = new AR.CloudRecognitionService(clientToken, World.targetCollectionId, {
      onInitialized: this.trackerLoaded,
      onError: this.trackerError
    });

    World.tracker = new AR.ImageTracker(World.cloudRecognitionService, {
      onTargetsLoaded: World.loadingStepDone,
      onError: World.errorLoading
    });

  },
  trackerLoaded: function trackerLoadedFn() {
    World.startContinuousRecognition(750);
  },
  trackerError: function trackerErrorFn(errorMessage) {
    alert(errorMessage);
  },
  startContinuousRecognition: function startContinuousRecognitionFn(interval) {
    this.cloudRecognitionService.startContinuousRecognition(interval, this.onInterruption, this.onRecognition, this.onRecognitionError);
  },
  onInterruption: function onInterruptionFn(suggestedInterval) {
    World.cloudRecognitionService.stopContinuousRecognition();
    World.cloudRecognitionService.startContinuousRecognition(suggestedInterval);
  },
  onRecognition: function onRecognitionFn(recognized, response) {
    if (recognized) {

      var thisTarget = _.find(World.targets, { title: response.targetInfo.name });
      if (thisTarget.overlays && thisTarget.overlays.length > 0) {
        var overlay = thisTarget.overlays[0];

        var overlayImageResource = new AR.ImageResource(overlay.imageUrl, {
          onLoaded: World.loadingStepDone,
          onError: World.errorLoading
        });

        var overlayImageDrawable = new AR.ImageDrawable(overlayImageResource, 5, {
          onClick: World.overlayClicked,
          translate: overlay.translate,
          scale: overlay.scale,
          rotate: overlay.rotate
        });

        if (World.spaceAugmentation !== undefined) {
          World.spaceAugmentation.destroy();
        }
        World.spaceAugmentation = new AR.ImageTrackable(World.tracker, '*' , {
          drawables: {
            cam: overlayImageDrawable
          }
        });
      }
    }
  },
  onRecognitionError: function onRecognitionErrorFn(errorCode, errorMessage) {
    alert("error code: " + errorCode + " error message: " + JSON.stringify(errorMessage));
  }

  My initTargets is called when I get my data from my server and data is indeed available. Not exactly sure what am I doing wrong here. I had a custom 7.1 version of the SDK as there was a minor bug in the current stable version. I did also changed that back to the stable version but unfortunately that did not help either...


Hi there again. I really appreciate you guys helping out with these issues. It is greatly appreciated. We have fallen behind schedule because of this issue and the sooner we can find a solution the better. If you guys need me to provide you guys with targetCollectionId or anything at all please let me know.


Thx.

Hello Farshid,

You are testing with our SDK 7.1 but can you also tell me which platform you are using (Javascript, Native, extensions)? Also, please tell me exactly what is your issue - for example the target is never recognized? Finally, did you try with our sample to see if this is working for you? You mention that you customized the 7.1 version, did you make sure to follow the exact steps reported here?

Thanks
Eva

 

This is on JavaScript iOS. The issue is that the target is never recognized even though onRecognition is called but recognized variable is always 0. 


The clientId and targetCollectionId in your sample project doesn't authenticate nor work. I believe my example is quiet the the same as your sample only with different targets and targetCollection.

Finally, How can I run your example without the proper clientId?? 


thx

using Wikitude's sample example now I get the following error:

"errorMessage": "CloudTracker could not initialize target collection 'MyValidTargetCollectionId' with client token 'MyValidClientToken'."


Eva, can you please address this issue? We have been waiting for a week without being able to move forward. Thanks.


Patrick

Hello,

it looks like you use the wrong tokens. Check your target collection id again because 'MyValidTargetCollectionId' is an invalid id. Also check your client token in the studio manager in your account settings dialog (user icon top right -> settings)

Regards,

Christian

Hi,


I was just letting you guys know that for some reason your sample code was throwing the previous error regarding the token.  My token is actually valid because it doesn't throw the invalid token error in my first sample code.  


My main problem is the sample code I initially provided on this thread. If you could address that issue, it'd be a great help.


Thanks

Are you sure that your target collection has been published to the cloud? If you use the API to create the targets you'd need to use call the 'generate cloud archive'-endpoint to publish your project into the cloud, or press the cloud icon in the studio manager in your target collection.


Regards,

Christian

Thanks a lot. That did it! I don't know how I missed that part of the documentation.... I appreciate you guys taking the time

Login or Signup to post a comment