UnsatisfiedLinkError: org.opencv.highgui.Highgui.imread_0 (OpenCV Java)

删除回忆录丶 提交于 2019-12-23 02:53:02

问题


I am trying to use OpenCV in a servlet and this error pops up everytime I run the servlet. Here is the stacktrace for the same:

SEVERE: Servlet.service() for servlet [com.patternrecognition.preprocessing.Preprocessing] in context with path     **[/ImagePreprocessing] threw exception [Servlet execution threw an exception] with root cause
java.lang.UnsatisfiedLinkError: org.opencv.highgui.Highgui.imread_0(Ljava/lang/String;I)J
at org.opencv.highgui.Highgui.imread_0(Native Method)
at org.opencv.highgui.Highgui.imread(Highgui.java:309)**
at com.patternrecognition.preprocessing.Preprocessing.smooth(Preprocessing.java:168)
at com.patternrecognition.preprocessing.Preprocessing.startPreprocessing(Preprocessing.java:56)
at com.patternrecognition.preprocessing.Preprocessing.doGet(Preprocessing.java:46)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:315)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)

I am running out of time for my Project. Please help.


回答1:


I resolved this issue by using the absolute path of the image that was being read by the method "imread". Because it is a web project, it was not taking the relative path of the default project folder.

I was doing:

Highgui.imread("img_perspective.png", Highgui.CV_LOAD_IMAGE_GRAYSCALE);

I changed it to:

Highgui.imread("C:/Users/ImagePreprocessing/WebContent/WEB-INF/img_perspective.png", Highgui.CV_LOAD_IMAGE_GRAYSCALE);

Hope it helps.




回答2:


Your unsatisfied link error is most likely due to the server not understanding where the appropriate shared objects exist on the filesystem.

You will need to have the opencv jar, opencv java shared object, and the opencv shared libraries available to the JVM.

This varies depending on your container and OS.

You may wish to look at setting "java.library.path" or LD_LIBRARY_PATH.



来源:https://stackoverflow.com/questions/26849618/unsatisfiedlinkerror-org-opencv-highgui-highgui-imread-0-opencv-java

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