Java | Get OpenCV working on other PC

asked 2016-06-23 15:09:30 -0600

Tech gravatar image

Hey Programmers!

GENERAL:

Im programming a face detection Programm with OpenCV and I want to get it working on other Computers without a OpenCV install. So my installer (Java) must install all requirements to get the program working. My Programm is for Mac OS X, Linux and Windows.

WHAT I ALREADY TRIED:

I tried to compile it on my first Mac, then I copied to my second mac, but I always get Errors, because there are absolute paths (i think) that are pointing to my Desktop (Where i compiled the Library on my first mac). I asked my teacher if it is possible to rewrite these absolute paths to relative paths, but he said that it is not possible. Another idea is to download and compile the opencv-library inside the installer. But I have no idea to do that. Now im here :)

CODE: (Nice Formatting xD)

public static void loadOpenCVLibrary() {
    //all opencv libs must be copyed to OpenCV_lib in the project workspace

    File folder = new File(directory+seperator+"System"+seperator+"OpenCV_Linux"+seperator+"build"+seperator+"lib"+seperator);
    //File folder = new File("/Users/Tech/Documents/Development/workspace/opencv-3.0.0/bin/");
    File[] listOfFiles = folder.listFiles(); 

for (int i = 0; i < listOfFiles.length; i++) {
    if (listOfFiles[i].isFile() && listOfFiles[i].getName().endsWith(".dylib")) {
        File lib = new File(directory+seperator+"System"+seperator+"OpenCV_Linux"+seperator+"build"+seperator+"lib"+seperator + listOfFiles[i].getName());
        //File lib = new File("/Users/Tech/Documents/Development/workspace/opencv-3.0.0/bin/" + listOfFiles[i].getName());
        System.load(lib.getAbsoluteFile().toString());
    }
}}

If you need more infos, send a message :)

Thank you very MUCH! Tech

edit retag flag offensive close merge delete

Comments

not an answer, just some remarks:

  • you only need to load opencv_java300.so
  • you should build the java wrappers statically with cmake -DBUILD_SHARED_LIBS=OFF so your java wrapper is "self-contained" (does not erly on other opencv so's at runtime.
  • as long as you're using System.load (as opposed to System.loadLibrary , - yes, you're bound to an absolute path there.
berak gravatar imageberak ( 2016-06-24 03:07:01 -0600 )edit

UPDATE: I still dont have an answer. I need help! :P

Tech gravatar imageTech ( 2016-07-01 10:46:24 -0600 )edit

From what I know. There are DLL files needed to include together with your jar file. It's inside your build folder for opencv for this to be able to run on windows.

Cheqrd gravatar imageCheqrd ( 2016-08-11 22:53:15 -0600 )edit