我正在尝试使用 opencv 和 java 进行人脸检测,在那个过程中,我发现了这个“JNI2OPENCV”文件....但我对如何使它工作感到困惑,有人可以帮助我吗?
http://img519.imageshack.us/img519/4803/askaj.jpg
以下是 FaceDetection.java
class JNIOpenCV {
static {
System.loadLibrary("JNI2OpenCV");
}
public native int[] detectFace(int minFaceWidth, int minFaceHeight, String cascade, String filename);
}
public class FaceDetection {
private JNIOpenCV myJNIOpenCV;
private FaceDetection myFaceDetection;
public FaceDetection() {
myJNIOpenCV = new JNIOpenCV();
String filename = "lena.jpg";
String cascade = "haarcascade_frontalface_alt.xml";
int[] detectedFaces = myJNIOpenCV.detectFace(40, 40, cascade, filename);
int numFaces = detectedFaces.length / 4;
System.out.println("numFaces = " + numFaces);
for (int i = 0; i < numFaces; i++) {
System.out.println("Face " + i + ": " + detectedFaces[4 * i + 0] + " " + detectedFaces[4 * i + 1] + " " + detectedFaces[4 * i + 2] + " " + detectedFaces[4 * i + 3]);
}
}
public static void main(String args[]) {
FaceDetection myFaceDetection = new FaceDetection();
}
}
谁能告诉我如何在 Netbeans 上完成这项工作?我试过谷歌,但对这个特定主题的帮助非常大。
我已将整个文件夹添加为 netbeans 项目中的 Llibrary,当我尝试运行该文件时,我得到了以下错误。
Exception in thread "main" java.lang.UnsatisfiedLinkError: FaceDetection.JNIOpenCV.detectFace(IILjava/lang/String;Ljava/lang/String;)[I
at FaceDetection.JNIOpenCV.detectFace(Native Method)
at FaceDetection.FaceDetection.<init>(FaceDetection.java:19)
at FaceDetection.FaceDetection.main(FaceDetection.java:29)
Java Result: 1
BUILD SUCCESSFUL (total time: 2 seconds)
谁能告诉我使用这个的确切方法?就像我要做的一切?