Cant load a picture with java open cv

匿名 (未验证) 提交于 2019-12-03 00:46:02

问题:

I tried putting all libraries in my project (it was describet like solution of this problem ) but there is still same problem.

Mat m = Highgui.imread("Koala.jpg");  Exception in thread "main" java.lang.UnsatisfiedLinkError: org.opencv.highgui.Highgui.imread_1(Ljava/lang/String;)J     at org.opencv.highgui.Highgui.imread_1(Native Method)     at org.opencv.highgui.Highgui.imread(Highgui.java:352)     at Open.main(Open.java:26) 

回答1:

I got the same error and the below line worked for me.

System.loadLibrary(Core.NATIVE_LIBRARY_NAME);



回答2:

Java can't currently see OpenCV, hence the linking error.

I'm on a Mac, so I link to its location on my drive:

System.load( "/opt/local/share/OpenCV/java/libopencv_java246.dylib" ) 

You might also be able to include the JAR directly in your lib folder in your project, but I've had success by pointing to the dylib.



回答3:

Set path as C:\opencv\build\java\x64 in your project properties. In Netbeans it is project-properties-run-vmoptions=-Djava.library.path="C:\opencv\build\java\x64"

In Eclipse, Add library Window-prreference-java-buildpath-userlibraries-new-opencv,,, Add external jars(add the opencv-300 jar) set native library inside opencv as C:\opencv\build\java\x64. And add library to our project.

and to read an image use Imgcodecs.imread, Mat img=Imgcodecs.imread("C:\Users\softroniics\Documents\NetBeansProjects\SceneRecogintion\src\com\SR\view\burj.png");



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!