问题
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.
回答1:
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 ...
}
来源:https://stackoverflow.com/questions/22752820/pass-and-return-opencv-mat-object-with-jni