예제 #1
0
	    virtual void QCAR_onUpdate(QCAR::State& /*state*/)
	    {
	        if (switchDataSetAsap)
	        {
	            switchDataSetAsap = false;

	            // Get the image tracker:
	            QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance();
	            QCAR::ImageTracker* imageTracker = static_cast<QCAR::ImageTracker*>(
	                trackerManager.getTracker(QCAR::ImageTracker::getClassType()));
	            if (imageTracker == 0 || dataSetStonesAndChips == 0 || dataSetTarmac == 0 || dataSetvmio_vuforial_dev == 0 ||
	                imageTracker->getActiveDataSet() == 0)
	            {
	                LOG("Failed to switch data set.");
	                return;
	            }

				switch( selectedDataset )
				{
					case STONES_AND_CHIPS_DATASET_ID:
						if (imageTracker->getActiveDataSet() != dataSetStonesAndChips)
						{
							imageTracker->deactivateDataSet(dataSetvmio_vuforial_dev);
							imageTracker->deactivateDataSet(dataSetTarmac);
							imageTracker->activateDataSet(dataSetStonesAndChips);
						}
						break;

					case TARMAC_DATASET_ID:
						if (imageTracker->getActiveDataSet() != dataSetTarmac)
						{
							imageTracker->deactivateDataSet(dataSetvmio_vuforial_dev);
							imageTracker->deactivateDataSet(dataSetStonesAndChips);
							imageTracker->activateDataSet(dataSetTarmac);
						}
						break;

					case vmio_vuforial_dev_ID:
						if (imageTracker->getActiveDataSet() != dataSetvmio_vuforial_dev)
						{
							imageTracker->deactivateDataSet(dataSetStonesAndChips);
							imageTracker->activateDataSet(dataSetTarmac);
							imageTracker->deactivateDataSet(dataSetvmio_vuforial_dev);
						}
						break;
				}

				if(isExtendedTrackingActivated)
				{
					QCAR::DataSet* currentDataSet = imageTracker->getActiveDataSet();
					for (int tIdx = 0; tIdx < currentDataSet->getNumTrackables(); tIdx++)
					{
						QCAR::Trackable* trackable = currentDataSet->getTrackable(tIdx);
						trackable->startExtendedTracking();
					}
				}

	        }
	    }
JNIEXPORT jboolean JNICALL
Java_rajawali_vuforia_RajawaliVuforiaActivity_stopExtendedTracking(JNIEnv*, jobject)
{
    QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance();
    QCAR::ImageTracker* imageTracker = static_cast<QCAR::ImageTracker*>(
          trackerManager.getTracker(QCAR::ImageTracker::getClassType()));

    QCAR::DataSet* currentDataSet = imageTracker->getActiveDataSet();
    if (imageTracker == 0 || currentDataSet == 0)
    	return JNI_FALSE;

    for (int tIdx = 0; tIdx < currentDataSet->getNumTrackables(); tIdx++)
    {
    	QCAR::Trackable* trackable = currentDataSet->getTrackable(tIdx);
        if(!trackable->stopExtendedTracking())
        	return JNI_FALSE;
    }

    isExtendedTrackingActivated = false;
    return JNI_TRUE;
}
예제 #3
0
	JNIEXPORT jboolean JNICALL
	Java_com_miosys_finder_ui_PfinderTargets_startExtendedTracking(JNIEnv*, jobject)
	{
	    QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance();
	    QCAR::ImageTracker* imageTracker = static_cast<QCAR::ImageTracker*>(
	          trackerManager.getTracker(QCAR::ImageTracker::getClassType()));

	    QCAR::DataSet* currentDataSet = imageTracker->getActiveDataSet();
	    if (imageTracker == 0 || currentDataSet == 0)
	    	return JNI_FALSE;

	    for (int tIdx = 0; tIdx < currentDataSet->getNumTrackables(); tIdx++)
	    {
	        QCAR::Trackable* trackable = currentDataSet->getTrackable(tIdx);
	        if(!trackable->startExtendedTracking())
	        	return JNI_FALSE;
	    }

	    isExtendedTrackingActivated = true;
	    return JNI_TRUE;
	}
JNIEXPORT int JNICALL
Java_rajawali_vuforia_RajawaliVuforiaActivity_createImageMarker(JNIEnv* env,
		jobject object, jstring dataSetFile) {
	QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance();
	QCAR::ImageTracker* imageTracker =
			static_cast<QCAR::ImageTracker*>(trackerManager.getTracker(
					QCAR::ImageTracker::getClassType()));

	if (imageTracker == NULL) {
		LOG("Failed to load tracking data set because the ImageTracker has not"
		" been initialized.");
		return 0;
	}

	QCAR::DataSet* dataSet = imageTracker->createDataSet();
	if (dataSet == 0) {
		LOG("Failed to create a new tracking data.");
		return 0;
	}

	// Load the data sets:
	const char *nativeString = env->GetStringUTFChars(dataSetFile, NULL);
	if (!dataSet->load(nativeString, QCAR::DataSet::STORAGE_APPRESOURCE)) {
		LOG("Failed to load data set.");
		env->ReleaseStringUTFChars(dataSetFile, nativeString);
		return 0;
	}
	env->ReleaseStringUTFChars(dataSetFile, nativeString);

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

	LOG("Successfully loaded and activated data set.");

	return 1;
}