[Question/Java/Help] how to get openCV to run in a jar?

asked 2018-05-10 15:40:37 -0600

kyl293 gravatar image

updated 2018-05-10 16:04:49 -0600

So I've been trying for a really long time to get my program to run in a jar file through cmd and I kept getting the error: "exception in thread main java.lang.unsatisfiedlinkerror no opencv in java.library.path" with some extra bits of unneeded code. I fixed that part by putting the .dll files in a resource folder and reading them through with the following code:"inputStream = LoadOpenCv.class.getResourceAsStream("/opencv/windows/x64/opencv_java341.dll");" and also using file output stream to load it into the program i was able to fix the problem. My newest problem is that it does not read or connect to the IP camera that I am using to test it. When I run it in netbeans everything works fine, but if I run it as a jar file by clicking on it or using java -jar {programname}.jar it returns a blank popup(where the output of the camera would be). Any information or help you can give me is deeply appreciated and would really help me out. Thank you! This is the program I am using to test it( so I know it's not the bugs in my program that may cause the issue) https://ratiler.wordpress.com/2014/09...

edit retag flag offensive close merge delete

Comments

you probably missed, that opencv is actually a c++ library, and that everything in opencv-xx.jar is only a shallow wrapper around jni / c++code.

berak gravatar imageberak ( 2018-05-10 16:05:34 -0600 )edit

in other words, what you want is not feasible/doable. there will always be the dependancy on some opencv.so or dll.

berak gravatar imageberak ( 2018-05-10 16:07:29 -0600 )edit

I understand what you are saying but am supplying it with the necessary dll file by putting them into a resource file and loading them manually through output stream and it provides me with no crash or anything just I can't view the webcam

kyl293 gravatar imagekyl293 ( 2018-05-10 16:38:40 -0600 )edit

a dll cannot be loaded from a resource file

berak gravatar imageberak ( 2018-05-10 16:50:39 -0600 )edit

you also missed opencv_ffmpeg.dll, which has all functionality to read video files.

berak gravatar imageberak ( 2018-05-10 16:53:40 -0600 )edit

? I was able to do it though. If you load it through a file outputstream you are able to load the .dll file into the program. I apologize for my adamance, but it works from netbeans when I load it this way and it dosen't crash the program when I run it. I can send you my test program if you want to see it in action

kyl293 gravatar imagekyl293 ( 2018-05-10 16:55:05 -0600 )edit

I do use the opencv_ffmpeg as well I just didn't include it as I was only trying to show the concept that I was using

kyl293 gravatar imagekyl293 ( 2018-05-10 16:56:36 -0600 )edit

well, you have to.

berak gravatar imageberak ( 2018-05-10 16:58:20 -0600 )edit

ffmpeg is only if you were to save the video files I thought as well.

kyl293 gravatar imagekyl293 ( 2018-05-10 17:02:32 -0600 )edit

no, ip cam access, too.

berak gravatar imageberak ( 2018-05-10 17:04:06 -0600 )edit