Abbyss
Abbyss

Reputation: 155

Open cv 3.0.0 FaceRecognizer class cannot be resolved while compiling in Linux (Ubuntu)

In Open Cv 3.0.0 FaceRecognizer class cannot be resolved while compiling in Linux (Ubuntu). This used to work in 2.4.11 version and the class was present in the contrib module. Looks like the contrib module is missing in the Open cv 3.0.0 version.

Upvotes: 0

Views: 691

Answers (1)

Abbyss
Abbyss

Reputation: 155

The contrib module by default doesn't come with the installation of open cv 3.0.0

The contrib module has to be separately installed. Please follow the instructions below to get rid of the compilation issue with FaceRecognizer class.

  1. First, go to your build directory in open cv. This could be named as build or release when you have installed the open cv 3.0.0 version.
  2. There you can run the following command to install the contrib module

cmake -DOPENCV_EXTRA_MODULES_PATH=opencv_contrib/modules opencv_source_directory

  1. In the above command, opencv_contrib is the opencv contrib module directory path that you have downloaded from the github link [https://github.com/Itseez/opencv_contrib/tree/3.0.0-rc1][1]. opencv_source_directory is the source directory of the opencv, which would be typically the open cv root folder where you extracted or downloaded it, this would be ../ if you have followed open cv tutorial instructions for installing and creating the release or build folder

  2. I used RC1 tag of open cv 3.0.0 from github, you can use tag of your choice.

  3. Now run the following two commands

make -j $(nproc)

sudo make install

  1. After this, in the code (.cpp or .hpp file) where you are referring to the FaceRecognizer class, put the following namespaces near the #includes

using namespace cv; using namespace face;

  1. Alternatively you can also refer to the class with namespace prefix, as in, if you are referring to FaceRecognizer as cv::FaceRecognizer, now refer to it as cv::face::FaceRecognizer. It's just a coding style. Use either point 6 or 7 style, not both.

Now you shouldn't see any compilation issue.

Upvotes: 1

Related Questions