Ask Your Question
0

Problem with building opencv_contrib. Cannot find file face.hpp.

asked 2017-01-05 14:02:56 -0600

Stfn gravatar image

I want to use FaceRecognizer class. As far as I know, it's not present in OpenCV 3.* versions, so I need to build opencv_contrib repository to be able to use it in my projects.

Unfortunately something went wrong, I've built it, but I still can't find face.hpp file in libraries folder. Here is what I've done to build it:

This is where I installed OpenCV and how it looks like: image description

This is where I've copied opecv_contrib and how it looks like on my drive: image description

This is how I configured cmake-gui it build new libraries: image description

When I try to include face.hpp in my code:

#include "opencv2/face.hpp"

I see: cannot open source file "opencv2/face.hpp" and identifier "FaceRecognizer" is undefined.

Am I doing something wrong?

edit retag flag offensive close merge delete

Comments

it works with #include "opencv2/face.hpp" or with #include <opencv2 face.hpp="">

Have you check that BUILD_opencv_face is checked ? and BUILD_opencv_objdetect is checked too ?

LBerger gravatar imageLBerger ( 2017-01-05 14:24:36 -0600 )edit

@LBerger If you are talking about options in cmake-gui, then: yes, they are all checked, but BUILD_opencv_face is highlighted in red. Does it mean something?

Stfn gravatar imageStfn ( 2017-01-05 14:32:50 -0600 )edit

Yes it is in CMake GUI. About red I don't know. Have you build opencv with samples? if yes check if facerec_demo.cpp samples is OK.

LBerger gravatar imageLBerger ( 2017-01-05 14:41:40 -0600 )edit

@LBerger no, it's not, because, like in my project, compiler can't find "opencv2/face.hpp"

Stfn gravatar imageStfn ( 2017-01-05 14:58:32 -0600 )edit

To build opencv you have to clone it from github

git clone https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv_contrib.git
LBerger gravatar imageLBerger ( 2017-01-05 15:02:44 -0600 )edit

Its simple, if something is red in cmake then it means something is wrong. You are lucky, for OpenCV 3 Blueprints we also used the face module, so we have a tutorial completely describing the configuration. Can you take a look there?

StevenPuttemans gravatar imageStevenPuttemans ( 2017-01-06 03:19:10 -0600 )edit

I'm not sure that if something is red something is wrong using CMake 3.7.1. When I leave cmake everything is white and when I reopen cmakelists everything is red

LBerger gravatar imageLBerger ( 2017-01-06 03:36:30 -0600 )edit

@StevenPuttemans: I've followed tutorial that you've linked. I deleted all opencv libs and I've built everything from scratch. Now, my Visual Studio doesn't seem to see any of opencv libraries. Not only face.hpp but all of them. As far as I know, all libraries should be present in include folder, they aren't https://monosnap.com/file/gzTOy8ec1Kj...

Stfn gravatar imageStfn ( 2017-01-06 07:10:39 -0600 )edit

BTW do I need to build it by myself? Why didn't opencv team built it and share it just like they did with "base" opencv here: http://opencv.org/downloads.html? I'm not a power user, I just want to use OpenCV in one of my projects.

Stfn gravatar imageStfn ( 2017-01-06 07:17:08 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2017-01-06 13:33:54 -0600

LBerger gravatar image

updated 2017-01-07 08:35:28 -0600

You have to :

  1. Download opencv 3.2 unzip it (in C:\Users\Laurent.PC-LAURENT-VISI\Downloads\ on my computer)
  2. git clone https://github.com/opencv/opencv_cont... ( in g:/lib on my computer)
  3. run cmake GUI. give opencv path in where is source file (C:\Users\Laurent.PC-LAURENT-VISI\Downloads\opencv/sources
  4. press configure
  5. if you use VS2015 disable cuda (in build (12 check box)and with_cuda and withcufft )
  6. give path to opencv_contrib/modules (where you clone it and don't forget modules g:/lib/opencv_contrib/modules)
  7. generate
  8. open project if you have vs and build solution (drink a coffee)

image description

Now build face sample in opencv_contrib

  1. run cmakeGUI
  2. where is the source code = G:/Lib/opencv_contrib/modules/face/samples
  3. where to build binaries = C:/Users/Laurent.PC-LAURENT-VISI/Downloads/opencv/sources/samples
  4. fill all field like this
  5. cmake cannot find opencv : give path C:\Users\Laurent.PC-LAURENT-VISI\Downloads\opencv\sources in cmake variables OpenCV_DIR

image description

build project and no errors...

edit flag offensive delete link more

Comments

By saying run cmake give opencv path you mean typing in console cmake [path_to_opecv_source_folder]? By saying if you use VS2015 disable cuda (in build and with cmake variables) running command from point 3 with -D WITH_CUDA=OFF at the end? By saying give path to opencv_contrib/modules you mean opening cmake-gui with the same configuration as on first screenshot (source code and build destination are the same folders), finding OPENCV_EXTRA_MODULES_PATH and adding there modules folder from opencv_contrib`?

Stfn gravatar imageStfn ( 2017-01-07 08:20:17 -0600 )edit

I'm asking, beacuse this is what I see https://monosnap.com/file/RIA0InYcVCA... , but maybe I didn't understood one of the points.

Stfn gravatar imageStfn ( 2017-01-07 08:21:35 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-01-05 14:02:56 -0600

Seen: 1,839 times

Last updated: Jan 07 '17