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

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

问题描述

我正在尝试使用 opencv 和 java 进行人脸检测,在那个追求中我发现了这个JNI2OPENCV"文件......但我对如何使它工作感到困惑,有人可以帮助我吗?

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

下面是FaceDetection.java

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();   
    }
}

谁能告诉我如何在 Netbeans 上进行这项工作?我试过谷歌,但对这个特定主题的帮助非常有限.

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

我已在 netbeans 项目中将整个文件夹添加为 Llibrary,当我尝试运行该文件时,我得到了 followig wrroes.

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

线程main"中的异常 java.lang.UnsatisfiedLinkError: FaceDetection.JNIOpenCV.detectFace(IILjava/lang/String;Ljava/lang/String;)[I在 FaceDetection.JNIOpenCV.detectFace(本机方法)在 FaceDetection.FaceDetection.(FaceDetection.java:19)在 FaceDetection.FaceDetection.main(FaceDetection.java:29)Java 结果:1构建成功(总时间:2 秒)

谁能告诉我使用它的确切方法?比如我需要做什么?

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

推荐答案

我使用 OpenCV 2.3.1 和 Eclipse 而不是 Netbeans 创建了一个有效的 Android 示例.

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 to JNI 如何使它工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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