JavaCV 给出 java.lang.UnsatisfiedLinkError

发布于 2024-11-25 16:54:32 字数 1334 浏览 1 评论 0原文

好吧,你可能会说“用谷歌搜索这个,有数百万个”。然而,我几乎花了一整天的时间来运行以下代码,但自从我尝试以来,我每次都得到 java.lang.UnsatisfiedLinkError: C:\Users\hp\AppData\Local\Temp\jniopencv_core2477828805078034839.dll: 找不到依赖库 错误让我发疯。

我找到了 javacv-bin 文件夹,其中包括 javacpp.jar、javacv.jar、javacv-windows-x86.jar、javacv-windows-x86_64.jar

在 Netbeans 中,我打开项目属性,并将它们添加到

我找到的 OpenCV2.3 文件夹中的库中,将其复制并粘贴到 C:\ 目录中。

我添加了 C:\OpenCV2.3\build\bin; C:\OpenCV2.3\build\x86\vc10\bin; C:\OpenCV2.3\build\x64\vc10\bin;PATH 中。

我相信没有什么可做的了。然而,自从我尝试以来,每次我都会遇到同样的错误。我已经筋疲力尽了,请有人帮助我。

最后要说的是,我同时拥有 32 位64 位 JDK,因此我尝试了这两种编译器,但没有用。

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 Smoother {
    public static void main(String[] args) {
        smooth("filename0.png");
    }
    public static void smooth(String filename) {
        System.out.println("java.library.path="+System.getProperty("java.library.path"));
        IplImage image = cvLoadImage(filename);
        if (image != null) {
            cvSmooth(image, image, CV_GAUSSIAN, 3);
            cvSaveImage(filename, image);
            cvReleaseImage(image);
        }
    }
}

Alright, you may say "use google search for this, there are millions of them". However, I almost spent all day just to run following code but every since I tried I got java.lang.UnsatisfiedLinkError:
C:\Users\hp\AppData\Local\Temp\jniopencv_core2477828805078034839.dll:
Can't find dependent libraries
error which drives me mad.

I found javacv-bin folder which includes javacpp.jar, javacv.jar, javacv-windows-x86.jar, javacv-windows-x86_64.jar.

In Netbeans, I opened project properties and I added them into the libraries

I found OpenCV2.3 folder, copied and pasted it into C:\ directory.

I added C:\OpenCV2.3\build\bin; C:\OpenCV2.3\build\x86\vc10\bin; C:\OpenCV2.3\build\x64\vc10\bin; in the PATH.

And I believe nothing to do left. However, every since I tried I got the same error. I'm exhausted please someone help me.

And last to say, I have both 32-bit and 64-bit JDKs so I tried both compilers but it's no use.

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 Smoother {
    public static void main(String[] args) {
        smooth("filename0.png");
    }
    public static void smooth(String filename) {
        System.out.println("java.library.path="+System.getProperty("java.library.path"));
        IplImage image = cvLoadImage(filename);
        if (image != null) {
            cvSmooth(image, image, CV_GAUSSIAN, 3);
            cvSaveImage(filename, image);
            cvReleaseImage(image);
        }
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

[旋木] 2024-12-02 16:54:32

我和你有同样的问题。假设您的 openCV 文件夹位置是 C:\OpenCV2.3,请执行以下操作。

  1. 在用户和系统环境变量下创建路径和类路径变量。

  2. 将此附加到所有四个变量(假设您有最新版本的 openCV2.3): C:\OpenCV2.3\build\bin;C:\OpenCV2.3\build\x64\mingw\bin;C:\OpenCV2.3\build\x64\vc9\bin;C:\OpenCV2.3 \构建\x64\ vc10\bin;C:\OpenCV2.3\build\x86\mingw\bin;C:\OpenCV2.3\build\x86\vc9\bin;C:\OpenCV2.3\build\x86\vc10\bin;< /代码>

希望有帮助!
阿拉文德

I had the same problem as you did. Assuming your openCV folder location is C:\OpenCV2.3, here is what to do.

  1. Create path and classpath variables under both user AND system environment variables.

  2. Append this to all four variables(Assuming you have the latest version of openCV2.3): C:\OpenCV2.3\build\bin;C:\OpenCV2.3\build\x64\mingw\bin;C:\OpenCV2.3\build\x64\vc9\bin;C:\OpenCV2.3\build\x64\vc10\bin;C:\OpenCV2.3\build\x86\mingw\bin;C:\OpenCV2.3\build\x86\vc9\bin;C:\OpenCV2.3\build\x86\vc10\bin;

Hope it helps!
Aravind

时光是把杀猪刀 2024-12-02 16:54:32

两个提示:

  • 您不能在路径中混合使用 64 和 x86 库!
  • 重新启动Eclipse

Two Tips:

  • You can't mix 64 and x86 libraries in the pathes!
  • restart Eclipse
泪眸﹌ 2024-12-02 16:54:32

我从未使用过 OpenCV,但不知怎的,我让我的 JNI 代码工作了。你生成了 .dll 还是它随包一起提供了?并检查这篇文章,它可能是 Ohelp 调用 C 子例程时出现 JNI 错误 。 ..还有一个建议尝试将您的 dll 放入 system32 文件夹中,然后使用 System.load(path/to/dll) 方法手动加载它...快乐编码

I have never worked with OpenCV ,but somehow I made my JNI code work.Have you generated the .dll or it comes with the package? And check this post ,it may Ohelp JNI error while calling a C subroutine ... One more suggestion try putting your dll in system32 folder and then load it manually using System.load(path/to/dll) method...Happy coding

奶茶白久 2024-12-02 16:54:32

如果有人遇到这个问题并且更新系统路径和类路径没有解决,请将您的 OpenCv2.3.1 目录重命名为“opencv”。它确实解决了我的问题。

If anybody have this problem and updating system path and class path didn't solve, rename your OpenCv2.3.1 directory to "opencv". It did solve my problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文