I want to access c++ code from java program. For that I used concept of JNI.
I declare one native method in java, whose return type is Mat class of opencv, as follows :
public native Mat getFrames();
Then using javah utility, I created c implementation(Header File) of my java class JNITest.h using command : javah -jni java_class_name. This header file is as follows :
#include <jni.h>
#ifndef _Included_JNITest
#define _Included_JNITest
#ifdef __cplusplus
extern "C" {
#endif
JNIEXPORT jobject JNICALL Java_JNITest_getFrames(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif
I implement this Java_JNITest_getFrames method in cpp file as follows:
JNIEXPORT jobject JNICALL Java_JNITest_getFrames(JNIEnv *en, jobject)
{
Mat frame;
VideoCapture cap("D:\\ImageProcessing\\1.jpg");
cap>>frame;
jobject jb ;
Mat * ptrImg = &frame;
jb=(jobject)ptrImg;
return jb;
}
But, this above code is not working.
So, how to convert opencv Mat class object to this jobject ?
And how do I return that object ?