Log in or register to post comments

LOG marker ID in FrameMarkers.java

June 25, 2011 - 4:11am #1

Hi!

I want to log the actual markerID in the FrameMarkers.java. I have a on Touchevent there and want to use the markerID to play a sound. So if a special marker is in the stream, i want to touch the display and a special sound is played. At the moment my code looks like this:

FrameMarkers.cpp:

...code

int a = marker->getMarkerId();

        jclass javaClass = env->GetObjectClass(obj);
        jmethodID method = env->GetMethodID(javaClass, "reportDistance", "(I)I");
        env->CallObjectMethod(obj, method, a);

...code

FrameMarkers.java:

  public boolean onTouchEvent (MotionEvent event)
    { 
    	
    	int action = event.getAction();
    	if(action == MotionEvent.ACTION_DOWN){
    	try{
    		if(b==0){
    	// hier auswerten! test[0].map[][][]; // MAP 50x50 = 1m 7x7m // Position will ich hier drin haben!!!!
    		for(int i =0; i<10; i++){
    			
    			DebugLog.LOGD("COLOR: " + test.get(0).map[i][i][1]);
    		}
    	 mSoundManager.playSound(96, 3.0f);
    	 Thread.sleep(4000);
    	 mSoundManager.playSound(101, 3.0f);
    	 Thread.sleep(4000);
    	 mSoundManager.playSound(106, 3.0f);
    	 Thread.sleep(4000);
    	 mSoundManager.playSound(111, 3.0f);
    	
    	}}
    	catch(InterruptedException e){}}//}
 	
    		  
    return true;
    }

Everytime a marker is in the stream, the app is shut down: At the moment it should work with the markerID 0, but i don´t know why it doesn´t.

Stephan

Re: LOG marker ID in FrameMarkers.java

June 25, 2011 - 8:11am #3

At first glance, this is an issue:

jmethodID method = env->GetMethodID(javaClass, "reportDistance", "(I)I");

public void reportDistance(int a)

"(I)I" is the JNI signature for a method that takes an int and returns an int. You don't have a method like that, you have "(I)V" which is a method that takes and int and return void.

- Kim

Re: LOG marker ID in FrameMarkers.java

June 25, 2011 - 4:15am #2

Forgot the call of the function before the onTouchEvent :

int b;

public void reportDistance(int a)
{
b = a;
DebugLog.LOGD("IDMARKER: " + a);
}

public boolean onTouchEvent (MotionEvent event){
...}

Log in or register to post comments