1

I am trying to make a facerecognizer in C++ using openCV. But keep getting the following errors:

1) cv::face::createFisherFaceRecognizer(int, double), but this gives:

main.cpp:(.text+0x6a8): undefined reference to`cv::face::createFisherFaceRecognizer(int, double)'

2)face::FisherFaceRecognizer::create(), but this gives:

 error: ‘cv::face::FisherFaceRecognizer’ has not been declared

None of those work, what is the correct way so I can run my code (none of those commented lines worked...)?

I even reinstalled everything, because no one could help me out. This is the current situation:

General configuration for OpenCV 3.2.0 =====================================
  Version control:               unknown

  Extra modules:
    Location (extra):            /home/yalishanda/Downloads/opencv_contrib-3.2.0/modules
    Version control (extra):     unknown

  Platform:
    Timestamp:                   2017-07-04T08:29:50Z
    Host:                        Linux 4.8.0-36-generic x86_64
    CMake:                       3.5.1
    CMake generator:             Unix Makefiles
    CMake build tool:            /usr/bin/make
    Configuration:               Release

  C/C++:
    Built as dynamic libs?:      YES
    C++ Compiler:                /usr/bin/c++  (ver 5.4.0)
    C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
    C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
    C Compiler:                  /usr/bin/cc
    C flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUG
    C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
    Linker flags (Release):
    Linker flags (Debug):
    ccache:                      NO
    Precompiled headers:         YES
    Extra dependencies:          /usr/lib/x86_64-linux-gnu/libpng.so /usr/lib/x86_64-linux-gnu/libz.so gtk-x11-2.0 gdk-x11-2.0 pangocairo-1.0 atk-1.0 cairo gdk_pixbuf-2.0 gio-2.0 pangoft2-1.0 pango-1.0 gobject-2.0 fontconfig freetype gthread-2.0 glib-2.0 dl m pthread rt
    3rdparty dependencies:       libjpeg libwebp libtiff libjasper IlmImf libprotobuf

  OpenCV modules:
    To be built:                 core flann imgproc ml photo reg surface_matching video dnn freetype fuzzy imgcodecs shape videoio highgui objdetect plot superres ts xobjdetect xphoto bgsegm bioinspired dpm face features2d line_descriptor saliency text calib3d ccalib datasets rgbd stereo tracking videostab xfeatures2d ximgproc aruco optflow phase_unwrapping stitching structured_light
    Disabled:                    world contrib_world
    Disabled by dependency:      -
    Unavailable:                 cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java python2 python3 viz cnn_3dobj cvv hdf matlab sfm

  GUI: 
    QT:                          NO
    GTK+ 2.x:                    YES (ver 2.24.30)
    GThread :                    YES (ver 2.48.2)
    GtkGlExt:                    NO
    OpenGL support:              NO
    VTK support:                 NO

  Media I/O: 
    ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.8)
    JPEG:                        libjpeg (ver 90)
    WEBP:                        build (ver 0.3.1)
    PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.2.54)
    TIFF:                        build (ver 42 - 4.0.2)
    JPEG 2000:                   build (ver 1.900.1)
    OpenEXR:                     build (ver 1.7.1)
    GDAL:                        NO
    GDCM:                        NO

  Video I/O:
    DC1394 1.x:                  NO
    DC1394 2.x:                  NO
    FFMPEG:                      NO
      avcodec:                   NO
      avformat:                  NO
      avutil:                    NO
      swscale:                   NO
      avresample:                NO
    GStreamer:                   NO
    OpenNI:                      NO
    OpenNI PrimeSensor Modules:  NO
    OpenNI2:                     NO
    PvAPI:                       NO
    GigEVisionSDK:               NO
    Aravis SDK:                  NO
    UniCap:                      NO
    UniCap ucil:                 NO
    V4L/V4L2:                    NO/YES
    XIMEA:                       NO
    Xine:                        NO
    gPhoto2:                     NO

  Parallel framework:            pthreads

  Other third-party libraries:
    Use IPP:                     9.0.1 [9.0.1]
         at:                     /home/yalishanda/Downloads/opencv-3.2.0/build/3rdparty/ippicv/ippicv_lnx
    Use IPP Async:               NO
    Use VA:                      NO
    Use Intel VA-API/OpenCL:     NO
    Use Lapack:                  NO
    Use Eigen:                   NO
    Use Cuda:                    NO
    Use OpenCL:                  YES
    Use OpenVX:                  NO
    Use custom HAL:              NO

  OpenCL:                        <Dynamic loading of OpenCL library>
    Include path:                /home/yalishanda/Downloads/opencv-3.2.0/3rdparty/include/opencl/1.2
    Use AMDFFT:                  NO
    Use AMDBLAS:                 NO

  Python 2:
    Interpreter:                 /usr/bin/python2.7 (ver 2.7.12)

  Python 3:
    Interpreter:                 /usr/bin/python3 (ver 3.5.2)

  Python (for build):            /usr/bin/python2.7

  Java:
    ant:                         NO
    JNI:                         NO
    Java wrappers:               NO
    Java tests:                  NO

  Matlab:                        Matlab not found or implicitly disabled

  Documentation:
    Doxygen:                     NO

  Tests and samples:
    Tests:                       YES
    Performance tests:           YES
    C/C++ Examples:              NO

  Install path:                  /usr/local

  cvconfig.h is in:              /home/yalishanda/Downloads/opencv-3.2.0/build
-----------------------------------------------------------------

This is the command with which I compile: (https://pastebin.com/raw/1EB7jXZd)

g++ src/faceDetection.cpp src/faceRecognition.cpp main.cpp -L/usr/local/lib -lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dpm -lopencv_fuzzy -lopencv_line_descriptor -lopencv_optflow -lopencv_reg -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_rgbd -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_face -lopencv_plot -lopencv_dnn -lopencv_xfeatures2d -lopencv_shape -lopencv_video -lopencv_ximgproc -lopencv_calib3d -lopencv_features2d -lopencv_flann -lopencv_xobjdetect -lopencv_objdetect -lopencv_ml -lopencv_xphoto -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_photo -lopencv_imgproc -lopencv_core -o main

sort of speaking already linking almost every library that exists in openCV.... What else can I add?

  • Which version of OpenCV? You refer to docs for 2.4.x, but I have a suspicion you're using 3.x. – Dan Mašek Jul 02 '17 at 21:35
  • @DanMašek indeed was looking at the incorrect docs. But still if I follow the 3.1 docs I get exactly the same error... What do you suggest? – LandonZeKepitelOfGreytBritn Jul 02 '17 at 21:57
  • I suspect those docs weren't kept up to date. Looking at the source code, I think [this](https://github.com/opencv/opencv_contrib/blob/master/modules/face/include/opencv2/face/facerec.hpp#L122) is what you want. – Dan Mašek Jul 03 '17 at 02:59
  • @DanMašek same problem, the link uses functions that don't work neither. – LandonZeKepitelOfGreytBritn Jul 03 '17 at 08:35
  • @DanMašek any other suggestions? Hence I updated my main post. – LandonZeKepitelOfGreytBritn Jul 03 '17 at 19:56
  • Right, [I see](https://github.com/opencv/opencv_contrib/blob/3.1.0/modules/face/include/opencv2/face/facerec.hpp#L99), it has changed again since the version you're using. #1 looks half-way there, I guess you forgot to link with the contrib library? – Dan Mašek Jul 03 '17 at 20:00
  • @DanMašek This is the compile command I use, what do you suggest to add? https://pastebin.com/scQK8YV2 – LandonZeKepitelOfGreytBritn Jul 03 '17 at 20:04
  • @DanMašek I read somewhere online that there is no need to include (or however it s called). They seem to have moved their stuff to face.hpp – LandonZeKepitelOfGreytBritn Jul 03 '17 at 20:05
  • Well, at this point it compiles, so the headers seem OK. The problem is now in linking, however you do seem to mention the right lib, so I'm honestly at the end of my wits here... How exactly did you install the contrib library? What exact version is it? – Dan Mašek Jul 03 '17 at 23:12
  • @DanMašek I installed it immediately together with openCV like described in the readme (https://github.com/opencv/opencv_contrib). installation info: https://pastebin.com/sc0fVaAT – LandonZeKepitelOfGreytBritn Jul 04 '17 at 07:46
  • Possible duplicate of [How to fix undefined reference/unresolved external symbol error](https://stackoverflow.com/questions/12573816/how-to-fix-undefined-reference-unresolved-external-symbol-error) – autistic Jan 17 '18 at 22:38

1 Answers1

0

createFisherFaceRecognizer() must be declared before being used. Most likely you are missing an header file (.h). I couldn't understand from the doc which one is it. You must find which one declares this function.

user6106573
  • 193
  • 2
  • 11