Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to import JNI code ImageUtils #25

Closed
gerardsimons opened this issue Oct 31, 2016 · 5 comments
Closed

Unable to import JNI code ImageUtils #25

gerardsimons opened this issue Oct 31, 2016 · 5 comments

Comments

@gerardsimons
Copy link

Heya,

I am making an Android app, with similar functionality as the demo app in terms of dlib calls. I started from a new project, using the Gradle dependency. Everything works fine including JNI calls to DetFace etc. but I also want to use the JNI functions of the ImageUtils class and am not sure how I can include these? Every time I run them, I get an Implementation not found error. It seems the binaries are not inside the libpeople_det.so, right? Where are they then? I would expect to see a .so file somewhere, and a System.loadLibrary in ImageUtils, but I do not find either of them. Could anyone help me out? Thanks a lot.

@beraldofilippo
Copy link

You should post at least the error it gives, not much I can guess from your quick description.
The only thing I can recall now is that the JNI declaration of the methods is dependent from the package, so if for example if you've changed the package you should change it accordingly into the declaration.

I remeber it gave me some headaches when I modified it.

Also, remember that everything in the project is compiled into the libpeople_det.so, as for the Android.mk file

@gerardsimons
Copy link
Author

gerardsimons commented Oct 31, 2016

Hey, thanks for your quick reply. Sorry, here is a trace for the error :

10-31 15:03:39.205 23259-23376/com.qualogy.faceverificationapp E/art: No implementation found for void com.qualogy.faceverificationapp.ImageUtils.convertYUV420ToARGB8888(byte[], byte[], byte[], int[], int, int, int, int, int, boolean) (tried Java_com_qualogy_faceverificationapp_ImageUtils_convertYUV420ToARGB8888 and Java_com_qualogy_faceverificationapp_ImageUtils_convertYUV420ToARGB8888___3B_3B_3B_3IIIIIIZ)
10-31 15:03:39.206 23259-23376/com.qualogy.faceverificationapp E/AndroidRuntime: FATAL EXCEPTION: ImageListener
                                                                                 Process: com.qualogy.faceverificationapp, PID: 23259
                                                                                 java.lang.UnsatisfiedLinkError: No implementation found for void com.qualogy.faceverificationapp.ImageUtils.convertYUV420ToARGB8888(byte[], byte[], byte[], int[], int, int, int, int, int, boolean) (tried Java_com_qualogy_faceverificationapp_ImageUtils_convertYUV420ToARGB8888 and Java_com_qualogy_faceverificationapp_ImageUtils_convertYUV420ToARGB8888___3B_3B_3B_3IIIIIIZ)
                                                                                     at com.qualogy.faceverificationapp.ImageUtils.convertYUV420ToARGB8888(Native Method)
                                                                                     at com.qualogy.faceverificationapp.OnGetImageListener.onImageAvailable(OnGetImageListener.java:308)
                                                                                     at android.media.ImageReader$ListenerHandler.handleMessage(ImageReader.java:648)
                                                                                     at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                     at android.os.Looper.loop(Looper.java:148)
                                                                                     at android.os.HandlerThread.run(HandlerThread.java:61)

Your comments were useful. I am guessing that my project should either have the same package name (which I don't really like) or I should include the project directly rather than relying on the Maven repository? Or is there a way to call the methods with an explicit full method name from JNI (rather than relying on the package based prefix?)

BTW, I did an objdump of the so file, and indeed there is a symbol like this :

00000000000ce6b4 g    DF .text  00000000000001c8  Base        Java_com_tzutalin_dlibtest_ImageUtils_convertYUV420ToARGB8888

@gerardsimons
Copy link
Author

gerardsimons commented Oct 31, 2016

Oh, it already works if you just place ImageUtils in a com.tzutalin.dlibtest package, which is not so bad! Still if any other, less hacky solutions exist, I would love to know. Thanks again.

@beraldofilippo
Copy link

That's exactly the way JNI declarations work, if you place it into com.my.package make sure to change the declaration to Java_com_my_package_ImageUtils_convertYUV420ToARGB8888 and recompile the libs to get a working .so file.
Actually I don't think it as of being hacky, that's the (hacky) way the JNI works. :)

@gerardsimons
Copy link
Author

Haha, you are probably right. Thanks for your help @beraldofilippo !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants