0

Good morning!

I'm working on a project of face recognition using java but I got this error on FaceRecognizer class:

Exception in thread "main" java.lang.UnsatisfiedLinkError: com.compa.opencv.nativec.FisherFaceRecognizerID.createFisherFaceRecognizer_1()J
    at com.compa.opencv.nativec.FisherFaceRecognizerID.createFisherFaceRecognizer_1(Native Method)
    at com.compa.opencv.nativec.FisherFaceRecognizerID.<init>(FisherFaceRecognizerID.java:15)
    at com.compa.opencv.PlayMain.createRecognizer(PlayMain.java:128)
    at com.compa.opencv.PlayMain.cameraRecognize(PlayMain.java:88)
    at com.compa.opencv.PlayMain.main(PlayMain.java:33)

I have tried the solutions in these below links but it didn't work :s

Getting 'java.lang.UnsatisfiedLinkError': no lwjgl in java.library.path

Exception in thread "main" java.lang.UnsatisfiedLinkError: no openalprjni in java.library.path

Exception in thread "main" java.lang.UnsatisfiedLinkError"

Here is the part of the code which contains the error:

package com.compa.opencv.nativec;

import org.opencv.contrib.FaceRecognizer;

public class FisherFaceRecognizerID extends FaceRecognizer{

    private static native long createFisherFaceRecognizer_1();

    private static native long createFisherFaceRecognizer_1(int num_components);

    private static native long createFisherFaceRecognizer_2(int num_components,
            double threshold);

    public FisherFaceRecognizerID() {
        super(createFisherFaceRecognizer_1());
    }

    public FisherFaceRecognizerID(int num_components) {
        super(createFisherFaceRecognizer_1(num_components));
    }

    public FisherFaceRecognizerID(int num_components, double threshold) {
        super(createFisherFaceRecognizer_2(num_components, threshold));
    }

}

Full code here: https://www.dropbox.com/s/pa415f6lz3zbco7/DemoFaceRecognize-master%20%282%29.zip?dl=0

I would be grateful with any kind of help.

Community
  • 1
  • 1
J4J
  • 1
  • 2

2 Answers2

1

Looks to me like you are using a third party face recognition library that depends on a native binary.

You have to add those native binaries in your class path e.g. (*.dll files in windows, or *.so in unix or linux)

UnsatisfiedLinkError - usually means a Java Native Interface (JNI) call where it fails to locate the native binary files.

Here is a screenshot on eclipse where you can see a Native Library in the source and you can click Edit and select the folder where your DLL or so files are. Here is a screen on eclipse project properties

Itherael
  • 193
  • 3
  • 10
  • Thank for your reply, I'm using the dll file from Opencv library and I have loaded it in the main but still the error is there.. Also I used the suggest solution in the above link -Djava.library.path and still no change. – J4J Mar 29 '17 at 06:46
  • I have attached a screenshot on eclipse where you can select the location of the native libraries associated with your source directory. If you are 100% sure that the location of the DLL is visible when you run java and it still doesn't work, you need to check the compatibility of those DLL on your system, e.g. 32bit dlls or 64bit dlls. Those binary structures for different architecture could potentially be a problem – Itherael Mar 29 '17 at 08:04
  • Select the Native library location (None) and click Edit to specify the directory where those native libraries are stored. Hope that helps. – Itherael Mar 29 '17 at 08:08
  • Thanks again for your reply brother, I followed the steps that you suggest in the screen shot where I edited the native library location to point the path of the dll file and I chose the compatible one for my system --64bit-- but nothing changes :( ...... someone suggest to me that maybe the dll file is invalid...What do you think? – J4J Mar 29 '17 at 09:19
0

This is the temporary solution that I found:

In the main java file right click --> Properties --> Run/Debug settings --> Choose the main java file and click on Edit --> Arguments --> In the VM arguments field enter the following:

-Djava.library.path="C:\Program Files\Java\opencv2.4.13\build\java\x64; C:\Program Files\Java\opencv2.4.13\build\x64\vc12\bin" 

Which will point to the path of the dll files, but unfortunately it didn't work with me :(

Does anyone have any different suggestions?

J4J
  • 1
  • 2