LYNX

Links

Tags

Categories

jni笔记

jnijava间的交互

jni获取/修改jobject成员

参考:CSDN

javac变量转换

JNIEXPORT void JNICALL Java_ClassName_MethodName(JNIEnv *env, jobject obj, jstring javaString)
{
const char *nativeString = (*env)->GetStringUTFChars(env, javaString, 0);
(*env)->ReleaseStringUTFChars(env, javaString, nativeString);
}

javaString[]->c

参考:CSDN

public native void sendString(String[] imgPaths);// 函数声明
JNIEXPORT void JNICALL
Java_com_example_stitch_MainActivity_sendString(
JNIEnv *env,
jobject thiz,
jobjectArray imgPaths) {
// 获取String数组长度
jsize str_len = env->GetArrayLength(imgPaths);

for (int i = 0; i < str_len; i ++) {
jstring tmp = (jstring) env->GetObjectArrayElement(imgPaths, i);
const char *img_path = env->GetStringUTFChars(tmp, 0);

LOG("img[%d]: %s", i, img_path);
}
}

javaMat->cMat

public native void findPoint(String imgPath, long result);// 函数声明

... {// 函数调用
findPoint(appPath + "/img0.png", matBGR.getNativeObjAddr());
}
extern "C"
JNIEXPORT void JNICALL
Java_com_example_stitch_MainActivity_findPoint(
JNIEnv *env,
jobject thiz,
jstring imgPath,
jlong result) {
*(Mat *)result = mat.clone();// 一定要用clone()
umat.copyTo(*(Mat *)result);
}

jni的opencvmat与javaBitmap互转

参考:简书

jni新建图片返回到java

TODO

参考
stackoverflow

Tags

jni
ndk

Categories

1 / 1