Ask Your Question
1

How to build the Java wrapper for OpenCV 3.0?

asked 2015-07-17 19:12:57 -0600

smwikipedia gravatar image

updated 2015-07-18 09:20:54 -0600

I am using OpenCV 3.0 in my Java application through the opencv-300.jar and opencv_java300.dll. They come with the standard installation. But some extra modules are not in the standard installation. So I build an OpenCV 3.0 with the opencv-contrib repo.

But the build generates about 40 binaries. How can I generate something like opencv-300.jar and opencv_java300.dll for Java adoption? Do I need to turn to SWIG or something?

ADD 1

I see the following log in the cmake-gui generation process:

  Java:
    ant:                         C:/apache-ant-1.9.4/bin/ant.bat (ver
1.9.4)
    JNI:                         C:/Java/jdk1.6.0_45_32bit/include C:/Java/jdk1.6.0_45_32bit/include/win32 C:/Java/jdk1.6.0_45_32bit/include
    Java wrappers:               NO
    Java tests:                  NO

Could this be the reason?

The complete log is below:

found IPP (ICV version): 8.2.1 [8.2.1]
at: E:/Softwares/OpenCV/OpenCV3.0.0/opencv/sources/3rdparty/ippicv/unpack/ippicv_win
Could NOT find Doxygen (missing:  DOXYGEN_EXECUTABLE) 
To enable PlantUML support, set PLANTUML_JAR environment variable or pass -DPLANTUML_JAR=<filepath> option to cmake
Could NOT find PythonInterp: Found unsuitable version "1.4", but required is at least "2.7" (found C:/Python/Python27/python.exe)
Could NOT find PythonInterp: Found unsuitable version "1.4", but required is at least "2.6" (found C:/Python/Python27/python.exe)
Could NOT find PythonInterp: Found unsuitable version "1.4", but required is at least "3.4" (found C:/Python/Python27/python.exe)
Could NOT find PythonInterp: Found unsuitable version "1.4", but required is at least "3.2" (found C:/Python/Python27/python.exe)
Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true

Found apache ant 1.9.4: C:/apache-ant-1.9.4/bin/ant.bat
ERROR: 
The system was unable to find the specified registry key or value.

ERROR: 
The system was unable to find the specified registry key or value.

Could NOT find Matlab (missing:  MATLAB_MEX_SCRIPT MATLAB_INCLUDE_DIRS MATLAB_ROOT_DIR MATLAB_LIBRARIES MATLAB_LIBRARY_DIRS MATLAB_MEXEXT MATLAB_ARCH MATLAB_BIN) 
VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
Tesseract:   NO
  videoio: Removing WinRT API headers by default
Tesseract:   NO

General configuration for OpenCV 3.0.0 =====================================
  Version control:               unknown

  Platform:
    Host:                        Windows 6.1 AMD64
    CMake:                       3.1.3
    CMake generator:             Visual Studio 12 2013
    CMake build tool:            C:/Program Files (x86)/MSBuild/12.0/bin/MSBuild.exe
    MSVC:                        1800

  C/C++:
    Built as dynamic libs?:      NO
    C++ Compiler:                C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe  (ver 18.0.31101.0)
    C++ flags (Release):         /DWIN32 /D_WINDOWS /W4 /GR /EHa  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /arch:SSE2 /Oi /fp:fast  /wd4251 /wd4324 /MP4  /MT /O2 /Ob2 /D NDEBUG  /Zi
    C++ flags (Debug):           /DWIN32 /D_WINDOWS /W4 /GR /EHa  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /arch:SSE2 /Oi /fp:fast  /wd4251 /wd4324 /MP4  /D_DEBUG /MTd /Zi /Ob0 /Od /RTC1 
    C Compiler:                  C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin ...
(more)
edit retag flag offensive close merge delete

Comments

1

you can use cmake -DBUILD_SHARED_LIBS=OFF for a statically linked opencv_java300.dll

berak gravatar imageberak ( 2015-07-17 22:25:10 -0600 )edit

@berak Thanks for the hint. I re-configure the build process by unchecking the BUILD_SHARED_LIBS in cmake-gui, and rebuild the solution in visual studio 2013. But I didn't find a opencv_java300.dll generated. Could you provide more details?

smwikipedia gravatar imagesmwikipedia ( 2015-07-18 02:47:52 -0600 )edit
1

did you build the INSTALL project ? (it is not built by default)

also, please check the cmake output again carefully.

berak gravatar imageberak ( 2015-07-18 02:51:09 -0600 )edit

@berak I rebuild the INSTALL project. And totally 99 projects are successfully built. After build finished, I searched the build directory for opencv_java300.dll. But still no luck. I noticed there's something like opencv_ffmpeg300.dll. I recheck the configure entries in the cmake-gui, I see entries like WITH_FFMPEG. But I didn't see anything related to java. Could you shed some more light? Thx.

smwikipedia gravatar imagesmwikipedia ( 2015-07-18 05:18:14 -0600 )edit
1

you're safe to ignore the opencv_ffmpeg.dll for now. you will need that binary present (only if) you want to capture video-url-streams, it is unrelated to your problems with the java wrappers.

please add the cmake -output to your question , maybe we can find something in there.

berak gravatar imageberak ( 2015-07-18 05:24:27 -0600 )edit
1

@berak I added some log during generation.

smwikipedia gravatar imagesmwikipedia ( 2015-07-18 05:51:03 -0600 )edit

now, we're onto something ;) it obviously should say: Java wrappers: YES .

there must be something else, again, try to add the whole output (yes it is pretty long)

btw, did it generate a java dll for the dynamic libs at all ?

berak gravatar imageberak ( 2015-07-18 05:53:43 -0600 )edit
1

@berak Yes sir. Full log just added.. ;)

smwikipedia gravatar imagesmwikipedia ( 2015-07-18 05:54:43 -0600 )edit
1

^^ thanks ;)

so, here's the current culprit: you need a valid python interpreter to generate the java - wrapper code. it found 1.4, but iirc, 2.6+ is needed.

berak gravatar imageberak ( 2015-07-18 05:57:13 -0600 )edit

@berak Strange. the one it found C:/Python/Python27/python.exeis indeed python 2.7. And here's an related link: http://answers.opencv.org/question/41...

smwikipedia gravatar imagesmwikipedia ( 2015-07-18 06:38:22 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2018-03-18 04:16:20 -0600

Andrej Lucny gravatar image

Perhaps you have an old python in your cygwin which is preferred by OpenCV. Solution is easy: remove it out. cd .../cygwin.../bin del python. Than ensure you have an up-to-date python installed (python is used for generation of java wrapper, therefore it is needed even when you do not need opencv python bindings) and (on windows with developer tools it is very important) that default program for opening .py is python.exe (not e.g. WebMatrix). And it will work fine.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-07-17 19:12:57 -0600

Seen: 6,284 times

Last updated: Jul 18 '15