Ask Your Question

Eirot's profile - activity

2016-11-29 03:02:32 -0600 commented question How to use opencv on Android Studio with Jni call

Thanks for your reply! Your posted link is helpful . Recently, I have found the solution and solved the problem by using cmake to include the OpenCV native header for my project. Here is my study wiki:

http://cxuef.github.io/android/Androi...

2016-11-27 20:06:30 -0600 asked a question How to use opencv on Android Studio with Jni call

Hi all,

Refrence to pure java to develop OpenCV demo , we can import new module *OpenCV-android-sdk\sdk\java* as a module dependencies for android project. Using this way, Android Studio will give the tips of functions and so on. Now I wanna do the same thing when I use Jni, see below please:

JNIEXPORT jintArray JNICALL Java_com_ckt_eirot_opencv4jni_GrayProcess_grayProcess(JNIEnv *env, class obj,jintArray buf,jint w, jint h) { jboolean ptfalse = false; jint *srcBuf = env->GetIntArrayElements(buf, &ptfalse); if (srcBuf == NULL) { return 0; } int size = w * h;

**Mat** srcImage(h, w, CV_8UC4, (unsigned char *) srcBuf);
**Mat** grayImage;

// when I type the part of bold function  like cvt… , I want to AS give me a tip of the usage
**cvtColor**(srcImage, grayImage, COLOR_BGRA2GRAY);
**cvtColor**(grayImage, srcImage, COLOR_GRAY2BGRA);

jintArray result = env->NewIntArray(size);
env->SetIntArrayRegion(result, 0, size, srcBuf);
env->ReleaseIntArrayElements(buf, srcBuf, 0);

return result;

}

Looking forward to replies