Log in or register to post comments

Stop tracking

September 20, 2011 - 10:24am #4

Hello,

I would like to know if it is possible to stop the tracking but still keep getting the camera image.

I tried to comment the line:
QCAR::Tracker::getInstance().start(); on the Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_startCamera method and also tried the QCAR::Tracker::getInstance().start(); in a diferrent call but I stop receiving the camera image.

Thanks in advance,
Pedro

Re: Stop tracking

September 21, 2011 - 9:47am #3

The tracker has to be running to deliver the camera image, but you can deactivate ImageTarget or Marker tracking (or both) using the Tracker::deactivate method. See the API docs: https://ar.qualcomm.at/qdevnet/api

- Kim

Re: Stop tracking

January 18, 2012 - 5:57am #2

EDIT: Do not use this, not thread safe. I will add a proper way of doing it later.

Just for anyone else

From 1.5.4 beta you can use the following to activate an deactivate the tracker
Add the code for your QCAR callback.


bool activatetrackerAsap = false;
bool deactivatetrackerAsap = false;

// Object to receive update callbacks from QCAR SDK
class ImageTargets_UpdateCallback : public QCAR::UpdateCallback
{   
	virtual void QCAR_onUpdate(QCAR::State& /*state*/)
	{
		if (activatetrackerAsap)
		{
			LOG("Activating tracker");

			QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance();
			QCAR::ImageTracker* imageTracker = static_cast<QCAR::ImageTracker*>(
					trackerManager.getTracker(QCAR::Tracker::IMAGE_TRACKER));
			if (imageTracker == NULL)
			{
				LOG("Failed to activate tracker because the ImageTracker has not"
						" been initialized.");
				return;
			}


			if (dataSet != 0)
			{
				// Activate the data set:
				if (!imageTracker->activateDataSet(dataSet))
				{
					LOG("Failed to activate tracker.");
					return;
				}
			} else {

				LOG("Failed to activate tracker.");
				return;
			}

			LOG("Successfully activated tracker");
			activatetrackerAsap = false;
		}
		if (deactivatetrackerAsap)
		{
			LOG("Deactivating tracker");

				QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance();
				QCAR::ImageTracker* imageTracker = static_cast<QCAR::ImageTracker*>(
						trackerManager.getTracker(QCAR::Tracker::IMAGE_TRACKER));
				if (imageTracker == NULL)
				{
					LOG("Failed to deactivate tracker because the ImageTracker has not"
							" been initialized.");
					return;
				}

				if (dataSet != 0)
				{
					if (!imageTracker->deactivateDataSet(dataSet))
					{
						LOG("Failed to deactivate the tracker because the data set "
								"could not be activated.");
						return;
					}

					LOG("Successfully deactivated tracker");
					deactivatetrackerAsap = false;
					return;
				}

				LOG("No tracker set to deactivate");
				return;
		}
	}
};

ImageTargets_UpdateCallback updateCallback;

Then all you need to do is call one of the following:

JNIEXPORT int JNICALL
Java_com_accenture_android_arfilmlistings_ImageTargets_activateCurrentDataset(JNIEnv* env, jobject obj)
{
	activatetrackerAsap = true;
}


JNIEXPORT int JNICALL
Java_com_accenture_android_arfilmlistings_ImageTargets_deactivateCurrentDataset(JNIEnv* env, jobject obj)
{
	deactivatetrackerAsap = true;
}

Stop tracking

May 5, 2013 - 5:11am #1

hi , in my app i want to stop the tracker with button click. I want the Image tracking to stop, so the vuforia is no longer searching for the pattern, but keep the 3D object in screen . i tried below code but its not working.. please any idea.. how can i do this.. thank you

Log in or register to post comments