コード例 #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();
					}
				}

	        }
	    }
コード例 #2
0
JNIEXPORT jboolean JNICALL
Java_rajawali_vuforia_RajawaliVuforiaActivity_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;
}
コード例 #3
0
	virtual void QCAR_onUpdate(QCAR::State&) {

		if (dataSetToActivate != NULL) {
			QCAR::TrackerManager& trackerManager =
					QCAR::TrackerManager::getInstance();
			QCAR::ImageTracker* imageTracker =
					static_cast<QCAR::ImageTracker*>(trackerManager.getTracker(
							QCAR::ImageTracker::getClassType()));
			if (imageTracker == 0) {
				LOG("Failed to activate data set.");
				return;
			}
			imageTracker->activateDataSet(dataSetToActivate);

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

			dataSetToActivate = NULL;
		}

		if (scanningMode) {
			QCAR::TrackerManager& trackerManager =
					QCAR::TrackerManager::getInstance();
			QCAR::ImageTracker* imageTracker =
					static_cast<QCAR::ImageTracker*>(trackerManager.getTracker(
							QCAR::ImageTracker::getClassType()));

			// Get the target finder:
			QCAR::TargetFinder* targetFinder = imageTracker->getTargetFinder();

			// Check if there are new results available:
			const int statusCode = targetFinder->updateSearchResults();

			if (statusCode < 0) {
				char errorMessage[80];
				LOG(errorMessage, "Error with status code %d", statusCode);
			} else if (statusCode
					== QCAR::TargetFinder::UPDATE_RESULTS_AVAILABLE) {
				// Process new search results
				if (targetFinder->getResultCount() > 0) {
					const QCAR::TargetSearchResult* result =
							targetFinder->getResult(0);

					// Check if this target is suitable for tracking:
					if (result->getTrackingRating() > 0) {
						// Create a new Trackable from the result:
						QCAR::Trackable* newTrackable =
								targetFinder->enableTracking(*result);

						if (newTrackable != 0) {
							LOG(
									"Successfully created new trackable '%s' with rating '%d'.",

									newTrackable->getName(), result->getTrackingRating());

							if (strcmp(result->getUniqueTargetId(),
									lastTargetId) != 0) {
								// Copies the new target Metadata
								snprintf(targetMetadata, CONTENT_MAX, "%s",
										result->getMetaData());
								//LOG(targetMetadata);

							}

							strcpy(lastTargetId, result->getUniqueTargetId());

							// Stop Cloud Reco scanning
							targetFinder->stop();

							scanningMode = false;
						}
					}
				}
			}
		}
	}