Pass matrix in JNI

asked 2013-11-17 07:56:46 -0500

itay gravatar image

updated 2013-11-17 08:13:43 -0500

berak gravatar image

Hi,

I would like to know how can I pass matrix to function with JNI?

I trying to do basic thing, just pass 2 matrix and save them:

c++:

JNIEXPORT void JNICALL Java_com_example_mytest1_NativeClass_DetectSpermMaskMex(JNIEnv * env, jclass cls,long oneMatAddress, long secMatAddress, int brdr,int grayThresh, int maxDist)
{

        Mat* Inmat =  (Mat*)oneMatAddress;
        unsigned char * IM = Inmat->data;

        Mat* Outmat = (Mat*)secMatAddress;
        unsigned char * res = Outmat->data;


}

I have a problem with the second matrix (secMatAddress), after I add the last 2 lines the application stopped.

This is part of the java code:

    Mat F1 =  new Mat(new Size(701,701),CvType.CV_8U);

    M[0].copyTo(F1);
    NativeClass.DetectSpermMaskMex(F.getNativeObjAddr(),F.getNativeObjAddr() ,1, 2, 3);

I would like to know 3 things: 1. am I doing it right? 2. is there another way to pass matrix to jni function? 3. what is the easiest way to debug jni c++ code?

edit retag flag offensive close merge delete