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::Tracker::IMAGE_TRACKER)); if (imageTracker == 0 || dataSetStonesAndChips == 0 || dataSetTarmac == 0 || imageTracker->getActiveDataSet() == 0) { LOG("Failed to switch data set."); return; } if (imageTracker->getActiveDataSet() == dataSetStonesAndChips) { imageTracker->deactivateDataSet(dataSetStonesAndChips); imageTracker->activateDataSet(dataSetTarmac); } else { imageTracker->deactivateDataSet(dataSetTarmac); imageTracker->activateDataSet(dataSetStonesAndChips); } } }
JNIEXPORT int JNICALL Java_edu_pugetsound_vichar_ar_ARGameActivity_destroyTrackerData(JNIEnv *, jobject) { LOG("Java_edu_pugetsound_vichar_ar_ARGameActivity_destroyTrackerData"); // Get the image 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 destroy the tracking data set because the ImageTracker has not" " been initialized."); return 0; } if (dataSetVichar != 0) { if (imageTracker->getActiveDataSet() == dataSetVichar && !imageTracker->deactivateDataSet(dataSetVichar)) { LOG("Failed to destroy the tracking data set vichar because the data set " "could not be deactivated."); return 0; } if (!imageTracker->destroyDataSet(dataSetVichar)) { LOG("Failed to destroy the tracking data set vichar."); return 0; } LOG("Successfully destroyed the data set vichar."); dataSetVichar = 0; } if (dataSetFlakesBox != 0) { if (imageTracker->getActiveDataSet() == dataSetFlakesBox && !imageTracker->deactivateDataSet(dataSetFlakesBox)) { LOG("Failed to destroy the tracking data set FlakesBox because the data set " "could not be deactivated."); return 0; } if (!imageTracker->destroyDataSet(dataSetFlakesBox)) { LOG("Failed to destroy the tracking data set FlakesBox."); return 0; } LOG("Successfully destroyed the data set FlakesBox."); dataSetFlakesBox = 0; } return 1; }
JNIEXPORT int JNICALL Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_destroyTrackerData(JNIEnv *, jobject) { LOG("Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_destroyTrackerData"); // Get the image 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 destroy the tracking data set because the ImageTracker has not" " been initialized."); return 0; } if (dataSetStonesAndChips != 0) { if (imageTracker->getActiveDataSet() == dataSetStonesAndChips && !imageTracker->deactivateDataSet(dataSetStonesAndChips)) { LOG("Failed to destroy the tracking data set StonesAndChips because the data set " "could not be deactivated."); return 0; } if (!imageTracker->destroyDataSet(dataSetStonesAndChips)) { LOG("Failed to destroy the tracking data set StonesAndChips."); return 0; } LOG("Successfully destroyed the data set StonesAndChips."); dataSetStonesAndChips = 0; } if (dataSetTarmac != 0) { if (imageTracker->getActiveDataSet() == dataSetTarmac && !imageTracker->deactivateDataSet(dataSetTarmac)) { LOG("Failed to destroy the tracking data set Tarmac because the data set " "could not be deactivated."); return 0; } if (!imageTracker->destroyDataSet(dataSetTarmac)) { LOG("Failed to destroy the tracking data set Tarmac."); return 0; } LOG("Successfully destroyed the data set Tarmac."); dataSetTarmac = 0; } return 1; }
JNIEXPORT jint JNICALL Java_com_tvc_supastriker_SupaStriker_destroyTrackerData (JNIEnv *, jobject){ LOG("Java_com_tvc_supastriker_SupaStriker_destroyTrackerData"); // Get the image 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 destroy tracking data set because the ImageTracker has not" "been initialized"); return 0; } if(dataSetSupaStrika != 0){ if(imageTracker->getActiveDataSet() == dataSetSupaStrika && !imageTracker->deactivateDataSet(dataSetSupaStrika)){ LOG("Failed to destroy the tracking data set SupaStriker because the data set" "could not be activated"); return 0; } LOG("Successfully destroyed the data set SupaStriker"); } return 1; }
void MSTracker::addTrackableSource(QCAR::TrackableSource *t) { QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance(); QCAR::ImageTracker* imageTracker = static_cast<QCAR::ImageTracker*> (trackerManager.getTracker( QCAR::Tracker::IMAGE_TRACKER)); // Deactivate current dataset imageTracker->deactivateDataSet(imageTracker->getActiveDataSet()); // Replace the previously tracked target (if any) by the new one. if ( this->dataset->hasReachedTrackableLimit() || this->dataset->getNumTrackables()) { delete static_cast<MSTargetInfo *>(this->dataset->getTrackable(0)->getUserData()); this->dataset->destroy(this->dataset->getTrackable(0)); } // Add new trackable source QCAR::Trackable *trackable = this->dataset->createTrackable(t); // Get its additionnal info from controller, and store it as userdata. MSTargetInfo *info = MSController::getNewTargetInfo(); if (info) { trackable->setUserData(info); } // Reactivate current dataset imageTracker->activateDataSet(this->dataset); }
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 int JNICALL Java_com_robopeak_EasyQCAR_EasyQCAR_destroy(JNIEnv *, jobject) { LOGI("EasyQCAR_destroy"); // Get the image tracker: QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance(); QCAR::ImageTracker* imageTracker = static_cast<QCAR::ImageTracker*>( trackerManager.getTracker(QCAR::Tracker::IMAGE_TRACKER)); if (imageTracker == NULL) { LOGE("Failed to destroy the tracking data set because the ImageTracker has not" " been initialized."); return 0; } if (g_dataSet != 0) { if (!imageTracker->deactivateDataSet(g_dataSet)) { LOGE("Failed to destroy the tracking data set because the data set " "could not be deactivated."); return 0; } if (!imageTracker->destroyDataSet(g_dataSet)) { LOGE("Failed to destroy the tracking data set."); return 0; } LOGI("Successfully destroyed the data set."); g_dataSet = 0; return 1; } //Destroy the image tracker trackerManager.deinitTracker(QCAR::Tracker::IMAGE_TRACKER); LOGI("No tracker data set to destroy."); return 0; }
JNIEXPORT int JNICALL Java_rajawali_vuforia_RajawaliVuforiaActivity_destroyTrackerData(JNIEnv *env, jobject object) { LOG("Java_rajawali_vuforia_RajawaliVuforiaRenderer_destroyTrackerData"); QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance(); QCAR::ImageTracker* imageTracker = static_cast<QCAR::ImageTracker*>(trackerManager.getTracker( QCAR::ImageTracker::getClassType())); if (imageTracker == NULL) { return 0; } for (int tIdx = 0; tIdx < imageTracker->getActiveDataSetCount(); tIdx++) { QCAR::DataSet* dataSet = imageTracker->getActiveDataSet(tIdx); imageTracker->deactivateDataSet(dataSet); imageTracker->destroyDataSet(dataSet); } return 1; }
MSTracker::~MSTracker() { QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance(); QCAR::ImageTracker* imageTracker = static_cast<QCAR::ImageTracker*>( trackerManager.getTracker(QCAR::Tracker::IMAGE_TRACKER)); if (imageTracker != NULL && this->dataset != 0) { imageTracker->deactivateDataSet(this->dataset); int n = this->dataset->getNumTrackables(); for (int i = 0; i < n; ++i) { QCAR::Trackable *t = this->dataset->getTrackable(i); if (t->getUserData()) { MSTargetInfo *info = static_cast<MSTargetInfo *>(t->getUserData()); delete info; t->setUserData(NULL); } } imageTracker->destroyDataSet(this->dataset); this->dataset = NULL; } trackerManager.deinitTracker(QCAR::Tracker::IMAGE_TRACKER); }
JNIEXPORT int JNICALL Java_com_mx_ipn_escom_ars_recorrido_ReconocerActivity_destroyTrackerData(JNIEnv *, jobject) { LOG("Java_com_mx_ipn_escom_ars_recorrido_ReconocerActivity_destroyTrackerData"); 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 destroy the tracking data set because the ImageTracker has not" " been initialized."); return 0; } if (dataSetStonesAndChips2 != 0) { if (imageTracker->getActiveDataSet() == dataSetStonesAndChips2 && !imageTracker->deactivateDataSet(dataSetStonesAndChips2)) { LOG("Failed to destroy the tracking data set StonesAndChips because the data set " "could not be deactivated."); return 0; } if (!imageTracker->destroyDataSet(dataSetStonesAndChips2)) { LOG("Failed to destroy the tracking data set StonesAndChips."); return 0; } LOG("Successfully destroyed the data set StonesAndChips."); dataSetStonesAndChips2 = 0; } return 1; }
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::Tracker::IMAGE_TRACKER)); if (imageTracker == 0 || dataSetStonesAndChips == 0 || imageTracker->getActiveDataSet() == 0) { LOG("Failed to switch data set.1 = %d, 2 = %d, 3 = %d", imageTracker, dataSetStonesAndChips, imageTracker->getActiveDataSet()); return; } if (imageTracker->getActiveDataSet() == dataSetStonesAndChips) { imageTracker->deactivateDataSet(dataSetStonesAndChips); imageTracker->destroyDataSet(dataSetStonesAndChips); LOG("Load dynamically new data set Start"); LOG("DataSetName %s", dataSetName); // Get the image 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 load tracking data set because the ImageTracker has not" " been initialized."); return; } // Create the data sets: dataSetStonesAndChips = imageTracker->createDataSet(); if (dataSetStonesAndChips == 0) { LOG("Failed to create a new tracking data."); return; } LOG("Load data set from device"); char path[strlen("/mnt/sdcard/") + strlen(dataSetName) + strlen(".xml")]; strcpy(path, "/mnt/sdcard/"); strcat(path, dataSetName); strcat(path, ".xml"); LOG("Path %s", path); // Load the data sets: if (!dataSetStonesAndChips->load(path, QCAR::DataSet::STORAGE_ABSOLUTE)) { LOG("Failed to load data set."); return; } // Activate the data set: if (!imageTracker->activateDataSet(dataSetStonesAndChips)) { LOG("Failed to activate data set."); return; } LOG("Load dynamically new data set End"); //imageTracker->activateDataSet(dataSetTarmac); } else { //imageTracker->deactivateDataSet(dataSetTarmac); imageTracker->activateDataSet(dataSetStonesAndChips); } } }