4

我确定这将是某种 PATH 问题,但我不确定我哪里出错了。我试图让 JavaCV 在我的 Eclipse 项目中工作,这样我就可以对图像进行一些圆形检测,但在尝试运行示例项目之一时得到 Eclipse 抛出的以下异常:

java.lang.UnsatisfiedLinkError

我已尝试按照以下说明进行操作:http ://code.google.com/p/javacv/

我的项目的 BuildPath 中有javacv.jarand jna.jar。我需要做什么才能将正确的文件添加到正确的路径以使 JavaCV 正常工作?

我尝试将 jar 文件添加到 $CLASSPATH 但得到相同的错误。我已经下载并安装了 OpenCV,不确定我需要从这个文件夹中添加什么到 $PATH。任何帮助表示赞赏。

4

4 回答 4

2

I also get the same exception when I try to run my first javacv application. I also try various things and last I found that the incompatible versions are the cause for this exception. So it might be the case in your problem as well.

于 2012-06-19T02:55:56.297 回答
2

UnsatisfiedLink 错误意味着一个或多个本机库文件无法链接到您的程序中。这最常见的原因是本机库文件不在 JVM 所在的位置。

有关详细信息,请参阅http://java.sun.com/docs/books/jni/html/start.html的第 2.7 节。

于 2012-02-12T16:36:27.160 回答
2

你能把整个错误放在你的应用程序中吗?有时问题可能是 javacv 和 opencv 的两个版本不兼容。因此,请尝试检查您是否有兼容的版本。

于 2012-06-19T02:43:43.573 回答
1

我也面临类似的问题,我尝试从源代码构建 OpenCV 以及使用 MacPorts。比我尝试在 eclipse 中设置本机库路径以指向构建 OpenCV 的位置,但这对我不起作用。最后,我通过 Macports 安装 OpenCV 解决了这个问题,Macports 将所有 .dylibs 安装在“/opt/local/lib”路径中。此后我执行了以下 shell 脚本(在http://code.google.com/p/javacv/wiki/HowToMakeAnApplet给出)

BADPATH=/opt/local/lib 
for f in libopencv*2.4.dylib; do install_name_tool $f -id @rpath/$f \
-add_rpath /usr/local/lib/ -add_rpath /opt/local/lib/ -add_rpath @loader_path/. \
-change $BADPATH/libopencv_core.2.4.dylib @rpath/libopencv_core.2.4.dylib \
-change $BADPATH/libopencv_calib3d.2.4.dylib @rpath/libopencv_calib3d.2.4.dylib \
-change $BADPATH/libopencv_features2d.2.4.dylib @rpath/libopencv_features2d.2.4.dylib \
-change $BADPATH/libopencv_flann.2.4.dylib @rpath/libopencv_flann.2.4.dylib \
-change $BADPATH/libopencv_gpu.2.4.dylib @rpath/libopencv_gpu.2.4.dylib \
-change $BADPATH/libopencv_highgui.2.4.dylib @rpath/libopencv_highgui.2.4.dylib \
-change $BADPATH/libopencv_imgproc.2.4.dylib @rpath/libopencv_imgproc.2.4.dylib \
-change $BADPATH/libopencv_legacy.2.4.dylib @rpath/libopencv_legacy.2.4.dylib \
-change $BADPATH/libopencv_ml.2.4.dylib @rpath/libopencv_ml.2.4.dylib \
-change $BADPATH/libopencv_nonfree.2.4.dylib @rpath/libopencv_nonfree.2.4.dylib \
-change $BADPATH/libopencv_objdetect.2.4.dylib @rpath/libopencv_objdetect.2.4.dylib \
-change $BADPATH/libopencv_photo.2.4.dylib @rpath/libopencv_photo.2.4.dylib \
-change $BADPATH/libopencv_video.2.4.dylib @rpath/libopencv_video.2.4.dylib; done

运行上面给定的脚本后,我简单地创建了一个示例 JavaCV 项目(使用http://www.cnblogs.com/ljsspace/archive/2011/08/05/2128948.html给出的示例代码)并能够运行它从 Eclipse 成功,无需设置任何其他路径。

于 2013-02-11T18:37:14.300 回答