我正在使用int
值作为参数调用JNI函数。我发送宽度和高度为800和480.但是当我尝试在JNI函数中打印这些值时,我得到1和0而不是800和480.为什么我在JNI中得到错误的值?
我的JNI函数调用是:
findSquare(sourceImage.getNativeObjAddr(),
imageTaken.getNativeObjAddr(), 1, width, height);
public native void findSquare(long matAddrRgba, long matAddrDescriptor,
int draw, int width, int height);
JNI功能是:
JNIEXPORT jint JNICALL
Java_info_androidhive_androidcameraapi_CameraMainActivity_findSquare(
JNIEnv*, jobject, jlong addrRgba, jlong addrDescriptor, jlong addrSrc,
jlong addrDst, jint draw, jint width, jint height);
答案 0 :(得分:4)
android和native方法签名不匹配。
您的Java本机方法应如下所示:
// added addrSrc, addrDst which were missing.
public native void findSquare(long matAddrRgba, long matAddrDescriptor,
long addrSrc, long addrDst, int draw, int width,
int height);