contrib module missing in opencv 3.0?

大憨熊 提交于 2020-01-13 08:33:13

问题


I am using OpenCV 3.0 beta.

I tried to create a face recogniser using createLBPHFaceRecognizer(); class as,

   **Ptr <FaceRecognizer> model =  createLBPHFaceRecognizer();**

the error I have is

   **error: 'createLBPHFaceRecognizer' was not declared in this scope**

I have researched and found that the class exists in contrib module of opencv2 (opencv2/contrib/contrib.hpp) in previous versions of OpenCV

But this module is not available in opencv 3.0 beta. So where are the recogniser classes defined in opencv 3.0?

If they are not defined,how can we add this module in addition to the existing modules?


回答1:


you will have to download and build the opencv_contrib repo.

after running cmake, make, make install,

#include <opencv2/face.hpp>

// note the additional namespace:    
cv::Ptr <cv::face::FaceRecognizer> model = cv::face::createLBPHFaceRecognizer();
// proceed as usual



回答2:


from https://github.com/opencv/opencv_contrib:

  1. Start cmake-gui
  2. Select the opencv source code folder and the folder where binaries will be built (the 2 upper forms of the interface)
  3. Press the configure button. you will see all the opencv build parameters in the central interface
  4. Browse the parameters and look for the form called OPENCV_EXTRA_MODULES_PATH (use the search form to focus rapidly on it)
  5. Complete this OPENCV_EXTRA_MODULES_PATH by the proper pathname to the /modules value using its browse button.
  6. Press the configure button followed by the generate button (the first time, you will be asked which makefile style to use)
  7. Build the opencv core with the method you chose (make and make install if you chose Unix makfile at step 6)

To run, linker flags to contrib modules will need to be added to use them in your code/IDE. For example to use the aruco module, "-lopencv_aruco" flag will be added.




回答3:


On my Debian installation

$ dpkg -l libopencv-contrib-dev
ii  libopencv-contrib-dev:amd64 3.2.0+dfsg-6 amd64        development files for libopencv-contrib3.2

enables me to use contributed modules with just an additional include. For example:

#include <opencv2/opencv.hpp>
#include <opencv2/face.hpp>
auto model = cv::face::createLBPHFaceRecognizer();


来源:https://stackoverflow.com/questions/28323077/contrib-module-missing-in-opencv-3-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!