adding openCV to java buildpath in eclipse

前端 未结 6 1031
滥情空心
滥情空心 2020-12-20 13:35

I have problems adding openCV to the buildpath of my eclipse-project. I have followed the instructions in the tutorial on this site: http://docs.opencv.org/2.4.4-beta/doc/tu

相关标签:
6条回答
  • 2020-12-20 14:15

    I have found the solution. The tutorial skips the step, where one has to add a dll to the "native build path". The dll is located in "opencv/build/java/x86" for 32-bit java i guess. although i dont know why this is the case. Would be nice, if someone could explain that.

    0 讨论(0)
  • 2020-12-20 14:16

    I had the same problem.

    It happened because I had a mistake with the 'Native library location' configuration:

    Goto Eclipse -> Window -> Preferences:

    Goto Eclipse -> Window -> Preferences

    Goto User Libraries:

    enter image description here

    Make sure that your native library location path is (change c:/opencv-2.4.9 to your own opencv folder):

    C:/opencv-2.4.9/build/java/x64
    

    and not:

    C:/opencv-2.4.9/build/x64
    

    (I missed the /java folder...)

    0 讨论(0)
  • 2020-12-20 14:20

    Change the code to System.loadLibrary("opencv_java244") hope you would set the native path to correct folder and opencv jar has set in build path

    0 讨论(0)
  • 2020-12-20 14:21

    For me, Eclipse > external jar > native library config = opencv/build/lib worked

    0 讨论(0)
  • 2020-12-20 14:26

    The OpenCV java library is correctly linked to your Eclipse project.

    The problem is the OpenCV native library which is not in the java.library.path. The exception is thrown by the line

    static{ System.loadLibrary("opencv_java244"); }
    

    which link the java library to the native one.

    When you install OpenCV on your computer, it will also install a native dll library somewhere on your system, and when you call the System.loadLibrary, you tell java to search and load this library.

    Your current problem is Java can not find this library in your System, either because the library is not in one of the java.library.path folders, or because you have not OpenCV installed (also take a look at the version, maybe you have not the 2.4.4 because the last is 2.4.5, in which case you will have to adapt the String).

    I just noticed that your exception is about "opencv-java2.4.4". Be sure to have the right spelling of the form "opencv_java244", in your System.loadLibrary call.

    I also redirect you to one of my answer, which is related to JavaCV, but that explain in more details what is going under.

    0 讨论(0)
  • 2020-12-20 14:35

    I found a solution. The actual dll is located in the openCV\opencv\build\java\x64\ folder. In my case, its name is opencv_java247.dll, so I have changed System.loadLibrary("opencv_java244") to System.loadLibrary("opencv_java247") in my java code. I also put the native library location as E:/Sagar_tools/tools/openCV/opencv/build/java/x64 (which is my full path to the dll).

    0 讨论(0)
提交回复
热议问题