Error compiling face extra module

Hi, I’m Marcos, a student who is doing a university project using Visual Studio 2019 with c++ and your library (version 4.5.2). This is my first time using libraries, so I’ll try to describe my error as much accurate as I can. The project is about face recognition, so I’m trying the library with the example in the documentation:

tutorial_face_main
I’m trying to use the first code, the one with EigenFaces.

For the installation, I downloaded the opencv-4.5.2-vc14-vc15.exe from:

https://github.com/opencv/opencv/releases/tag/4.5.2

And then, linked it with Visual Studio in three steps:

  1. In (Settings-> C+±> General-> Additional include directories) added C:\opencv\build\include.
  2. In (Settings-> Linker-> General-> Additional library directories) added C:\opencv\build\x64\vc15\lib.
  3. In (Settings-> Linker-> Input) added opencv_world452.lib and opencv_world452d.lib.
  4. In (Compilation events-> Post-compilation events) added the commad XCOPY “C:\opencv\build\x64\vc15\bin*.dll” “$(TargetDir)” /D /K /Y, so the .dll could go to the .exe directory.

As I have to use the opencv/face.hpp, I downloaded the extra modules from:

https://github.com/opencv/opencv_contrib/releases/tag/4.5.2
And I copied the …opencv_contrib-4.5.2\modules\face\include\opencv2 archieves into C:\opencv\build\include\opencv2.

At this moment, I can use the functions in the face files with autocomplete functionality and there are no red underlined parts. The problem is that when I compile the project, there are a lot of LNK2019 errors arising from the line 125.

Ptr<EigenFaceRecognizer> model = EigenFaceRecognizer::create();


There is a screenshot.

I think the problem is about the face module, which maybe is not installed properly, because when I compile the code commenting the last section (from line 125 untill the end), there are no errors. but I looked for possible answers in forums and I didn’t get an useful answer.

Hi,
face module is in opencv_contrib.
Did you build opencv with opencv_contrib using cmake? it seems not(download opencv_contrib is not enough)
instructions are here

your IDE is fooling you, it does not work like this

you have to download the opencv_contrib repo and rebuild it all from src, before you can use the code.

It was that! It has been tough because i didn’t know how cmake works, but now I got it. I thought it wasn’t necessary do this as it wasn’t neccesary for the non-extra modules. Of course I was wrong! Thanks!

1 Like

It was that! Thanks a lot!