Ask Your Question
1

Build Java wrappers OpenCV 3.3.0 with contrib

asked 2017-08-08 12:30:56 -0600

phillity gravatar image

updated 2017-11-12 18:28:23 -0600

Can someone point me to a guide to build Java wrappers OpenCV 3.3.0 (or 3.2.0) with contrib modules? I am using Windows 10. I have run into several problems trying to follow online guides :( If someone knows of a good guide to accomplish the build, I would be very grateful if you shared it with meeee

EDIT: I ended up being able to build 3.2.0 but now have run into another problem.

After the build, I received a opencv_java320.jar and a libopencv_java320.dll (and a opencv_ffmpeg320.dll). I am trying to use Eclipse. I made a new User Library pointing to the opencv_java320.jar. I am unsure where the Native Library Location should point to. It seems that it should be pointing to a opencv_java320.dll file, but I got no such file from my build. I have no jars or dlls other than opencv_java320.jar and a libopencv_java320.dll (and a opencv_ffmpeg320.dll). Is there some way to resolve this issue or was my build unsuccessful?

edit retag flag offensive close merge delete

Comments

2

did you already run cmake? show us cmake's generating output

sturkmen gravatar imagesturkmen ( 2017-08-08 14:39:45 -0600 )edit
1

cmake output looks OK. i can't say anything about MinGW because i used MS Visual Studio to compile. i recommend you to use MS Visual Studio

sturkmen gravatar imagesturkmen ( 2017-08-09 13:11:08 -0600 )edit
1

"After the build, I received a opencv_java320.jar and a libopencv_java320.dll" try to rename libopencv_java320.dll -> opencv_java320.dll

sturkmen gravatar imagesturkmen ( 2017-08-09 18:19:08 -0600 )edit

After renaming I can successfully System.loadLibrary(Core.NATIVE_LIBRARY_NAME), but then I receive an unsatisfied link error on the first line of code using OpenCV: Exception in thread "main" java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_Mat()J

phillity gravatar imagephillity ( 2017-08-09 18:29:18 -0600 )edit

try the files someone shared https://github.com/cesardelgadof/Open...

sturkmen gravatar imagesturkmen ( 2017-08-09 18:38:12 -0600 )edit

show your java code also

sturkmen gravatar imagesturkmen ( 2017-08-09 18:42:24 -0600 )edit

try

import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
public class Hello
{
   public static void main( String[] args )
   {
      System.loadLibrary( Core.NATIVE_LIBRARY_NAME );
      Mat mat = Mat.eye( 3, 3, CvType.CV_8UC1 );
      System.out.println( "mat = " + mat.dump() );
   }
}
sturkmen gravatar imagesturkmen ( 2017-08-09 18:56:07 -0600 )edit

I was using a 32 bit jdk so I changed to a 64 bit one, now I am getting:

Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\OpenCV-
3.2.0\build\install\java\opencv_java320.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at BIFtest.main(BIFtest.java:167)
ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183):  [util.c:840]
phillity gravatar imagephillity ( 2017-08-09 18:56:37 -0600 )edit

sorry, maybe i disguided you. again i say. if you use MS Visual Studio probably you will solve all problems.

sturkmen gravatar imagesturkmen ( 2017-08-09 19:00:18 -0600 )edit

otherwise you can download compiled dlls from https://github.com/cesardelgadof/Open...

sturkmen gravatar imagesturkmen ( 2017-08-09 19:01:55 -0600 )edit

0 answers

Sort by ยป oldest newest most voted
1

answered 2017-11-12 18:28:10 -0600

phillity gravatar image

Hello everyone! I had to take some time off OpenCV, but, after returning, I was able to successfully build OpenCV 3.3.1 with contrib for Java!! Big thanks to sturkmen!!! As sturkmen suggested, Visual Studio was able to resolve my issues.

If you are trying to build OpenCV with contrib for Java I suggest:

First following this guide but disregard the MinGW section/steps: https://zami0xzami.wordpress.com/2016...

Then use visual studio and follow the steps outlined here: http://pythonopencv.com/step-by-step-...

Good luck Java friends!

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-08-08 12:30:56 -0600

Seen: 3,684 times

Last updated: Nov 12 '17