"Java.lang.UnsatisfiedLinkError: no opencv_java320 in java.library.path"
Please find below a working snippet. Which you need to adapt to your needs.
assume following file structure
libs\opencv_java320.dll
pom.xml
src\test\java\sub\optimal\OpenCVTest.java
pom.xml - the part for the testing
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<configuration>
<argLine>-Djava.library.path=${project.basedir}/libs/</argLine>
</configuration>
</plugin>
</plugins>
</build>
sub\optimal\OpenCVTest.java
package sub.optimal;
import org.junit.Test;
public class OpenCVTest {
@Test
public void someOpenCVTest() {
System.out.printf("java.library.path: %s%n",
System.getProperty("java.library.path"));
System.loadLibrary("opencv_java320");
}
}
run the test
mvn compile test
output
...
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running sub.optimal.OpenCVTest
java.library.path: X:\develop\opencv-demo/libs/
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: ...
...
This worked for me. I am using intellij on mac
import org.opencv.core.CvType;
import org.opencv.core.Mat;
public class Test {
public static void main(String[] args){
//System.loadLibrary(Core.NATIVE_LIBRARY_NAME); - REMOVE THIS
nu.pattern.OpenCV.loadShared(); //add this
Mat mat = Mat.eye(3, 3, CvType.CV_8UC1);
System.out.println("mat = " + mat.dump());
}
}
And dependency
<dependency>
<groupId>org.openpnp</groupId>
<artifactId>opencv</artifactId>
<version>3.2.0-0</version>
</dependency>
If you are using STS/Eclipse or any IDE then follow the steps to getting solve your unsatisfiedlinkerror-no-opencv-java320 error.
Window -> Preferences -> User Libraries -> New -> create new Library Like attached Image
Note:- Jar location and Native Library Location (opencv/build/java/x64) should be exactly like this while creating the new library.