JNIEXPORT void JNICALL Java_rajawali_vuforia_RajawaliVuforiaActivity_stopCamera(JNIEnv *, jobject) { LOG("Java_rajawali_vuforia_RajawaliVuforiaActivity_stopCamera"); // Stop the tracker: QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance(); QCAR::Tracker* markerTracker = trackerManager.getTracker( QCAR::MarkerTracker::getClassType()); if (markerTracker != 0) markerTracker->stop(); QCAR::ImageTracker* imageTracker = static_cast<QCAR::ImageTracker*>(trackerManager.getTracker( QCAR::ImageTracker::getClassType())); if (imageTracker != 0) imageTracker->stop(); QCAR::CameraDevice::getInstance().stop(); // Stop Cloud Reco: QCAR::TargetFinder* targetFinder = imageTracker->getTargetFinder(); assert(targetFinder != 0); targetFinder->stop(); // Clears the trackables targetFinder->clearTrackables(); QCAR::CameraDevice::getInstance().deinit(); initStateVariables(); }
// ---------------------------------------------------------------------------- // Initialize Cloud Reco // ---------------------------------------------------------------------------- JNIEXPORT int JNICALL Java_com_qualcomm_QCARSamples_CloudRecognition_CloudReco_initCloudReco(JNIEnv *, jobject) { LOG("Java_com_qualcomm_QCARSamples_VisualSearch_VisualSearch_initVisualSearch"); // Get the image tracker: QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance(); QCAR::ImageTracker* imageTracker = static_cast<QCAR::ImageTracker*>( trackerManager.getTracker(QCAR::Tracker::IMAGE_TRACKER)); assert(imageTracker != NULL); // Initialize visual search: QCAR::TargetFinder* targetFinder = imageTracker->getTargetFinder(); assert(targetFinder != NULL); // Start initialization: if (targetFinder->startInit(kAccessKey, kSecretKey)) { targetFinder->waitUntilInitFinished(); } int resultCode = targetFinder->getInitState(); if ( resultCode != QCAR::TargetFinder::INIT_SUCCESS) { LOG("Failed to initialize target finder."); return resultCode; } // Use the following calls if you would like to customize the color of the UI // targetFinder->setUIScanlineColor(1.0, 0.0, 0.0); // targetFinder->setUIPointColor(0.0, 0.0, 1.0); return resultCode; }
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); }
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; }
// ---------------------------------------------------------------------------- // Starts the Camera // ---------------------------------------------------------------------------- JNIEXPORT void JNICALL Java_com_qualcomm_QCARSamples_CloudRecognition_CloudReco_startCamera(JNIEnv *, jobject) { // Initialize the camera: if (!QCAR::CameraDevice::getInstance().init()) return; // Configure the video background configureVideoBackground(); // Select the default mode: if (!QCAR::CameraDevice::getInstance().selectVideoMode( QCAR::CameraDevice::MODE_DEFAULT)) return; // Start the camera: if (!QCAR::CameraDevice::getInstance().start()) return; // Start the tracker: QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance(); QCAR::ImageTracker* imageTracker = static_cast<QCAR::ImageTracker*>( trackerManager.getTracker(QCAR::Tracker::IMAGE_TRACKER)); assert(imageTracker != 0); imageTracker->start(); // Start cloud based recognition if we are in scanning mode: if(scanningMode) { QCAR::TargetFinder* targetFinder = imageTracker->getTargetFinder(); assert (targetFinder != 0); crStarted = targetFinder->startRecognition(); } }
// ---------------------------------------------------------------------------- // Enables CloudReco Service // ---------------------------------------------------------------------------- JNIEXPORT void JNICALL Java_com_qualcomm_QCARSamples_CloudRecognition_CloudReco_enterScanningModeNative(JNIEnv*, jobject) { QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance(); QCAR::ImageTracker* imageTracker = static_cast<QCAR::ImageTracker*>( trackerManager.getTracker(QCAR::Tracker::IMAGE_TRACKER)); assert(imageTracker != 0); QCAR::TargetFinder* targetFinder = imageTracker->getTargetFinder(); assert (targetFinder != 0); // Start CloudReco crStarted = targetFinder->startRecognition(); // Clear all trackables created previously: targetFinder->clearTrackables(); scanningMode = true; // Updates state variables showAnimation3Dto2D = false; showAnimation2Dto3D = false; isShowing2DOverlay = false; renderState = RS_SCANNING; }
// ---------------------------------------------------------------------------- // Stops the Camera // ---------------------------------------------------------------------------- JNIEXPORT void JNICALL Java_com_qualcomm_QCARSamples_CloudRecognition_CloudReco_stopCamera(JNIEnv *,jobject) { // Stop the tracker: QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance(); QCAR::ImageTracker* imageTracker = static_cast<QCAR::ImageTracker*>( trackerManager.getTracker(QCAR::Tracker::IMAGE_TRACKER)); assert(imageTracker != 0); imageTracker->stop(); // Stop cloud based recognition: QCAR::TargetFinder* targetFinder = imageTracker->getTargetFinder(); assert (targetFinder != 0); crStarted = !targetFinder->stop(); //Clears the trackables targetFinder->clearTrackables(); QCAR::CameraDevice::getInstance().stop(); QCAR::CameraDevice::getInstance().deinit(); // When the camera stops it clears the Product Texture ID so next time textures // Are recreated deleteCurrentProductTexture = true; // Initialize all state Variables initStateVariables(); }
MSTracker::MSTracker() { QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance(); QCAR::ImageTracker* imageTracker = static_cast<QCAR::ImageTracker*>(trackerManager.initTracker(QCAR::Tracker::IMAGE_TRACKER)); // Create and activate the data set: this->dataset = imageTracker->createDataSet(); imageTracker->activateDataSet(this->dataset); }
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 int JNICALL Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_loadTrackerData(JNIEnv *, jobject) { LOG("Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_loadTrackerData"); // 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 0; } // Create the data sets: dataSetStonesAndChips = imageTracker->createDataSet(); if (dataSetStonesAndChips == 0) { LOG("Failed to create a new tracking data."); return 0; } //dataSetTarmac = imageTracker->createDataSet(); //if (dataSetTarmac == 0) //{ // LOG("Failed to create a new tracking data."); // return 0; //} // Load the data sets: if (!dataSetStonesAndChips->load("/mnt/sdcard/Menu.xml", QCAR::DataSet::STORAGE_ABSOLUTE)) { LOG("Failed to load data set."); return 0; } //if (!dataSetTarmac->load("Tarmac.xml", QCAR::DataSet::STORAGE_APPRESOURCE)) //{ // LOG("Failed to load data set."); // return 0; //} // Activate the data set: if (!imageTracker->activateDataSet(dataSetStonesAndChips)) { LOG("Failed to activate data set."); return 0; } LOG("Successfully loaded and activated data set."); return 1; }
JNIEXPORT int JNICALL Java_edu_pugetsound_vichar_ar_ARGameActivity_loadTrackerData(JNIEnv *, jobject) { LOG("Java_edu_pugetsound_vichar_ar_ARGameActivity_loadTrackerData"); // 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 0; } // Create the data sets: dataSetVichar = imageTracker->createDataSet(); if (dataSetVichar == 0) { LOG("Failed to create a new tracking data."); return 0; } dataSetFlakesBox = imageTracker->createDataSet(); if (dataSetFlakesBox == 0) { LOG("Failed to create a new tracking data."); return 0; } // Load the data sets: if (!dataSetVichar->load("vichar.xml", QCAR::DataSet::STORAGE_APPRESOURCE)) { LOG("Failed to load data set."); return 0; } if (!dataSetFlakesBox->load("FlakesBox.xml", QCAR::DataSet::STORAGE_APPRESOURCE)) { LOG("Failed to load data set."); return 0; } // Activate the data set: if (!imageTracker->activateDataSet(dataSetVichar)) { LOG("Failed to activate data set."); return 0; } LOG("Successfully loaded and activated data set."); return 1; }
JNIEXPORT int JNICALL Java_name_nailgun_irrlichtvuforia_MainActivity_loadTrackerData(JNIEnv *, jobject) { LOG("Java_name_nailgun_irrlichtvuforia_MainActivity_loadTrackerData"); // 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 0; } // Create the data sets: dataSetStonesAndChips = imageTracker->createDataSet(); if (dataSetStonesAndChips == 0) { LOG("Failed to create a new tracking data."); return 0; } dataSetTarmac = imageTracker->createDataSet(); if (dataSetTarmac == 0) { LOG("Failed to create a new tracking data."); return 0; } // Load the data sets: if (!dataSetStonesAndChips->load("StonesAndChips.xml", QCAR::DataSet::STORAGE_APPRESOURCE)) { LOG("Failed to load data set."); return 0; } if (!dataSetTarmac->load("Tarmac.xml", QCAR::DataSet::STORAGE_APPRESOURCE)) { LOG("Failed to load data set."); return 0; } // Activate the data set: if (!imageTracker->activateDataSet(dataSetStonesAndChips)) { LOG("Failed to activate data set."); return 0; } LOG("Successfully loaded and activated data set."); return 1; }
// ---------------------------------------------------------------------------- // Disables the CloudReco service // ---------------------------------------------------------------------------- JNIEXPORT void JNICALL Java_com_qualcomm_QCARSamples_CloudRecognition_CloudReco_enterContentModeNative(JNIEnv*, jobject) { QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance(); QCAR::ImageTracker* imageTracker = static_cast<QCAR::ImageTracker*>( trackerManager.getTracker(QCAR::Tracker::IMAGE_TRACKER)); assert(imageTracker != 0); QCAR::TargetFinder* targetFinder = imageTracker->getTargetFinder(); assert (targetFinder != 0); // Stop CloudReco crStarted = !targetFinder->stop(); // Remember we are in content mode: scanningMode = false; }
JNIEXPORT int JNICALL Java_com_robopeak_EasyQCAR_EasyQCAR_create(JNIEnv* env, jobject, jstring trackerXml) { LOGI("EasyQCAR_create"); // 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) { imageTracker = static_cast<QCAR::ImageTracker*>(trackerManager.initTracker(QCAR::Tracker::IMAGE_TRACKER)); if (imageTracker == NULL) { LOGE("Failed to initialize ImageTracker."); return 0; } LOGI("Successfully initialized ImageTracker."); } // Create the data sets: g_dataSet = imageTracker->createDataSet(); if (g_dataSet == 0) { LOGE("Failed to create a new tracking data."); return 0; } // Load the data sets: const char* c_xml = env->GetStringUTFChars(trackerXml, 0); if (!g_dataSet->load(c_xml, QCAR::DataSet::STORAGE_APPRESOURCE)) { LOGE("Failed to load data set %s.", c_xml); return 0; } env->ReleaseStringUTFChars(trackerXml, c_xml); // Activate the data set: if (!imageTracker->activateDataSet(g_dataSet)) { LOGE("Failed to activate data set %s.", c_xml); return 0; } LOGI("Successfully loaded and activated data set %s.", c_xml); return 1; }
JNIEXPORT void JNICALL Java_rajawali_vuforia_RajawaliVuforiaActivity_startCamera(JNIEnv *env, jobject object) { LOG("Java_rajawali_vuforia_RajawaliVuforiaActivity_startCamera"); // Select the camera to open, set this to QCAR::CameraDevice::CAMERA_FRONT // to activate the front camera instead. QCAR::CameraDevice::CAMERA camera = QCAR::CameraDevice::CAMERA_DEFAULT; // Initialize the camera: if (!QCAR::CameraDevice::getInstance().init(camera)) return; // Configure the video background configureVideoBackground(); // Select the default mode: if (!QCAR::CameraDevice::getInstance().selectVideoMode( QCAR::CameraDevice::MODE_DEFAULT)) return; // Start the camera: if (!QCAR::CameraDevice::getInstance().start()) return; // Start the tracker: QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance(); QCAR::Tracker* markerTracker = trackerManager.getTracker( QCAR::MarkerTracker::getClassType()); if (markerTracker != 0) markerTracker->start(); QCAR::ImageTracker* imageTracker = static_cast<QCAR::ImageTracker*>(trackerManager.getTracker( QCAR::ImageTracker::getClassType())); if (imageTracker != 0) imageTracker->start(); // Start cloud based recognition if we are in scanning mode: if (scanningMode) { QCAR::TargetFinder* targetFinder = imageTracker->getTargetFinder(); assert(targetFinder != 0); targetFinder->startRecognition(); } }
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); } } }
void RefFreeFrame::deInit( ) { QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance(); QCAR::ImageTracker* imageTracker = static_cast<QCAR::ImageTracker*> (trackerManager.getTracker( QCAR::Tracker::IMAGE_TRACKER)); if (imageTracker != 0) { QCAR::ImageTargetBuilder* targetBuilder = imageTracker->getImageTargetBuilder(); if (targetBuilder && (targetBuilder->getFrameQuality() != QCAR::ImageTargetBuilder::FRAME_QUALITY_NONE)) { targetBuilder->stopScan(); } } }
JNIEXPORT int JNICALL Java_name_nailgun_irrlichtvuforia_MainActivity_destroyTrackerData(JNIEnv *, jobject) { LOG("Java_name_nailgun_irrlichtvuforia_MainActivity_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 int JNICALL Java_com_miosys_finder_ui_PfinderTargets_destroyTrackerData(JNIEnv *, jobject) { LOG("Java_com_miosys_finder_ui_PfinderTargets_destroyTrackerData"); // Get the image tracker: QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance(); QCAR::ImageTracker* imageTracker = static_cast<QCAR::ImageTracker*>( trackerManager.getTracker(QCAR::ImageTracker::getClassType())); 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 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_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; }
// ---------------------------------------------------------------------------- // DeInitialize Cloud Reco // ---------------------------------------------------------------------------- JNIEXPORT int JNICALL Java_com_qualcomm_QCARSamples_CloudRecognition_CloudReco_deinitCloudReco(JNIEnv *, jobject) { // 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; } // Deinitialize visual search: QCAR::TargetFinder* finder = imageTracker->getTargetFinder(); finder->deinit(); return 1; }
JNIEXPORT int JNICALL Java_com_mx_ipn_escom_ars_recorrido_ReconocerActivity_loadTrackerData(JNIEnv *env, jobject,jstring fileName) { LOG("Java_com_mx_ipn_escom_ars_recorrido_ReconocerActivity_loadTrackerData"); // 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 0; } dataSetStonesAndChips2 = imageTracker->createDataSet(); if (dataSetStonesAndChips2 == 0) { LOG("Failed to create a new tracking data."); return 0; } const char *nativeString = env->GetStringUTFChars(fileName, 0); if (!dataSetStonesAndChips2->load(nativeString, QCAR::DataSet::STORAGE_ABSOLUTE)) { LOG("Failed to load data set."); return 0; } env->ReleaseStringUTFChars(fileName, nativeString); if (!imageTracker->activateDataSet(dataSetStonesAndChips2)) { LOG("Failed to activate data set."); return 0; } LOG("Successfully loaded and activated data set."); return 1; }
JNIEXPORT int JNICALL Java_com_snda_sdar_ImageTargets_loadTrackerData(JNIEnv *, jobject) { LOG("Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_loadTrackerData"); // 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 0; } // Create the data sets: dataSetDefault = imageTracker->createDataSet(); if (dataSetDefault == 0) { LOG("Failed to create a new tracking data."); return 0; } // Load the data sets: if (!dataSetDefault->load("default.xml", QCAR::DataSet::STORAGE_APPRESOURCE)) { LOG("Failed to load data set."); return 0; } // Activate the data set: if (!imageTracker->activateDataSet(dataSetDefault)) { LOG("Failed to activate data set."); return 0; } LOG("Successfully loaded and activated data set."); return 1; }
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 void JNICALL Java_rajawali_vuforia_RajawaliVuforiaActivity_enterScanningModeNative(JNIEnv*, jobject) { QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance(); QCAR::ImageTracker* imageTracker = static_cast<QCAR::ImageTracker*>(trackerManager.getTracker( QCAR::ImageTracker::getClassType())); assert(imageTracker != 0); QCAR::TargetFinder* targetFinder = imageTracker->getTargetFinder(); assert(targetFinder != 0); // Start Cloud Reco targetFinder->startRecognition(); // Clear all trackables created previously: targetFinder->clearTrackables(); scanningMode = true; }
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; }
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; }
JNIEXPORT int JNICALL Java_rajawali_vuforia_RajawaliVuforiaActivity_deinitCloudReco(JNIEnv *, jobject) { // Get the image tracker: QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance(); QCAR::ImageTracker* imageTracker = static_cast<QCAR::ImageTracker*>(trackerManager.getTracker( QCAR::ImageTracker::getClassType())); if (imageTracker == NULL) { LOG( "Failed to deinit CloudReco as the ImageTracker was not initialized."); return 0; } // Deinitialize Cloud Reco: QCAR::TargetFinder* finder = imageTracker->getTargetFinder(); finder->deinit(); return 1; }
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; }