user3693423
user3693423

Reputation:

Get element of arrayList using JNI

i am using OpenCV to compute some algorimths, but now i want to convert its into java code, in java code, my program has a method:

public native float[] computeFeatures(ArrayList<float[]> listData);

now, i am using javah to generate header file and in jni, this method is look like:

JNIEXPORT jfloatArray JNICALL Java_cspdemo_CSPTest_computeFeatures (JNIEnv *, jobject, jobject);

How do i get elements (each float array such as listData1 = {1,3,4,0};) of listData coressponding in JNI? please help me, thank's!

Upvotes: 0

Views: 386

Answers (1)

manuell
manuell

Reputation: 7620

Use the size method for obtaining the number of arrays in the collection.

Then use the get method for obtaining an array, in a loop.

Then, for each array, use the GetFloatArrayElementsJNI API.

Upvotes: 1

Related Questions