Skip to content Skip to sidebar Skip to footer

How To Return Array Of Mat From Jni To Java

How can I write my c++ JNI function so that it returns an array of Mat to Java code? I am programming in Android environment, with the help of NDK to use also some functions of Ope

Solution 1:

One solution is to allocate an array of equal size in Java, pass it to your native getFrames() function, and inflate the Mat objects individually using your frame buffer. Please see this post for an example of passing an array to native code, and this one for a way to inflate a Java Mat from a native one.

If you really need to create the array in native code and return it, please have a look at the NewObjectArray method that's available through JNI. (Example)

Post a Comment for "How To Return Array Of Mat From Jni To Java"