Log in or register to post comments

Multiple count for one cloud reco

March 10, 2014 - 9:45pm #1

Vuforia SDK Version: 2.8.7 -

Description with steps to reproduce:

 It can be readily replicated. I installed the sample app from Vuforia website on iphone 4S with iOS7 and cloud-reco'ed only once. After one day check the reco-count, it is increased by either 2 or 3. I used apple mac mini mavericks OS and xcode 5.

Notice that this is an important bug directly related to the pricing on cloud reco (i.e. 2x or 3x over-charge). Greatly appreciate your help.

-

Development OS (Mac OS X, Windows, Linux): Mac OS X Mavericks -

Mobile OS and Version: ios 7 -

Mobile Device Manufacturer and Model name: iphone 4S -

Do the Vuforia Sample Applications show the same behavior?: exactly the same behavior

Multiple count for one cloud reco

September 24, 2014 - 8:20am #15

I've checked with our team and the common understanding of this is that the number of reco events (what you refer to as "the extra calls") is not necessarily mapped 1-to-1 with the number of times a New Search Result is reported to the client SDK API;

this is because, essentially (and as I had outlined in my previous answer), if the reported image target (Search Result) happens to be same target (within a short time frame), then the SDK will be "smart" enough to only report it once (so that your Application code only neds to handle one target).

So, the issue is about  not confusing the "high-level" representation of recognized targets that the client SDK reports (in terms of Search Results API)  with the "low-level" (Cloud-backend related) number of recos that actually reflects the "actual usage" of the Cloud service, and for which you are accounted. 

However,

if you are thinkng that you would want / wish to have an additional API in the Vuforia SDK that simply reports the actual number of recognition events (as opposed to the Search Result reporting API), this is probably something that you could post in our Wish List, so that we could consider this enhancement for a future release of Vuforia.

 

 

Multiple count for one cloud reco

September 23, 2014 - 5:55am #14

Ok, now I see where is the problem and If I understand well, there's nothing to do with this issue (as a client) .

Is there any plan to solve that extra calls?

Take the case that I start paying the starter plan and I have 10k recos, and everytime (or some of the times) a user makes a reco it counts more than one. When I get to my plan limit, I'll have to pay for every extra reco made by my users, without having into account that many of that recos have been made because of this issue.

I'd like to add that the solution that stops the TargetFinder when the target is detected is not updated yet, at least in the sample I am using.

Thanks again, best regards.

Multiple count for one cloud reco

September 23, 2014 - 3:47am #13

Yes, you correctly stop Cloud Reco, which indeed will prevent further reco events from happening;

but the Cloud Recognition backend (which is acting on your Cloud DB) is not running on the same thread or process as your client app (in fact, the backend runs on the Cloud, not on the device) , so what could happen (and probably happens in your case) is that you 2 reco events are occurring in the backend during the scanning phase (i.e. while Cloud Reco is still active), i.e. BEFORE  the OnNewSearchResult callback is executed  on the client side (your app),  

(in fact, if the 2 reco events are  occuring close to each other in time,  the Vuforia API will only call once OnNewSearchResult API, as this callback is simply reporting the target to you.... and the target is actually the same)

i.e. in fact you already got 2 recos on the Cloud DB by the time that you call CloudReco.enabled = false and the TargetFinder gets stopped.

 

Multiple count for one cloud reco

September 23, 2014 - 3:20am #12

 

       // First clear all trackables
        mImageTracker.TargetFinder.ClearTrackables(false);
 
        // enable the new result with the same ImageTargetBehaviour:
        ImageTargetBehaviour imageTargetBehaviour = mImageTracker.TargetFinder.EnableTracking(targetSearchResult, mParentOfImageTargetTemplate) as ImageTargetBehaviour;
         
        // ADD THIS TO STOP CLOUD SCAN
        cloudRecoBehaviour.CloudRecoEnabled = false;
         
        //if extended tracking was enabled from the menu, we need to start the extendedtracking on the newly found trackble.
        if(CloudRecognitionUIEventHandler.ExtendedTrackingIsEnabled)
        {
            imageTargetBehaviour.ImageTarget.StartExtendedTracking();
        }

 

As I added this to OnNewSearchResult, I thought that CloudReco scan was stopped once this function is called.

Shouldn't this avoid extra calls? Sorry for my misunderstanding.

Thanks for your fast answer.

Multiple count for one cloud reco

September 23, 2014 - 2:43am #11

Hi,

as I said previously, as long as the TargetFinder is running (i.e. until you don't stop the CloudReco scan), you might incur in more than 1 reco event, even if the target in view is the same.

This can happen for example if you are moving the camera around while Cloud Reco is still scanning (as opposed to keeping it roughly steady above the target); the motion of the camera w.r.t. the target will result in new camera images to be scanned and if the image has changed significantly this may produce an additional reco event.

The OnNewSearchResult() callback in such a case however may be called only once, because the recognized image target is the same (so Vuforia will not fire a new OnNewSearchResult() in this case, because the target is the same). 

So, to summarize:

- during the scanning time frame it is possible to have more than one reco event if the camera moves w.r.t. the target (despite the OnNewSearchResult() being called only once)

- only after the end of the scanning time frame (i.e. after TargetFinder stops). you are guaranteed that there will not be any more reco events on the Cloud DB.

Note that there is no guarantee of a 1-to-1 mapping between the actual number of reco events and the number of OnNewSearchResult API calls;

in one of my previous posts I was mentioning the possibility of using the OnNewSearchResult as a way of counting the recos, but this was only meant as a verification method under the assumptions that I mentioned here above (i.e. camera steady on the target i.e. not moving significantly during the scanning process).

I hope this clarifies a bit better.

 

 

 

Multiple count for one cloud reco

September 23, 2014 - 1:44am #10

I'm experimenting the same problem with cloud recognition and I followed all the tips exposed here. 

Development OS: Mac OS X Mountain Lion

Mobile OS and Version: Android 4.4.2

Mobile Device Manufacturer and Model name: HTC One M7

Do the Vuforia Sample Applications show the same behavior?: exactly the same behavior

I am using Vuforia Unity Extension with last published cloud sample (cloudreco-3-0-10.unitypackage).

The only changes I've made in the sample are:

- debug line to know the times the function OnNewSearchResult is called.

- a line to stop TargetFinder as you explain in this other thread, as I didn't see that change on the provided code ( https://developer.vuforia.com/forum/cloud-recognition/cloud-reco-samples-reco-count )

/*==============================================================================
Copyright (c) 2012-2014 Qualcomm Connected Experiences, Inc.
All Rights Reserved.
==============================================================================*/

using System;
using UnityEngine;

/// <summary>
/// This MonoBehaviour implements the Cloud Reco Event handling for this sample.
/// It registers itself at the CloudRecoBehaviour and is notified of new search results as well as error messages
/// The current state is visualized and new results are enabled using the TargetFinder API.
/// </summary>
public class CloudRecoEventHandler : MonoBehaviour, ICloudRecoEventHandler
{
    #region PRIVATE_MEMBER_VARIABLES

    // ImageTracker reference to avoid lookups
    private ImageTracker mImageTracker;
    private ContentManager mContentManager;

    // the parent gameobject of the referenced ImageTargetTemplate - reused for all target search results
    private GameObject mParentOfImageTargetTemplate;
	
	private CloudRecoBehaviour cloudRecoBehaviour;

    #endregion // PRIVATE_MEMBER_VARIABLES



    #region EXPOSED_PUBLIC_VARIABLES

    /// <summary>
    /// can be set in the Unity inspector to reference a ImageTargetBehaviour that is used for augmentations of new cloud reco results.
    /// </summary>
    public ImageTargetBehaviour ImageTargetTemplate;

    #endregion

    #region ICloudRecoEventHandler_IMPLEMENTATION

    /// <summary>
    /// called when TargetFinder has been initialized successfully
    /// </summary>
    public void OnInitialized()
    {
        // get a reference to the Image Tracker, remember it
        mImageTracker = TrackerManager.Instance.GetTracker<ImageTracker>();
        mContentManager = (ContentManager)FindObjectOfType(typeof(ContentManager));
    }

    /// <summary>
    /// visualize initialization errors
    /// </summary>
    public void OnInitError(TargetFinder.InitState initError)
    {
        switch (initError)
        {
            case TargetFinder.InitState.INIT_ERROR_NO_NETWORK_CONNECTION:
                ErrorMsg.New("Network Unavailable", "Please check your internet connection and try again.", RestartApplication);
                break;
            case TargetFinder.InitState.INIT_ERROR_SERVICE_NOT_AVAILABLE:
                ErrorMsg.New("Service Unavailable", "Failed to initialize app because the service is not available.");
                break;
        }
    }
    
    /// <summary>
    /// visualize update errors
    /// </summary>
    public void OnUpdateError(TargetFinder.UpdateState updateError)
    {
        switch (updateError)
        {
            case TargetFinder.UpdateState.UPDATE_ERROR_AUTHORIZATION_FAILED:
                ErrorMsg.New("Authorization Error","The cloud recognition service access keys are incorrect or have expired.");
                break;
            case TargetFinder.UpdateState.UPDATE_ERROR_NO_NETWORK_CONNECTION:
                ErrorMsg.New("Network Unavailable","Please check your internet connection and try again.");
                break;
            case TargetFinder.UpdateState.UPDATE_ERROR_PROJECT_SUSPENDED:
                ErrorMsg.New("Authorization Error","The cloud recognition service has been suspended.");
                break;
            case TargetFinder.UpdateState.UPDATE_ERROR_REQUEST_TIMEOUT:
                ErrorMsg.New("Request Timeout","The network request has timed out, please check your internet connection and try again.");
                break;
            case TargetFinder.UpdateState.UPDATE_ERROR_SERVICE_NOT_AVAILABLE:
                ErrorMsg.New("Service Unavailable","The service is unavailable, please try again later.");
                break;
            case TargetFinder.UpdateState.UPDATE_ERROR_TIMESTAMP_OUT_OF_RANGE:
                ErrorMsg.New("Clock Sync Error","Please update the date and time and try again.");
                break;
            case TargetFinder.UpdateState.UPDATE_ERROR_UPDATE_SDK:
                ErrorMsg.New("Unsupported Version","The application is using an unsupported version of Vuforia.");
                break;
        }
    }

    /// <summary>
    /// when we start scanning, unregister Trackable from the ImageTargetTemplate, then delete all trackables
    /// </summary>
    public void OnStateChanged(bool scanning)
    {
        if (scanning)
        {
            // clear all known trackables
            mImageTracker.TargetFinder.ClearTrackables(false);

            // hide the ImageTargetTemplate
            mContentManager.ShowObject(false);
        }
    }
    
    /// <summary>
    /// Handles new search results
    /// </summary>
    /// <param name="targetSearchResult"></param>
    public void OnNewSearchResult(TargetFinder.TargetSearchResult targetSearchResult)
    {
		Debug.Log("New Search Result: " + targetSearchResult.TargetName);
        // This code demonstrates how to reuse an ImageTargetBehaviour for new search results and modifying it according to the metadata
        // Depending on your application, it can make more sense to duplicate the ImageTargetBehaviour using Instantiate(), 
        // or to create a new ImageTargetBehaviour for each new result

        // Vuforia will return a new object with the right script automatically if you use
        // TargetFinder.EnableTracking(TargetSearchResult result, string gameObjectName)
		
        //Check if the metadata isn't null
		
        if(targetSearchResult.MetaData == null)
        {
            return;
        }

        // First clear all trackables
        mImageTracker.TargetFinder.ClearTrackables(false);

        // enable the new result with the same ImageTargetBehaviour:
        ImageTargetBehaviour imageTargetBehaviour = mImageTracker.TargetFinder.EnableTracking(targetSearchResult, mParentOfImageTargetTemplate) as ImageTargetBehaviour;
		
		// ADD THIS TO STOP CLOUD SCAN
		cloudRecoBehaviour.CloudRecoEnabled = false;
		
        //if extended tracking was enabled from the menu, we need to start the extendedtracking on the newly found trackble.
        if(CloudRecognitionUIEventHandler.ExtendedTrackingIsEnabled)
        {
            imageTargetBehaviour.ImageTarget.StartExtendedTracking();
        }
    }

    #endregion // ICloudRecoEventHandler_IMPLEMENTATION
	


    #region UNTIY_MONOBEHAVIOUR_METHODS

    /// <summary>
    /// register for events at the CloudRecoBehaviour
    /// </summary>
    void Start()
    {
        // look up the gameobject containing the ImageTargetTemplate:
        mParentOfImageTargetTemplate = ImageTargetTemplate.gameObject;

        // intialize the ErrorMsg class
        ErrorMsg.Init();

        // register this event handler at the cloud reco behaviour
        cloudRecoBehaviour = GetComponent<CloudRecoBehaviour>();
        if (cloudRecoBehaviour)
        {
            cloudRecoBehaviour.RegisterEventHandler(this);
        }
    }

    /// <summary>
    /// draw the sample GUI and error messages
    /// </summary>
    void OnGUI()
    {
        // draw error messages in case there were any
        ErrorMsg.Draw();
    }

    #endregion UNTIY_MONOBEHAVIOUR_METHODS

    #region PRIVATE_METHODS
    
    // callback for network-not-available error message
    private void RestartApplication()
    {
        Application.LoadLevel("Vuforia-1-About");
    }
    #endregion PRIVATE_METHODS
}

In order to test this clearly, I made a new cloud database and created 3 new targets and recorded the whole process.

The following link contains the recorded video: http://youtu.be/VGWEITkgokg

I also attach the final console capture, where you will see that the first target (Test1) calls OnNewSearchResult twice, which I don't understand why but happens all the time I restart the application, even in Unity Editor, and the two other targets call the function only once.

If you check the other image, the count capture total is 5 and it should be 3 (or 4 having into account that first target is always being called twice)

I've experimented weird recognition recounts in other occasions, having 3 or 4 extra recos on targets that I only recognised once.

Hope you can give me an answer.

Regards.

AttachmentSize
Image icon console_capture.png274.26 KB
Image icon count_capture.png31.3 KB

Multiple count for one cloud reco

June 24, 2014 - 10:50am #9

As I explained in my previous message, You need to stop the Target Finder when a target is recognized, otheriwse Cloud Reco keeps scanning in the background and as you move the device around you might get additional reco events.

This practice is also shown in the samples in the latest 3.0.5 version.

 

Multiple count for one cloud reco

June 24, 2014 - 9:29am #8

I just have the same problerm!!!!

It's about 4 times more than I scan;

 

I have a count on my server,when  OnNew SearchResult() and  ratgetSerchResult.Metadata != null   I send a post to my server and make a count,  but the count is much more less than the vuforia cloud count on target manager !

Multiple count for one cloud reco

March 19, 2014 - 6:35am #7

Yes, for the sample, we have definitely taken your suggesion into account and we plan to upate it soon.

Multiple count for one cloud reco

March 17, 2014 - 11:09am #6

Dear Vuforia,

Thank you for your advice. I will try it out.

But my previous obervation was based on Vuforia's sample app with no modification. If that is the case, I believe Vuforia also needs to update its sample app to reduce unwanted cloud reco (which translates to unwanted charge on user).

I will update my findings soon. Thank you for your time.

Best Regards,

Peng

Multiple count for one cloud reco

March 17, 2014 - 4:22am #5

Quick update:

are you stopping the TargetFinder when the target is detected ? (i.e. in the callback in which you get the the TargetSearchResult) ?

if you don't stop the TargetFinder, the Cloud scanning will continue happening, and if for instance you move your device around (while scanning is ON), you may occasionally incur in more recognition events, which would then be reported in your Target Manager.

 

Multiple count for one cloud reco

March 13, 2014 - 2:39pm #4

I will try to reproduce / verify this issue, doing the same test

 

Multiple count for one cloud reco

March 13, 2014 - 12:27pm #3

Dear Vuforia,

Following your advice, I logged the TargetSearchResult. Two days ago I established a new target, cloud reco'ed it only once. Based on the log, the reco happened at 03-11 21:36:01. Today when I check the database, the count is 6! I used Vuforia's sample cloud reco app. If you ever tried it out, you can readily find this bug by yourself. Thank you.

Best Regards,

Peng

Multiple count for one cloud reco

March 11, 2014 - 1:51am #2

Hi,

how can you be sure that the app recognized the target only once ?

For example, if while using the App, the target gets lost (e.g. due to out-of-view or out-of-focus conditions), even for a small time, the target may need to be redetected, thus increasing the count. This could have easily happened once or twice, which would exlain the count of 2 or 3.

You can always verify this by adding some logs in the sample code, logging a message whenever a new TargetSearchResult is returned, then count the number of log messages.

 

Log in or register to post comments