error in facec

asked 2015-02-18 04:55:54 -0600

Deepak Kumar gravatar image

updated 2015-02-18 08:49:28 -0600

thdrksdfthmn gravatar image

hi , i am getting error in facerecognizer in opencv 2.4.10. what should i do.

below is code :

Ptr<FaceRecognizer> learnCollectedFaces(const vector<Mat> preprocessedFaces, const vector<int> faceLabels, const string facerecAlgorithm)
{

    Ptr<FaceRecognizer> model;

    cout << "Learning the collected faces using the [" << facerecAlgorithm << "] algorithm ..." << endl;

    // Make sure the "contrib" module is dynamically loaded at runtime.
    // Requires OpenCV v2.4.1 or later (from June 2012), otherwise the FaceRecognizer will not compile or run!
    bool haveContribModule = initModule_contrib();
    if (!haveContribModule) {
        cerr << "ERROR: The 'contrib' module is needed for FaceRecognizer but has not been loaded into OpenCV!" << endl;
        exit(1);
    }

    // Use the new FaceRecognizer class in OpenCV's "contrib" module:
    // Requires OpenCV v2.4.1 or later (from June 2012), otherwise the FaceRecognizer will not compile or run!
    model = Algorithm::create<FaceRecognizer>(facerecAlgorithm);
    if (model.empty()) {
        cerr << "ERROR: The FaceRecognizer algorithm [" << facerecAlgorithm << "] is not available in your version of OpenCV. Please update to OpenCV v2.4.1 or newer." << endl;
        exit(1);
    }

    // Do the actual training from the collected faces. Might take several seconds or minutes depending on input!
    model->train(preprocessedFaces, faceLabels);

    return model;
}

error :

![image description](/upfiles/1424256649300074.png)
edit retag flag offensive close merge delete

Comments

first make sure, you 'really' link to opencv_contrib2410.lib.

then, you probably should avoid the Algorithm::create functionality anyway. it's no more supported in opencv3.0, and the day you'll have to adapt to that is close.

rather skip the initModule_contrib() function, and build your own factory similar to:

if (facerecAlgorithm =="Eigenfaces") model = cv::createEigenFaceRecognizer();
if (facerecAlgorithm =="Fisherfaces") model = cv::createFisherFaceRecognizer();
if (facerecAlgorithm =="LBPH") model = cv::createLBPHFaceRecognizer();
berak gravatar imageberak ( 2015-02-18 05:14:40 -0600 )edit

still getting the same error

Deepak Kumar gravatar imageDeepak Kumar ( 2015-02-18 05:26:11 -0600 )edit

now this is my code :

if (facerecAlgorithm == "Eigenfaces") 
    model = cv::createEigenFaceRecognizer();

model->train(preprocessedFaces, faceLabels);
Deepak Kumar gravatar imageDeepak Kumar ( 2015-02-18 05:27:04 -0600 )edit

why i am getting the same error. i have included

#include <opencv2/opencv.hpp>
#include "opencv2/core/core.hpp"
#include "opencv2/contrib/contrib.hpp"
#include "opencv2/highgui/highgui.hpp"

these header files

Deepak Kumar gravatar imageDeepak Kumar ( 2015-02-18 05:27:51 -0600 )edit
1

now repeat 5 times LINKER LINKER LINKER LINKER LINKER

berak gravatar imageberak ( 2015-02-18 05:29:56 -0600 )edit

how should i do it. i didn't get it.

Deepak Kumar gravatar imageDeepak Kumar ( 2015-02-18 05:33:52 -0600 )edit

ok, (and sorry for pulling your leg).

this is a linker error, not a compiler one, nothing to do with c++ headers above

you have to make sure, that opencv_contrib2410.lib is in your library list. (again, linker settings)

berak gravatar imageberak ( 2015-02-18 05:37:57 -0600 )edit

i have already included opencv_contrib2410 into my linker.

Deepak Kumar gravatar imageDeepak Kumar ( 2015-02-18 05:48:17 -0600 )edit

ok. you won't need the initModule_contrib() function now, got rid of it ?

berak gravatar imageberak ( 2015-02-18 05:52:10 -0600 )edit

i already removed initModule_contrib(); funtion and converted the create function as you told . but still i am getting same error

Deepak Kumar gravatar imageDeepak Kumar ( 2015-02-18 06:30:47 -0600 )edit