问题
I'm writing this post to ask how I can use Face Recognizer in a JAVA project. I'm trying to generate with cmake the jar file of opencv3.0.0.0 with all its contribs, but the resulted generated jar contains only standard modules. I've also tried to use the 2.4.11 version but i can't realize how to make a concrete instance of the face recognizer class.
回答1:
The one part that is a bit tricky to find in any documentation is about editing the CMakeLists.txt for the contrib modules. It seems that is the only part you are missing, but I have included the full step-by-step process below for others.
- Download/clone opencv repository found here
- Download/clone opencv_contrib repository found here
- Go to opencv_contrib/modules/face and edit CMakeLists.txt
Find the line that begins with ocv_define_module and add "java" so that it looks something like this:
ocv_define_module(face opencv_core opencv_imgproc opencv_objdetect WRAP python java)
Compile opencv with contrib modules as normal, i.e. adding the appropriate parameters to cmake as follows:
cmake -D CMAKE_BUILD_TYPE=Release -D OPENCV_EXTRA_MODULES_PATH=<path to opencv_contrib>
The JAR built in the bin/ folder will now contain the org.opencv.face package
来源:https://stackoverflow.com/questions/34224468/opencv-3-0-0-face-recognizer-with-java