早上好!
我正在开发一个使用java进行人脸识别的项目,但是我在FaceRecognizer类上遇到了这个错误:
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)
我已尝试以下链接中的解决方案,但它不起作用:s
获取“java.lang.UnsatisfiedLinkError”:java.library.path中没有lwjgl
线程“main”java.lang.UnsatisfiedLinkError中出现异常:java.library.path中没有openalprjni
线程“main”java.lang.UnsatisfiedLinkError”中出现异常
这是包含错误的代码部分:
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));
}
}
完整代码在这里:https://www.dropbox.com/s/pa415f6lz3zbco7/DemoFaceRecognize-master%20%282%29.zip?dl=0
如有任何帮助,我将不胜感激。
这是我找到的临时解决方案:
在主 java 文件中右键单击 --> 属性 --> 运行/调试设置 --> 选择主 java 文件并单击编辑 --> 参数 --> 在 VM 参数字段中输入以下内容:
-Djava.library.path="C:\Program Files\Java\opencv2.4.13\build\java\x64; C:\Program Files\Java\opencv2.4.13\build\x64\vc12\bin"
它将指向 dll 文件的路径,但不幸的是它对我不起作用:(
大家有什么不同的建议吗?
我遇到了同样的问题,但我无法解决它,我正在我的 pom 中运行 arg
<build>
<plugins>
<!-- JavaFX Maven Plugin -->
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<configuration>
<mainClass>tn.bfpme.test.MainFX</mainClass>
</configuration>
</plugin>
<!-- Exec Maven Plugin for Running Main Class -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<mainClass>tn.bfpme.test.MainFX</mainClass>
<arguments>
<argument>-Djava.library.path="C:\Program Files\Java\opencv2.4.13\build\java\x64; C:\Program Files\Java\opencv2.4.13\build\x64\vc12\bin"</argument>
</arguments>
</configuration>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>