I'm following an older tutorial on face recognition based on OpenCV in C++ and have an error I can't resolve. The relevant code snippet:
#include "opencv2/core/core.hpp"
#include "opencv2/face.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/objdetect/objdetect.hpp"
...
Ptr<face::FaceRecognizer> model = face::createFisherFaceRecognizer();
model->train(images, labels);
...
I have my OpenCV compiled correctly with contrib modules, have them included but it still gives the error:
error: 'createFisherFaceRecognizer()' is not a member of 'cv::face'
I also trief this one:
Ptr<face::FaceRecognizer> model = face::FisherFaceRecognizer_create();
error: 'FisherFaceRecognizer_create()' is not a member of 'cv::face'
I looked up the face.hpp, ad the class has a function 'create', so I tried to use it, but this also failed:
Ptr<face::FaceRecognizer> model = face::FisherFaceRecognizer.create();
error: expected primary-expression before '.' token
which is weird since the function has parameters with default values. All the online solutions I treid failed. What was changed in the newer OpenCV versions and how can I create a face recognizer object correctly?
According to the official document,
Ptr<FaceRecognizer> createFisherFaceRecognizer(int num_components=0, double threshold=DBL_MAX)
is used openCV2. Since you use openCV 4, you have to follow the documentation that works with openCV 4.
Try this:
static Ptr<FisherFaceRecognizer> cv::face::FisherFaceRecognizer::create (int num_components = 0, double threshold = DBL_MAX )
On the top of this page, you can adjust the version of openCV library which you have.