I am using NDK+OpenCV to develop the apps. I have the following issue:
I put all the native method in FoodRecgNativeLib.java and I want to read opencv Matrix from file:
//in FoodRecgNativeLib.java
public static void NativeLoadFile(String path, String tag, Mat result)
{
loadsfile(path,tag,result.nativeObj);
return;
}
public native static void loadsfile(String path, String tag, long addr);
//.h file
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class ca_uwo_csd_Threads_FoodRecgNativeLib */
#ifndef _Included_ca_uwo_csd_Threads_FoodRecgNativeLib
#define _Included_ca_uwo_csd_Threads_FoodRecgNativeLib
#ifdef __cplusplus
extern "C" {
#endif
JNIEXPORT void JNICALL Java_ca_uwo_csd_Threads_FoodRecgNativeLib_loadsfile
(JNIEnv *, jclass, jstring, jstring, jlong);
#ifdef __cplusplus
}
#endif
#endif
//in .cpp file, .h file is included
JNIEXPORT void JNICALL Java_ca_uwo_csd_Threads_FoodRecgNativeLib_loadsfile
(JNIEnv *env, jobject cls, jstring path, jstring tag, jlong result_addr)
{
cv::FileStorage fs(jstring2str(env,path), FileStorage::READ);
Mat& data = *(Mat*)result_addr;;
fs[jstring2str(env,tag)] >> data;
}
Could anyone check what's wrong with my code?
The declaration and implementation signatures of Java_ca_uwo_csd_Threads_FoodRecgNativeLib_loadsfile
don't match. Change the second parameter type in the implementation from jobject
to jclass
.
您可能忘记了通过以下方式加载本机库
static { System.loadLibrary("YourLibaryName"); }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.