javaCV的安装

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21135080/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 06:49:55  来源:igfitidea点击:

Installation of javaCV

javaopencvjavacv

提问by snake plissken

I am trying to follow the instructions for installing javaCV from here: https://code.google.com/p/javacv/. I ve already built opencv. Actually I locate the java folder with .jar file and .dll in opencv folder and I add them in the path of my project. When I am trying to run the SimpleSample.java I am receiving Error: Could not find or load main class FaceRecognition. Is there something else I ve got to follow in order to install javaCV? My simple Code

我正在尝试按照以下说明安装 javaCV:https: //code.google.com/p/javacv/。我已经构建了 opencv。实际上,我在 opencv 文件夹中找到了带有 .jar 文件和 .dll 的 java 文件夹,并将它们添加到我的项目路径中。当我尝试运行 SimpleSample.java 时,我收到错误:无法找到或加载主类 FaceRecognition。为了安装javaCV,我还需要遵循什么吗?我的简单代码

 package simplesample;

 /**
 *
 * @author snake
 */

 import static com.googlecode.javacv.cpp.opencv_core.*;
 import static com.googlecode.javacv.cpp.opencv_imgproc.*;
 import static com.googlecode.javacv.cpp.opencv_highgui.*;

 public class SimpleSample{

/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
    // TODO code application logic here

   }
}

EDIT2: I add some jar files (javacv-windows-x86.jar, javacpp.jar, javacv.jar) and I finally got it running. But when I am trying to read a simple jpg image:

EDIT2:我添加了一些 jar 文件(javacv-windows-x86.jar、javacpp.jar、javacv.jar),我终于让它运行了。但是当我试图读取一个简单的 jpg 图像时:

 public static void main(String[] args) {
    // TODO code application logic here
    System.out.println("soul makosa");

    IplImage image = cvLoadImage("ef.jpg");
    if (image != null) {
        cvSmooth(image, image, CV_GAUSSIAN, 3);
        cvSaveImage("ef1.jpg", image);
        cvReleaseImage(image);
    }

}

I am reveiving the following errors:

我正在重温以下错误:

    Exception in thread "main" java.lang.UnsatisfiedLinkError: no jniopencv_highgui in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1886)
at java.lang.Runtime.loadLibrary0(Runtime.java:849)
at java.lang.System.loadLibrary(System.java:1088)
at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:711)
at com.googlecode.javacpp.Loader.load(Loader.java:586)
at com.googlecode.javacpp.Loader.load(Loader.java:540)
at com.googlecode.javacv.cpp.opencv_highgui.<clinit>(opencv_highgui.java:79)
at projectcv.ProjectCV.main(ProjectCV.java:28)
    Caused by: java.lang.UnsatisfiedLinkError: C:\Documents and Settings\chrathan\Local         Settings\Temp\javacpp101399456657827\jniopencv_highgui.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1965)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1890)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1851)
at java.lang.Runtime.load0(Runtime.java:795)
at java.lang.System.load(System.java:1062)
at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:700)
... 4 more
   Java Result: 1

I also add .dll file in properties->run->VM optimize as instructed here giving 'java.library.path' in netbeans for .dll/.so files. However I am still receiving the above message.

我还在属性-> 运行-> VM 优化中添加 .dll 文件,按照此处的说明在 netbeans 中为 .dll/.so 文件提供“java.library.path”。但是我仍然收到上述消息。

采纳答案by snake plissken

SOLVED:Ok my problems was due to the fact that I had to install specific version of javaCV. So for openCV version 2.4.6.1 I ve installed 0.6 java_CV and now works like a charm.

已解决:好的,我的问题是由于我必须安装特定版本的 javaCV。所以对于 openCV 版本 2.4.6.1 我已经安装了 0.6 java_CV 并且现在就像一个魅力。

回答by midhun0003

You need to add native class library path while adding opencv jar file into the project

项目中添加opencv jar文件时需要添加原生类库路径

Goto the buildpath>>libraries>>opencv >>click on expand and edit " native library location" to

转到构建路径>>库>>opencv >>单击展开并编辑“本机库位置”以

C:/opencv/build/java/x86

C:/opencv/build/java/x86

for face FaceRecognition you need to add all jar files from that site

对于 face FaceRecognition,您需要从该站点添加所有 jar 文件

javacv-0.7-bin.zip javacv-0.7-cppjars.zip ffmg, etc....

javacv-0.7-bin.zip javacv-0.7-cppjars.zip ffmg 等...

it will work .... Its working for me

它会工作......它对我有用