Java OpenCV from Maven

Is there any way to get OpenCV from repository? Which artifact should I add to pom.xml? Every tutorial I'd found is from '14 and it seems like something changed - they say it is'nt in official Maven repository yet, but I've found entry:

<!-- https://mvnrepository.com/artifact/nu.pattern/opencv -->
<dependency>
   <groupId>nu.pattern</groupId>
   <artifactId>opencv</artifactId>
   <version>2.4.9-7</version>
</dependency>

Sadly, I get error

Caused by: java.lang.UnsatisfiedLinkError: no opencv_java249 in java.library.path

when I'm using System.loadLibrary(Core.NATIVE_LIBRARY_NAME). Can I add this library in a way that would make my project include it and 'forget' about manually adding it to classpath?


Solution 1:

Add the following dependency in your POM file:

<dependency>
    <groupId>org.openpnp</groupId>
    <artifactId>opencv</artifactId>
    <version>3.2.0-0</version>
</dependency>

and replace the following lines:

System.loadLibrary(Core.NATIVE_LIBRARY_NAME)

with

nu.pattern.OpenCV.loadShared();

This should solve the problem in WINDOWS also. Happy Coding.

Solution 2:

This worked for me.

nu.pattern.OpenCV.loadLibrary();

I'm using following maven dependency

<dependency>
  <groupId>nu.pattern</groupId>
  <artifactId>opencv</artifactId>
  <version>2.4.9-4</version>
</dependency>