java.lang.UnsatisfiedLinkError opencv-contrib - java

I'm trying to make an application with opencv that is able to recognize a person's face in an image, so I'm trying to use the FacemarkKazemi function of opencv. My problem is that as soon as I switch to class initialization, my application crashes instantly.
You can find the code I'm trying to run here :
https://github.com/opencv/opencv_contrib/blob/master/modules/face/samples/Facemark.java
The application crashes at line 29 here :
Facemark fm = Face.createFacemarkKazemi();
And i have this error :
java.lang.UnsatisfiedLinkError: No implementation found for long org.opencv.face.Face.createFacemarkKazemi_0() (tried Java_org_opencv_face_Face_createFacemarkKazemi_10 and Java_org_opencv_face_Face_createFacemarkKazemi_10__)
Also, if you know a better way to make FacialMarks, I would be happy to know it.
EDIT : I added this line to my gradle to import opencv contrib, do you think the error could be due to this?
implementation 'com.quickbirdstudios:opencv:3.4.4-contrib'

Before I integrated opencv directly into my project, when I wanted to add opencv-contrib I had to add the gradle to my project (but that never gave me the.so for android) that's why it wasn't able to find the functions, there were no pre-compiled files.
So I downloaded an opencv sdk with opencv contrib and added the.so in the jnilibs folder.

Related

opencv 3.2.0 java Face Recognition Ubuntu

i am using opencv 3.2.0 and im trying to get the face recognition up and running.
I am faced with the problem that the Face class in org.opencv.face.Face being empty. This is all contained in the file :
//
// This file is auto-generated. Please don't modify it!
//
package org.opencv.face;
public class Face {
}
From what i have read i need to add 'java' to the CMakeLists.txt of Face contrib module in order to add it to the final jar such as
ocv_define_module(face opencv_core opencv_imgproc opencv_objdetect WRAP python java)
In order to tell the compiler to include the contrib modules i have to add
-D
OPENCV_EXTRA_MODULES_PATH=$YOUR_OPENCV_CONTRIB_PATH/opencv_contrib-
3.2.0/modules
to the cmake command , and later make it , in general my commands are as follows
1: cmake
2: make -j5
I get no errors when compiling and building and i get my jar,
which i use without issues for face detection and so forth.
The problem is that the Face class is empty and i cannot create a FaceRecognizer.
i was following this guide here
https://github.com/andreaiacono/OpenCVDemo - as of 01.06.2017
and in the org.opencv.demo.core.RecognizerFactory class he uses
return Face.createFisherFaceRecognizer();
which as it seems i can not use.
I tried to search if the 3.2.0 libraries have a different way of creating a recognizer but google is not very helpful as there are just a handful of answers to any java opencv related issues.
What could be causing the Face class to be empty and/or are there any other ways to create recognizers in case that 3.2.0 indeed works differently ?
Thank you for the time
I have found an answer to my previous question and i am posting it for all to see , i hope i could help some other lost soul like myself.
I have tested with version 3.1.0 and it would appear that the Face class is NOT empty. Proving that Face detection in 3.2.0 may not be implemented properly (as of the time of writing).
I faced issues with compiling properly due to usage of some libraries :
/usr/include/c++/6.1.1/cstdlib:75:25: fatal error: stdlib.h: No such file or directory
#include_next <stdlib.h>
An answer i found to this issue was found in https://github.com/opencv/opencv/issues/6517#issuecomment-219219767
namely to include this in the cmake :
cmake -DENABLE_PRECOMPILED_HEADERS=OFF
This allowed me to compile everything properly and i managed to get my face recognition code up and running :)
Good luck to all

Android JavaCV - UnsatisfiedLinkError and couldn't find "libopencv_core.so"

I use JavaCV 1.1. I have added jar files (javacv.jar, javacpp.jar and opencv.jar) and *.so libraries to my project in Android Studio. I succesfully build and run my app on Android 5.1 phone, but when i try use functions, that used OpenCV i get error:
java.lang.UnsatisfiedLinkError:dalvik.system.PathClassLoader[DexPathList[[zipfile"/data/app/com.example.dogan.ligntningshower-/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]] couldn't find "libopencv_core.so"
I try to add
static {
System.loadLibrary("opencv_core");
System.loadLibrary("jniopencv_core");
}
but it's no work. How to fix it?
I just add *.so libs to folder /app/src/main/jniLibs/armeabi and now all works fine!
if someone still looking for the answer, first you should check if you added correct files to jniLibs folders. heres a complete tutorial :
A Beginner’s Guide to Setting up OpenCV Android Library on Android Studio
second, if .os files are at their places in each and every folder then you should only change the names to the name that is showing up in the compiler error.
in my case the names were libopencv_java3.so and yet the compiler was saying couldn't find "libopencv_java343.so" . after changing the name to libopencv_java343.so it worked.

Using JRuby in Android Studio

I'm trying to use JRuby in projects created in Android studio. I have built the latest (as of 9/10/2014) JRuby, and have completely updated Android Studio. I have a working app that I can use to test. I have a copy of jruby.jar in the MyApp/app/libs directory. Once there I right-clicked on jruby.jar and selected "Add as Library", which presumably did something (though what I am not certain), and have added the line "compile files('libs/jruby.jar')" to the build.gradle that is in MyApp/app/.
In one of the class files I have "import org.jruby.embed.ScriptingContainer;", which Android Studio says is fine (if I hadn't added jruby.jar as a library I couldn't include this without an error). Then in one of the working methods I say "ScriptingContainer container = new ScriptingContainer();". When I run this method the app will crash. I won't try to include the whole error message, but the important part seems to be:
Caused by: java.lang.ExceptionInInitializerError
at org.jruby.embed.internal.AbstractLocalContextProvider.<init>(AbstractLocalContextProvider.java:42)
at org.jruby.embed.internal.SingletonLocalContextProvider.<init>(SingletonLocalContextProvider.java:88)
at org.jruby.embed.ScriptingContainer.getProviderInstance(ScriptingContainer.java:248)
at org.jruby.embed.ScriptingContainer.<init>(ScriptingContainer.java:228)
at org.jruby.embed.ScriptingContainer.<init>(ScriptingContainer.java:185)
and
Caused by: java.lang.RuntimeException: unsupported Java version: 0.9
at org.jruby.RubyInstanceConfig.initGlobalJavaVersion(RubyInstanceConfig.java:1858)
at org.jruby.RubyInstanceConfig.<clinit>(RubyInstanceConfig.java:1608)
At least, those are the parts that make sense to me. I hav no idea why I would get the error "java.lang.RuntimeException: unsupported Java version: 0.9", since I am using 1.8.0_20. The rest of the errors I cannot follow. When I click on any of the files giving me an error (say AbstractLocalContextProvider.java:42) Android Studio will show the file but also say "Sources not found". That could be the problem, but I don't know why it can't find the sources.
Thanks for any help,
Brian
Uwe Kubosch (‏#donv70) was able to tell me the solution to this via Twitter, so credit to him, but I wanted to post the solution here in case anyone else needs it.
It was Java version that was causing the problem. In Ruboto the problem is solved here: https://github.com/ruboto/ruboto/blob/master/assets/src/org/ruboto/JRubyAdapter.java#L137
and for use in Android Studio it is necessary only to include the line: System.setProperty("jruby.bytecode.version", "1.6");
The number of course can be 1.6, 1.7, or 1.8, depending on your version of Java.
Looks like an interoperability problem between JRuby and the Dalvik VM (don't forget that you're running against Dalvik, not the Java VM).
There's a bug report at http://jira.codehaus.org/browse/JRUBY-5774 that may lead you in the right direction.
It's kind of old, and is marked 'fixed', but maybe it'll provide some clues?

exporting project with native libraries in eclipse

I have a project that uses leap motion sdk. I wrote this project in Eclipse. When I run my program I don't have any problem because I set my native libraries as it is suggested from configuration.
However, when I export my application I can not run my program because Eclipse does not include my native libraries and I am having this error.
Native code library failed to load.
java.lang.UnsatisfiedLinkError: no LeapJava in java.library.path
My purpose is create a .jar file which user can run with one click on Windows(just). I tried this methodologies as it is suggested in stackoverflow. However, I could not get this result.
1.) method with static{ System.load("write each .dll") }
This did not work becuse I am having a error when I try to load Leapd.dll.
2.) System.setProperty("java.library.path", "C:/Users/can/Desktop/Vinar_libraries/LeapSDK/lib/x64/" );
This one also did not work.
3.) Adding -Djava.library.path="\LeapSDK\lib\x64" parameter from running configurations on Eclipse.
I know this subject is mentioned many times in stackoverflow. However, proposed solutions did not work for Leap Motion sensor.

eclipse can not locate my foregroundcameraplugin.xml file

so im making this cordova / phonegap application.
I found out that The default Phonegap (Cordova) Camera Plugin calls the native camera and this makes Android Garbage Collector to kill background applications.
so I found a plugin that fixes this :
https://code.google.com/p/foreground-camera-plugin/
now I followed the steps as these guys told. and I'm having the following problems that I cant resolve and need help on.
There was a problem with the cameraActivity.java it did not recognize thegenerated file R.java
then I used an import statement to make it have access to this file
import statement : import java.android.R;
after this eclipse doesnt recognize the foregroundcameraplugin.xml.
besides this my my styles.xml files in values-v11 and values-v14 directories are giving an error
"Error retrieving parent for item; no reources found that match the given name #android: Theme.Holo.Light.DarkActionBar "
this is how my forground camera plugin looks like :
If anyone knows how too fix this please let me know
thank you
I was able to reply the error with the new Eclipse Kepler and found the solution: upgrade your ADT to version 22 and install Android SDK Build-tools by SDK manager. I have also commited a new classpath file for ForegroundCameraPlugin project with some changes (included Android Private Libraries). Thanks to your contact and the help of this link: Eclipse giving error, missing R.java file after recent update

Categories