Log in or register to post comments

Display text based on the track

May 25, 2012 - 12:14am #1

Hi
I saw this example and follow it
https://ar.qualcomm.at/arforums/showthread.php?t=2161
it did work with me, but now i'm trying to modify the code to display a text not the trackable name

how can i do it?
I did this:

        if (trackable->getId() != lastTrackableId) {
			const char* message ;
			const char* trackName = trackable->getName() ;
			if (trackName == "liver")
				message = "Liver: info" ;
			else
				message = "any thing";
            //jstring js = env->NewStringUTF(trackable->getName());
            jstring js = env->NewStringUTF(message);
			
            jclass javaClass = env->GetObjectClass(obj);
            jmethodID method = env->GetMethodID(javaClass, "displayMessage", "(Ljava/lang/String;)V");
            env->CallVoidMethod(obj, method, js);
            lastTrackableId = trackable->getId();
        }

but it goes to the else part

PS. this code is in the imagetarget.cpp and my trackablle name is "liver"

thank you

Re: Display text based on the track

June 2, 2012 - 7:39pm #7

Yes you'll need to use the JNI to accomplish that. Take a look at the Dominoes sample. It's using the same approach.

When the user presses a button to select a DataSet, this will call its event handler in Java which can call a C++ method using the JNI. DataSets should be activated and deactivated in the QCAR_onUpdate method of the respective UpdateCallback class (see the sample). So your C++ JNI method can set a property which is read by this method to determine which DataSet should be active.

Re: Display text based on the track

June 2, 2012 - 6:04pm #6

can u plz answer me

Re: Display text based on the track

May 27, 2012 - 11:20am #5

thanks DavidBeard for your replay
in your replay you said "activating and deactivating these based on which button is selected" should i do that also by using the (JNI) ?

Re: Display text based on the track

May 27, 2012 - 8:28am #4

You can accomplish that via the Java Native Interface ( JNI ). Take a look at the Dominoes sample for an example of how to call into C++ from Java using a Java button - see: GUIManager.java and Dominoes.cpp.

Also you can distinguish which set of targets is to be detected by segregating them into multiple Datasets and then activating and deactivating these based on which button is selected. But if there is a case where all targets, from both sets, need to be detectable then you should include them all in a single dataset and handle the detection selection procedurally (e.g. in renderFrame ).

Re: Display text based on the track

May 27, 2012 - 6:11am #3

yup thank you sooooo much, it did works :)

now i have another question
how can i take variables from .java file to read it in .cpp file ? or vise versa?

what i want to accomplished actually is: i have a menu that include two buttons when the user click on the first i want the camera to detect specific markers while the other button detect the rest? any suggestions?

thank you ...

Re: Display text based on the track

May 25, 2012 - 11:07am #2

Hello MNR,

Try using strcmp() to compare your string. As an example see how the textures for the teapot are chosen in the sample ImageTargets.

        if (strcmp(trackable->getName(), "chips") == 0)
        {
            textureIndex = 0;
        }

Thank you,

-Peter

Log in or register to post comments