Log in or register to post comments

Pause/Resume AR without camera stop

May 19, 2014 - 4:03am #1

Hi,

 

I would like to be able to pause the AR engine, still getting the camera rendering. 

The documentation is not very usefull : 

https://developer.vuforia.com/sites/default/files/doxygen/12-16-2013-05-43-59_doxygen/publicAPI/nav_f.png); background-color: rgb(221, 236, 238); background-repeat: repeat no-repeat;">
static void com.qualcomm.vuforia.Vuforia.onResume (  ) [static]

Executes AR-specific tasks upon the onResume activity event

https://developer.vuforia.com/sites/default/files/doxygen/12-16-2013-05-43-59_doxygen/publicAPI/nav_f.png); background-color: rgb(221, 236, 238); background-repeat: repeat no-repeat;">
static void com.qualcomm.vuforia.Vuforia.onPause (  ) [static]

Executes AR-specific tasks upon the onResume activity event

 

Can I know more about that please ?

Thanks !

Pause/Resume AR without camera stop

March 21, 2018 - 6:52am #7

OK. After some research I did this.

Just copy the next Script in a new script and call it "RecognitionSwitch" (or whatever you want, as long as it has same class name and script name):

 

using UnityEngine;
using Vuforia;

public class RecognitionSwitch: MonoBehaviour
{
    private void Start()
    {
        PauseVuforia(false); // So to be sure when app starts, recognition will work.
    }

    static public void PauseVuforia(bool what)
    {
        Tracker imageTracker = TrackerManager.Instance.GetTracker<ObjectTracker>() as ObjectTracker;
        if (imageTracker != null)
        {
            if (what)
            {
                imageTracker.Stop();
                Debug.Log("Recognition Stopped");
            }
            else
            {
                imageTracker.Start();
                Debug.Log("Recognition Started");
            }
        }       
    }
}

Then you can turn on / off recognition from any script in your project as soon as you call:

RecognitionSwitch.PauseVuforia(true); // Pause recognition
RecognitionSwitch.PauseVuforia(false); // Start recognition

You do not have to attach the script to any gameObject because it uses Singletons and PauseVuforia is Static, so the whole thing is one switch for your whole project!

Pause/Resume AR without camera stop

June 15, 2015 - 2:08am #6

@AlessandroB

Hi,I tried your code but it doesnt work.

ImageTracker is not recognize So I used ObjectTracker instead of ImageTracker.
Still it doesnt work.

My code is here

Tracker imageTracker = TrackerManager.getInstance().getTracker(
ObjectTracker.getClassType());
if (imageTracker != null)
imageTracker.stop();
 
Please help

 

 

Pause/Resume AR without camera stop

June 13, 2014 - 5:56am #5

Thanks :-)

Pause/Resume AR without camera stop

June 13, 2014 - 3:35am #4

When you stop the Tracker, all the currently tracked targets are lost, and when you restart it, the engine will try to detect again those targets fom scratch; so, if this is what you mean with "reset", it could work indeed. However, note that if a Pose of a target is not fully satisfactory in some circumstances, restarting the Tracker might not be the solution, as there are also other factors involved; for example, your camera might be slightly out of focus w.r.t. the Target ...in that case, you may want to consider Triggering an Autofocus instead of restarting the Tracker.... see also:

https://developer.vuforia.com/resources/dev-guide/continuous-autofocus-and-other-focus-modes

https://developer.vuforia.com/forum/faq/how-can-i-improve-detection-and-tracking-stability

 

Pause/Resume AR without camera stop

June 13, 2014 - 2:42am #3

Hi !

 

Will the start-stop reset the tracker datas ?

I mean : sometimes the pose is not good, not well oriented, and we would like to make a "reset" instead of moving the camera far from the marker to force it.

 

thanks.

Pause/Resume AR without camera stop

May 21, 2014 - 11:46pm #2

Hi, 

you can do this by stopping the Trackers;  if you look at the sample code (e.g. in ImageTargets), you can find some code like this:

 // TO START the TRACKER       
Tracker imageTracker = TrackerManager.getInstance().getTracker(
            ImageTracker.getClassType());
if (imageTracker != null)
      imageTracker.start();
            
    
   // TO STOP the TRACKER     
  Tracker imageTracker = TrackerManager.getInstance().getTracker(
            ImageTracker.getClassType());
   if (imageTracker != null)
            imageTracker.stop();
   

If you are using FrameMarkers, you will need to do the same with the MarkerTracker class.

Note: the trackers must have bee initialized (see sample code for tracker init / deinit).

 

Log in or register to post comments