我正在处理在Android应用程序与JNI之间传递参数的问题,使用Java中的OpenCV库,我在Android应用程序代码中编写了以下内容。
Android OpenCV Java 代码:
Mat mat; //Mat object with data
Rect rect; //Rect object with data
//call to the native function
int resProc = Native.processImages_native(rect, mat);
C 代码:
JNIEXPORT jint JNICALL Java_com_test_Native_processImages_1native
(JNIEnv*, jclass, CvRect, Mat);
...
jint Java_com_test_Native_processImages_1native
(JNIEnv* env, jclass jc, CvRect rect, Mat mat){
int res = processImages(rect, mat);
return (jint)res;
}
...
int processImages(CvRect rect, Mat mat)
{
IplImage *ipl_Img = &mat.operator IplImage(); // here FAILS
CvRect rect_value = rect;
}
但是当我试图在C代码中从(Mat)转换为(IplImage *)时,我的应用程序失败了。因此,我的问题是如何将CvRect和Mat对象从我的Android Java代码传递到JNI。有更好的方法吗?
非常感谢。