- Sort Posts
- 13 replies
- Last post
CloudReco and ImageTarget
CloudReco and ImageTarget
Thanks for your reply.
I was checked my ImageTargets.cpp. But initCloudReco() in ImageTarget.cpp was well entered.
This is my initCloudReco() in ImageTargets.cpp.
If initCloudReco() is right where i find next?
------------------------------------------------------------------------------------------------ ImageTargets.cpp (initCloudReco)
JNIEXPORT int JNICALL Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_initCloudReco(JNIEnv *, jobject) { LOG("Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_initCloudReco"); QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance(); QCAR::ImageTracker* imageTracker = static_cast<QCAR::ImageTracker*>( trackerManager.getTracker(QCAR::Tracker::IMAGE_TRACKER)); assert(imageTracker != NULL); //Get the TargetFinder: 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; }
---------------------------------------------------------------------------------------- ImageTargets.java (initCloudRecoTask)
/** An async task to initialize cloud-based recognition asynchronously. */ private class InitCloudRecoTask extends AsyncTask<Void, Integer, Boolean> { // Initialize with invalid value private int mInitResult = -1; protected Boolean doInBackground(Void... params) { // Prevent the onDestroy() method to overlap: synchronized (mShutdownLock) { // Init cloud-based recognition: mInitResult = initCloudReco(); return mInitResult == INIT_SUCCESS; } } protected void onPostExecute(Boolean result) { DebugLog.LOGD("InitCloudRecoTask::onPostExecute: execution " + (result ? "successful" : "failed")); if (result) { // Done loading the tracker, update application status: updateApplicationStatus(APPSTATUS_INITED); // Hides the Loading Dialog loadingDialogHandler.sendEmptyMessage(HIDE_LOADING_DIALOG); mUILayout.setBackgroundColor(Color.TRANSPARENT); } else { // Create dialog box for display error: AlertDialog dialogError = new AlertDialog.Builder( ImageTargets.this).create(); dialogError.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.button_OK), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Exiting application System.exit(1); } }); // Show dialog box with error message: String logMessage = "Failed to initialize CloudReco."; // NOTE: Check if initialization failed because the device is // not supported. At this point the user should be informed // with a message. if (mInitResult == INIT_ERROR_NO_NETWORK_CONNECTION) logMessage = "Failed to initialize CloudReco because " + "the device has no network connection."; else if (mInitResult == INIT_ERROR_SERVICE_NOT_AVAILABLE) logMessage = "Failed to initialize CloudReco because " + "the service is not available."; dialogError.setMessage(logMessage); dialogError.show(); } } }
CloudReco and ImageTarget
Thank you so much AlessandroB!
I had forgotten the ndk-build ..
So Ndk-build again to clear the existing obj folder.
But got another problem.
ndk-build Cygwin : Generating dependency file converter script Compile++ arm : ImageTargets <= ImageTargets.cpp jni/ImageTargets.cpp: In function 'void Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_startCamera(JNIEnv*, jobject)': jni/ImageTargets.cpp:728:55: error: 'class QCAR::Tracker' has no member named 'getTargetFinder' jni/ImageTargets.cpp: In function 'void Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_stopCamera(JNIEnv*, jobject)': jni/ImageTargets.cpp:749:54: error: 'class QCAR::Tracker' has no member named 'getTargetFinder' /cygdrive/c/workspace/android-ndk-r8d/build/core/build-binary.mk:269: recipe for target `obj/local/armeabi/objs/ImageTargets/ImageTargets.o' failed make: *** [obj/local/armeabi/objs/ImageTargets/ImageTargets.o] Error 1
I don't know why 'class QCAR::Tracker' has no member named 'getTargetFinder' ..
Can you read my ImageTarget.cpp and ImageTarget.java code ?
If you can, I'm going to send email ..
Always, thank you for your answers. :)
CloudReco and ImageTarget
CloudReco and ImageTarget
Thank you so much AlessandroB!
I had forgotten the ndk-build ..
So Ndk-build again to clear the existing obj folder.
But got another problem.
ndk-build Cygwin : Generating dependency file converter script Compile++ arm : ImageTargets <= ImageTargets.cpp jni/ImageTargets.cpp: In function 'void Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_startCamera(JNIEnv*, jobject)': jni/ImageTargets.cpp:728:55: error: 'class QCAR::Tracker' has no member named 'getTargetFinder' jni/ImageTargets.cpp: In function 'void Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_stopCamera(JNIEnv*, jobject)': jni/ImageTargets.cpp:749:54: error: 'class QCAR::Tracker' has no member named 'getTargetFinder' /cygdrive/c/workspace/android-ndk-r8d/build/core/build-binary.mk:269: recipe for target `obj/local/armeabi/objs/ImageTargets/ImageTargets.o' failed make: *** [obj/local/armeabi/objs/ImageTargets/ImageTargets.o] Error 1I don't know why 'class QCAR::Tracker' has no member named 'getTargetFinder' ..
Can you read my ImageTarget.cpp and ImageTarget.java code ?
If you can, I'm going to send email ..
Always, thank you for your answers. :)
I have the same problem,
"Compile++ arm : ImageTargets <= ImageTargets.cpp
jni/ImageTargets.cpp: In function 'void Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_startCamera(JNIEnv*, jobject)':
jni/ImageTargets.cpp:755:58: error: 'class QCAR::Tracker' has no member named 'getTargetFinder'
jni/ImageTargets.cpp: In function 'void Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_stopCamera(JNIEnv*, jobject)':
jni/ImageTargets.cpp:774:54: error: 'class QCAR::Tracker' has no member named 'getTargetFinder'
make: *** [obj/local/armeabi/objs/ImageTargets/ImageTargets.o] Error 1
can you please let me know how did u solve this problem?
I tried refreshing the project and NDK-build several times.
CloudReco and ImageTarget
I've solved the casting errors in startCamera and stopCamera, but I still get this one:
$ ndk-build Compile++ arm : ImageTargets <= ImageTargets.cpp jni/ImageTargets.cpp: In member function 'virtual void ImageTargets_UpdateCallback::QCAR_onUpdate(QCAR::State&)': jni/ImageTargets.cpp:127:7: error: 'state' was not declared in this scope make: *** [obj/local/armeabi/objs/ImageTargets/ImageTargets.o] Error 1
This is my onUpdate function:
virtual void QCAR_onUpdate(QCAR::State& /*state*/) { //NEW code for Cloud Reco QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance(); QCAR::ImageTracker* imageTracker = static_cast<QCAR::ImageTracker*>( trackerManager.getTracker(QCAR::Tracker::IMAGE_TRACKER)); // 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]; sprintf(errorMessage, "Error with status code %d at frame %d", statusCode, state.getFrame().getTimeStamp()); } 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) { // If the target has changed... // app-specific: do something // (e.g. generate new 3D model or texture) } strcpy(lastTargetId, result->getUniqueTargetId()); // Stop Cloud Reco scanning targetFinder->stop(); scanningMode = false; showStartScanButton = true; } } } } }
I can compile the original .cpp correctly, but it doesn't use that State variable either. Any idea where this is coming from?
CloudReco and ImageTarget
Thanks for such a quick answer, that solved that error and I could build the project. Thing is, I'm trying to modify this project so I get a message in Java with the Trackable's name, using this tutorial: https://developer.vuforia.com/resources/dev-guide/open-web-site-and-display-toast-target-detection, and now I got a new error:
$ ndk-build Compile++ arm : ImageTargets <= ImageTargets.cpp jni/ImageTargets.cpp: In function 'void Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer_renderFrame(JNIEnv*, jobject)': jni/ImageTargets.cpp:500:46: error: 'class QCAR::State' has no member named 'getActiveTrackable' make: *** [obj/local/armeabi/objs/ImageTargets/ImageTargets.o] Error 1
I've been using it in my older project and I never got that error. I was using the ImageTargets example from 1.5.9, but now I want to use Cloud Recognition and I'm trying to start the project again. Right now I have the ImageTargets with Cloud Reco, but when I replace the 'for' loop from the tutorial i get that last error. Do I have to cast the state or is it something else?
// Get the trackable: const QCAR::Trackable* trackable = state.getActiveTrackable(tIdx); // Compare this trackable's id to a globally stored id // If this is a new trackable, find the displayMessage java method and // call it with the trackable's name if (trackable->getId() != lastTrackableId) { jstring js = env->NewStringUTF(trackable->getName()); jclass javaClass = env->GetObjectClass(obj); jmethodID method = env->GetMethodID(javaClass, "displayMessage", "(Ljava/lang/String;)V"); env->CallVoidMethod(obj, method, js); lastTrackableId = trackable->getId(); }
Hi, the Logs say that you have not implemented initCloudReco() in native code:
Caused by: java.lang.UnsatisfiedLinkError: Native method not found: com.qualcomm.QCARSamples.ImageTargets.ImageTargets.initCloudReco:()I
Could you check that you have that function in your ImageTargets.cpp file ?