9

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?

be_good_do_good
  • 4,311
  • 3
  • 28
  • 42

3 Answers3

9

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
berak
  • 39,159
  • 9
  • 91
  • 89
  • Thanks for your reply..I tried to build opencv_contrib using cmake gui, but i couldnt find any cmake lists in the repository. cmake lists were found in individual modules inside the repository. But building individual modules throws error. how to resolve the problem ? – Jayendhar Gautham Feb 04 '15 at 14:28
  • 1
    you add the opencv_contrib module to you cmake int the *main* opencv dir `-DOPENCV_EXTRA_MODULES_PATH=/modules` and re-build the *main* opencv repo, not seperated. – berak Feb 04 '15 at 14:49
  • Thanks..How to add this path in cmake-GUI "DOPENCV_EXTRA_MODULES_PATH".? – balajichinna Feb 04 '15 at 15:08
  • click 'grouped', -> opencv ->OPENCV_EXTRA_MODULES_PATH – berak Feb 04 '15 at 15:11
  • Or just search for "OPENCV_EXTRA_MODULES_PATH" and CMke-gui will find it for you :) – cyriel Feb 05 '15 at 01:59
  • Thanks. I successfully build extra contrib module in MAC OSX. But i am trying to build in Windows. I got error after "Generate". For example >mingw32-make-exe – balajichinna Feb 05 '15 at 06:43
  • @balajichinna with mingw, you will have to specify the path to the compiler and make tool explicitly, and that's btw not related to above question. – berak Feb 05 '15 at 08:00
  • Ok...Could you tell simple steps for build using Mingw.? – balajichinna Feb 05 '15 at 08:44
  • @balajichinna, pleas ask a *new* question for that. – berak Feb 05 '15 at 08:49
  • I've compiled opencv_contrib as in the instruction, but still can't find any contrib.hpp. – nafsaka Jan 19 '16 at 07:35
0

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.

abhiarora
  • 9,743
  • 5
  • 32
  • 57
Mahyar
  • 1
  • 2
0

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();
Vorac
  • 8,726
  • 11
  • 58
  • 101