Ask Your Question

OpenCV 4.01 face module for Java

asked 2019-03-18 11:51:37 -0500

velicko91 gravatar image

updated 2019-03-20 10:12:00 -0500

Hello, I am trying to build OpenCV from source to .jar, since I need face module. I followed this tutorial

Installed ant,Cmake and MinGW, setted Cmake configurations and this is my Cmake log:


Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE) (Required is at least version "3.2")
AVX_512F is not supported by C++ compiler
AVX512_SKX is not supported by C++ compiler
Dispatch optimization AVX512_SKX is not available, skipped
libjpeg-turbo: VERSION = 1.5.3, BUILD = opencv-4.0.1-libjpeg-turbo
Could not find OpenBLAS include. Turning OpenBLAS_FOUND off
Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
Could NOT find BLAS (missing: BLAS_LIBRARIES) 
LAPACK requires BLAS
A library with LAPACK API not found. Please specify library location.
Found apache ant: D:/programi/apache-ant-1.10.5/bin/ant.bat (1.10.5)
VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
OpenCV Python: during development append to PYTHONPATH: D:/programi/opencv/buildSimple/python_loader
Caffe:   NO
Protobuf:   NO
Glog:   NO
freetype2:   NO
harfbuzz:    NO
Module opencv_ovis disabled because OGRE3D was not found
No preference for use of exported gflags CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported gflags CMake configuration if available.
Failed to find installed gflags CMake configuration, searching for gflags build directories exported with CMake.
Failed to find gflags - Failed to find an installed/exported CMake configuration for gflags, will perform search for installed gflags components.
Failed to find gflags - Could not find gflags include directory, set GFLAGS_INCLUDE_DIR to directory containing gflags/gflags.h
Failed to find glog - Could not find glog include directory, set GLOG_INCLUDE_DIR to directory containing glog/logging.h
Module opencv_sfm disabled because the following dependencies are not found: Eigen Glog/Gflags
Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.avx512_skx.cpp

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

  Extra modules:
    Location (extra):            D:/programi/opencv/opencv_contrib-4.0.1/modules
    Version control (extra):     unknown

    Timestamp:                   2019-03-17T17:41:53Z
    Host:                        Windows 10.0.17134 AMD64
    CMake:                       3.14.0
    CMake generator:             MinGW Makefiles
    CMake build tool:            D:/programi/minGW/mingw64/bin/mingw32-make.exe
    Configuration:               Release

  CPU/HW features:
    Baseline:                    SSE SSE2 SSE3
      requested:                 SSE3
    Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2
      requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
      SSE4_1 (5 files):          + SSSE3 SSE4_1
      SSE4_2 (1 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
      FP16 (0 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
      AVX (4 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
      AVX2 (11 files):           + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2

    Built as dynamic libs?:      NO
    C++ Compiler:                D:/programi/minGW/mingw64/bin/g++.exe  (ver 8.1.0)
    C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
    C++ flags (Debug):           -fsigned-char -W ...
edit retag flag offensive close merge delete


can you try to ask a real question here ? (a link to another one is not enough to be useful here)

berak gravatar imageberak ( 2019-03-18 14:41:53 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2019-03-19 01:43:29 -0500

berak gravatar image

updated 2019-03-19 03:01:07 -0500

So when i search for opencv_java401.dll lib, there exist only libopencv_java401.dll.

that's a bug (in the mingw toolchain) , you have to rename it manually back to opencv_java401.dll

and you should also have a opencv/buildSimple/install/java folder with the jar in it

sidenote: i'm not sure, if mingw can REALLY compile your CPU_BASELINE (you probably should have left it "empty" instead. it all compiles and links, but if you get really weird c++ errors later, consider going back and clear those options (and rebuild, ofc.)

edit flag offensive delete link more


Ok I tried renamnng libopencv_java401.dll to opencv_java401.dll and still getting exception Caused by: java.lang.UnsatisfiedLinkError: D:\programi\opencv\buildSimple\lib\opencv_java401.dll: Can't find dependent libraries, even thou that dll exists in this path.

I don't have opencv/buildSimple/install/ folder at all.

Thanks for fast response.

velicko91 gravatar imagevelicko91 ( 2019-03-19 03:33:53 -0500 )edit

Can't find dependent libraries

since you built dynamic opencv libs, opencv_java.dll depends on opencv_core.dll, opencv_imgproc.dll, etc.

you have to append the folder containing those to your system's PATH

berak gravatar imageberak ( 2019-03-20 10:33:33 -0500 )edit

It works, thanks :D

velicko91 gravatar imagevelicko91 ( 2019-03-20 16:23:16 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2019-03-18 11:51:37 -0500

Seen: 81 times

Last updated: Mar 20