How to build the Java wrapper for OpenCV 3.0?
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 ...
you can use
cmake -DBUILD_SHARED_LIBS=OFF
for a statically linked opencv_java300.dll@berak Thanks for the hint. I re-configure the build process by unchecking the
BUILD_SHARED_LIBS
incmake-gui
, and rebuild the solution in visual studio 2013. But I didn't find aopencv_java300.dll
generated. Could you provide more details?did you build the INSTALL project ? (it is not built by default)
also, please check the cmake output again carefully.
@berak I rebuild the
INSTALL
project. And totally99
projects are successfully built. After build finished, I searched the build directory foropencv_java300.dll
. But still no luck. I noticed there's something likeopencv_ffmpeg300.dll
. I recheck the configure entries in thecmake-gui
, I see entries likeWITH_FFMPEG
. But I didn't see anything related tojava
. Could you shed some more light? Thx.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 I added some log during generation.
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 Yes sir. Full log just added.. ;)
^^ 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 Strange. the one it found
C:/Python/Python27/python.exe
is indeed python 2.7. And here's an related link: http://answers.opencv.org/question/41...