Freesky1102
Freesky1102

Reputation: 21

Pass and return OpenCv Mat object with JNI

I would like to write a function in JNI like this:

JNIEXPORT jobject JNICALL Java_com_datumdroid_android_ocr_simple_HoughLine_nativeDetectLine

(JNIEnv * jenv, jclass, jstring fileInput, jobject mat)

The Java interface would be :

nativeDetectLine( String fileInput, Mat mat);

Now I want to pass the Mat to JNI and change its value.

Can anyone give me a tutorial or guide? Specifically how work with jobjects.

Upvotes: 0

Views: 3065

Answers (1)

don_q
don_q

Reputation: 415

http://answers.opencv.org/question/12271/can-the-java-interface-pass-a-mat-to-opencvs-c/

JNIEXPORT void JNICALL Java_org_opencv_samples_tutorial2_Tutorial2Activity_FindFeatures(JNIEnv*, jobject, jlong  addrGray, jlong addrRgba)
{
    Mat& mGr  = *(Mat*)addrGray;
    Mat& mRgb = *(Mat*)addrRgba;
    ... do stuff with the Mat objects ...
}

Upvotes: 1

Related Questions