在eclipse中向java构建路径添加openCV

时间:2023-01-15 22:47:10

I have problems adding openCV to the buildpath of my eclipse-project. I have followed the instructions in the tutorial on this site: http://docs.opencv.org/2.4.4-beta/doc/tutorials/introduction/desktop_java/java_dev_intro.html#create-a-simple-java-project-in-eclipse

在我的eclipse-project的构建路径中添加openCV有问题。我已经按照本网站教程中的说明:http://docs.opencv.org/2.4.4- beta/doc/tutorials/tion/desktop_java/java_dev_intro.html #create-a-simple-java-project-in-eclipse

But executing the code fragment gives this console output:

但是执行代码片段会得到控制台输出:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no opencv-java2.4.4 in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at camStatisticsTests.RawTests.main(RawTests.java:20)

What do I have to do in order to get openCV working with java and eclipse. i want to use it as a normal java library.

要让openCV使用java和eclipse,我需要做什么?我想把它用作一个普通的java库。

6 个解决方案

#1


8  

I had the same problem.

我也有同样的问题。

It happened because I had a mistake with the 'Native library location' configuration:

这是因为我在“本地库位置”配置上犯了一个错误:

Goto Eclipse -> Window -> Preferences:

Goto Eclipse ->窗口->首选项:

在eclipse中向java构建路径添加openCV

Goto User Libraries:

转到用户库:

在eclipse中向java构建路径添加openCV

Make sure that your native library location path is (change c:/opencv-2.4.9 to your own opencv folder):

确保您的本地库位置路径为(将c:/opencv-2.4.9更改为您自己的opencv文件夹):

C:/opencv-2.4.9/build/java/x64

and not:

而不是:

C:/opencv-2.4.9/build/x64

(I missed the /java folder...)

(我错过了/java文件夹…)

#2


2  

The OpenCV java library is correctly linked to your Eclipse project.

OpenCV java库正确地链接到Eclipse项目。

The problem is the OpenCV native library which is not in the java.library.path. The exception is thrown by the line

问题是OpenCV本地库不在java.library.path中。该异常由行抛出

static{ System.loadLibrary("opencv_java244"); }

which link the java library to the native one.

将java库链接到本地库。

When you install OpenCV on your computer, it will also install a native dll library somewhere on your system, and when you call the System.loadLibrary, you tell java to search and load this library.

当您在您的计算机上安装OpenCV时,它也将在您的系统的某个地方安装一个本地dll库,当您调用系统时。loadLibrary,告诉java搜索和加载这个库。

Your current problem is Java can not find this library in your System, either because the library is not in one of the java.library.path folders, or because you have not OpenCV installed (also take a look at the version, maybe you have not the 2.4.4 because the last is 2.4.5, in which case you will have to adapt the String).

您当前的问题是Java无法在您的系统中找到这个库,或者因为该库不在Java .library中的任何一个中。路径文件夹,或者因为没有安装OpenCV(也可以查看版本,可能没有2.4.4,因为最后一个是2.4.5,在这种情况下,您必须调整字符串)。

I just noticed that your exception is about "opencv-java2.4.4". Be sure to have the right spelling of the form "opencv_java244", in your System.loadLibrary call.

我只是注意到你的例外是“opencv-java2.4.4”。请确保在您的系统中具有“opencv_java244”表单的正确拼写。loadLibrary电话。

I also redirect you to one of my answer, which is related to JavaCV, but that explain in more details what is going under.

我还将您重定向到我的一个答案,它与JavaCV相关,但这将更详细地解释正在发生的事情。

#3


1  

I found a solution. The actual dll is located in the openCV\opencv\build\java\x64\ folder. In my case, its name is opencv_java247.dll, so I have changed System.loadLibrary("opencv_java244") to System.loadLibrary("opencv_java247") in my java code. I also put the native library location as E:/Sagar_tools/tools/openCV/opencv/build/java/x64 (which is my full path to the dll).

我找到了一个解决方案。实际的dll位于openCV\ openCV\ \ openCV\ build\java\x64\文件夹中。在我的例子中,它的名字是opencv_java247。在我的java代码中,我将System.loadLibrary(“opencv_java244”)更改为System.loadLibrary(“opencv_java247”)。我还将本机库位置设置为E:/Sagar_tools/tools/openCV/ openCV/ build/java/x64(这是我到dll的完整路径)。

#4


1  

For me, Eclipse > external jar > native library config = opencv/build/lib worked

对于我来说,Eclipse >外部jar >本机库配置= opencv/build/lib有效

#5


0  

I have found the solution. The tutorial skips the step, where one has to add a dll to the "native build path". The dll is located in "opencv/build/java/x86" for 32-bit java i guess. although i dont know why this is the case. Would be nice, if someone could explain that.

我找到解决办法了。本教程跳过了这个步骤,在这个步骤中,必须向“本机构建路径”添加一个dll。dll位于“opencv/build/java/x86”中的32位java。虽然我不知道为什么会这样。如果有人能解释,那就太好了。

#6


-1  

Change the code to System.loadLibrary("opencv_java244") hope you would set the native path to correct folder and opencv jar has set in build path

将代码更改为System.loadLibrary(“opencv_java244”),希望您能将本机路径设置为正确的文件夹,并在构建路径中设置opencv jar

#1


8  

I had the same problem.

我也有同样的问题。

It happened because I had a mistake with the 'Native library location' configuration:

这是因为我在“本地库位置”配置上犯了一个错误:

Goto Eclipse -> Window -> Preferences:

Goto Eclipse ->窗口->首选项:

在eclipse中向java构建路径添加openCV

Goto User Libraries:

转到用户库:

在eclipse中向java构建路径添加openCV

Make sure that your native library location path is (change c:/opencv-2.4.9 to your own opencv folder):

确保您的本地库位置路径为(将c:/opencv-2.4.9更改为您自己的opencv文件夹):

C:/opencv-2.4.9/build/java/x64

and not:

而不是:

C:/opencv-2.4.9/build/x64

(I missed the /java folder...)

(我错过了/java文件夹…)

#2


2  

The OpenCV java library is correctly linked to your Eclipse project.

OpenCV java库正确地链接到Eclipse项目。

The problem is the OpenCV native library which is not in the java.library.path. The exception is thrown by the line

问题是OpenCV本地库不在java.library.path中。该异常由行抛出

static{ System.loadLibrary("opencv_java244"); }

which link the java library to the native one.

将java库链接到本地库。

When you install OpenCV on your computer, it will also install a native dll library somewhere on your system, and when you call the System.loadLibrary, you tell java to search and load this library.

当您在您的计算机上安装OpenCV时,它也将在您的系统的某个地方安装一个本地dll库,当您调用系统时。loadLibrary,告诉java搜索和加载这个库。

Your current problem is Java can not find this library in your System, either because the library is not in one of the java.library.path folders, or because you have not OpenCV installed (also take a look at the version, maybe you have not the 2.4.4 because the last is 2.4.5, in which case you will have to adapt the String).

您当前的问题是Java无法在您的系统中找到这个库,或者因为该库不在Java .library中的任何一个中。路径文件夹,或者因为没有安装OpenCV(也可以查看版本,可能没有2.4.4,因为最后一个是2.4.5,在这种情况下,您必须调整字符串)。

I just noticed that your exception is about "opencv-java2.4.4". Be sure to have the right spelling of the form "opencv_java244", in your System.loadLibrary call.

我只是注意到你的例外是“opencv-java2.4.4”。请确保在您的系统中具有“opencv_java244”表单的正确拼写。loadLibrary电话。

I also redirect you to one of my answer, which is related to JavaCV, but that explain in more details what is going under.

我还将您重定向到我的一个答案,它与JavaCV相关,但这将更详细地解释正在发生的事情。

#3


1  

I found a solution. The actual dll is located in the openCV\opencv\build\java\x64\ folder. In my case, its name is opencv_java247.dll, so I have changed System.loadLibrary("opencv_java244") to System.loadLibrary("opencv_java247") in my java code. I also put the native library location as E:/Sagar_tools/tools/openCV/opencv/build/java/x64 (which is my full path to the dll).

我找到了一个解决方案。实际的dll位于openCV\ openCV\ \ openCV\ build\java\x64\文件夹中。在我的例子中,它的名字是opencv_java247。在我的java代码中,我将System.loadLibrary(“opencv_java244”)更改为System.loadLibrary(“opencv_java247”)。我还将本机库位置设置为E:/Sagar_tools/tools/openCV/ openCV/ build/java/x64(这是我到dll的完整路径)。

#4


1  

For me, Eclipse > external jar > native library config = opencv/build/lib worked

对于我来说,Eclipse >外部jar >本机库配置= opencv/build/lib有效

#5


0  

I have found the solution. The tutorial skips the step, where one has to add a dll to the "native build path". The dll is located in "opencv/build/java/x86" for 32-bit java i guess. although i dont know why this is the case. Would be nice, if someone could explain that.

我找到解决办法了。本教程跳过了这个步骤,在这个步骤中,必须向“本机构建路径”添加一个dll。dll位于“opencv/build/java/x86”中的32位java。虽然我不知道为什么会这样。如果有人能解释,那就太好了。

#6


-1  

Change the code to System.loadLibrary("opencv_java244") hope you would set the native path to correct folder and opencv jar has set in build path

将代码更改为System.loadLibrary(“opencv_java244”),希望您能将本机路径设置为正确的文件夹,并在构建路径中设置opencv jar