Search code examples
javacarraysjava-native-interface

java jni transfer coordinates from c to java


i will get straight to question. I have facedetection done in c with .dll libraries using jni. I send stream array from java to c. I am successful on getting coordinates of the face (4 points), how do I transfer those coordinates from C back to java? These coordinates are constantly updated, and I need to use those 4points to draw a rectangle in java around the face. At the moment in c I can only print out the points. I tryed writing themto .txt the reading in java from it but there is such a huge delay,so I abandoned this attempt.


Solution

  • With JNI you can:

    • Access Java fields from C.
    • Call Java methods from C.

    If performance matters to you, you might want to have a data structure for these 4 points, pass a reference to that data structure to C, and in C update the fields of that data structure. (data structure = class that primarily holds data but doesn't offer a lot of operations)