To work with opencv you need a jar file and a binary file. The JAR file can simply be added by the local maven repository or by any other option.
Binary file to be added and downloaded manually. Something like that:
private static void addLibraryPath(String pathToAdd) throws Exception{ final Field usrPathsField = ClassLoader.class.getDeclaredField("usr_paths"); usrPathsField.setAccessible(true); //get array of paths final String[] paths = (String[])usrPathsField.get(null); //check if the path to add is already present for(String path : paths) { if(path.equals(pathToAdd)) { return; } } //add the new path final String[] newPaths = Arrays.copyOf(paths, paths.length + 1); newPaths[newPaths.length-1] = pathToAdd; usrPathsField.set(null, newPaths); } public void init() { String pathToOpenCvDll = "c:\\opencv\\"; //linux path works too try { addLibraryPath(pathToOpenCvDll); System.loadLibrary("opencv_java320"); } catch (Exception ignored) { } } }
Okapist
source share