OpenCV到JNI如何使其工作? [英] OpenCV to JNI how to make it work?

查看:140
本文介绍了OpenCV到JNI如何使其工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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); (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的?我试过Google,但是对这个特定主题的帮助是非常糟糕的。



我已经在netbeans项目中将整个文件夹添加为Llibrary,并且我尝试运行该文件,跟随着。



线程main中的异常java.lang.UnsatisfiedLinkError:FaceDetection.JNIOpenCV.detectFace(IILjava / lang / String; Ljava / lang / String ;)FaceDetection.JNIOpenCV.detectFace(Native Method)上的
在FaceDetection.FaceDetection中的
。< init>(FaceDetection.java:19)
在FaceDetection.FaceDetection.main(FaceDetection .java:29)
Java结果:1
BUILD SUCCESSFUL(总时间:2秒)



<任何人都告诉我确切的工作方式吗?像我所需要做的一样?

解决方案

我已经创建了一个使用OpenCV 2.3.1和Eclipse而不是Netbeans的工作Android示例。



此小教程介绍火炬手后的机器人。该页面还包含必要的步骤和源代码。


I am tring to use opencv and java for face detection, and in that pursit i found this "JNI2OPENCV" file....but i am confused on how to make it work, can anyone help me?

http://img519.imageshack.us/img519/4803/askaj.jpg

and the following is the 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();   
    }
}

CAn anyone tell me how can i make this work on Netbeans?? I tried Google but help on this particular topic is very meger.

I have added the whole folder as Llibrary in netbeans project and whe i try to run the file i get the followig wrroes.

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)

CAn anyone tell me the exact way to work with this? like what all i have to do?

解决方案

I have created a working Android example using OpenCV 2.3.1 and Eclipse instead of Netbeans.

This small tutorial describes a robot following torchlight. The page contains the necessary steps and the source code as well.

这篇关于OpenCV到JNI如何使其工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆