Unable to compile program due to dependencies

asked 2015-07-09 05:35:27 -0600

mack_emb gravatar image

updated 2015-07-09 08:47:05 -0600

berak gravatar image

Command used to compile the code:-

g++ `fltk-config --cxxflags` disguise_gui_1306.cpp `fltk-config --ldflags --use-images` `pkg-config opencv --cflags --libs` -o disgui

disguise_gui_1306.cpp:102:9: error: ‘FaceRecognizer’ was not declared in this scope cv::Ptr<facerecognizer> model, mouthModel; ^

disguise_gui_1306.cpp:102:23: error: template argument 1 is invalid cv::Ptr<facerecognizer> model, mouthModel; ^

disguise_gui_1306.cpp:102:30: error: invalid type in declaration before ‘,’ token cv::Ptr<facerecognizer> model, mouthModel; ^

disguise_gui_1306.cpp: In function ‘void snapshotCB(Fl_Widget, void)’:

disguise_gui_1306.cpp:233:40: error: base operand of ‘->’ is not a pointer int predictedMouthLabel = mouthModel->predict(testSample); ^

disguise_gui_1306.cpp:243:31: error: base operand of ‘->’ is not a pointer int predictedLabel = model->predict(testSample); ^

disguise_gui_1306.cpp:261:29: error: base operand of ‘->’ is not a pointer int predictedLabel = model->predict(testSample); ^

disguise_gui_1306.cpp: In function ‘void trainFaceRecogniserModel(std::vector<cv::mat>, std::vector<int>)’: disguise_gui_1306.cpp:395:39: error: ‘createEigenFaceRecognizer’ was not declared in this scope model = createEigenFaceRecognizer();
^

disguise_gui_1306.cpp:396:10: error: base operand of ‘->’ is not a pointer model->train(img, lab); ^

disguise_gui_1306.cpp: In function ‘int main(int, char**)’:

disguise_gui_1306.cpp:417:39: error: ‘createEigenFaceRecognizer’ was not declared in this scope model = createEigenFaceRecognizer();
^

disguise_gui_1306.cpp:418:10: error: base operand of ‘->’ is not a pointer model->train(images, labels); ^

disguise_gui_1306.cpp:433:15: error: base operand of ‘->’ is not a pointer mouthModel->train(mouthimages, mouthlabels);

I have tried using:-

cv::Ptr<face::facerecognizer> model, mouthModel;

error: ‘face’ cannot appear in a constant-expression cv::Ptr<face::facerecognizer> model, mouthModel;

The same code compiles perfectly on my friends laptop,and the only difference i am able to understand is he have installed opencv in usr/local while i have the same in downloads folder.

Kindly help,because i have been stuck around this from couple of days. I have even installed extra folders from https://github.com/itseez/opencv_contrib, but no difference.

These are relevant parts of code, I am trying to detect a mouth and face and then create a database of the same.

//
// libraies path:-
#include <opencv2/opencv.hpp>

#include <opencv/highgui.h>

#include <opencv/ml.h>

#include "/home/isenses/Downloads/opencv-3.0.0-rc1/modules/core/include/opencv2/core.hpp"

#include "/home/isenses/Downloads/opencv-3.0.0-rc1/modules/objdetect/include/opencv2/objdetect.hpp"

-#include "/home/isenses/Downloads/opencv-3.0.0-rc1/modules/imgproc/include/opencv2/imgproc.hpp"


cv::Ptr<face::FaceRecognizer> model, mouthModel;

if(predictedMouthLabel == 1){

        pureFaces.push_back(face);

        testSample = face;

        int predictedLabel = model->predict(testSample);

        }


for(int i = 0; i < pureFaces.size(); ++i){

        Mat temp  = pureFaces[i];

        resize(temp, temp, Size(92, 112));

        testSample = temp;    

        int predictedLabel = model->predict(testSample);

        }


void trainFaceRecogniserModel(std::vector<Mat> img, std::vector<int> lab){

    img.clear();

    lab.clear();

    try {

        readdb("database/database.txt", img, lab);

    } catch (cv::Exception& e) {

        cerr << "Error opening file . Reason: " << e.msg << endl;

        exit(1);

    }

    if(!(img.size() >= 2)) {

        string error_message = "This demo needs at least 2 images to work. Please add more images to your data set!";

        CV_Error(CV_StsError, error_message);

    }

    //resize images

    for(int i = 0; i < img.size(); ++i ...
(more)
edit retag flag offensive close merge delete

Comments

please add (the relevant parts of) your code .

berak gravatar imageberak ( 2015-07-09 05:39:44 -0600 )edit

mouthModel = face::createEigenFaceRecognizer();

berak gravatar imageberak ( 2015-07-09 08:53:21 -0600 )edit

I added the namespace declaration but i keep getting the same error as before.

error: ‘face’ cannot appear in a constant-expression cv::Ptr<face::facerecognizer> model, mouthModel;

and yes i have also added face:: to all the places where its model = createEigenFaceRecognizer(); or

mouthModel = createEigenFaceRecognizer();

mack_emb gravatar imagemack_emb ( 2015-07-09 10:58:05 -0600 )edit

hmm, i tried to format the code above, but maybe i fouled up somewhere.

the cv::Ptr<face::facerecognizer> model, mouthModel; line (and those below) are somewhat out of context.

can you try to add a bit more there ? (btw, that line compiles fine on it's own)

berak gravatar imageberak ( 2015-07-09 12:15:36 -0600 )edit

Yes these are just bits of code so it wont compile.

Another thing is i believe there is no problem with the code itself, because the same code without any face:: namespace declaration compiles smoothly on my friends laptop (the system on which we were originally working). I took the codes to test on my end and wasn't even able to compile it. Then i also gave a try of compiling it on different system, but no luck.

mack_emb gravatar imagemack_emb ( 2015-07-09 22:02:29 -0600 )edit

@berak can i have your email id. we tried to fresh install openCV and try to compile again but no luck. We came to conclusion of comparing our flags after installation. We compared our CMakeCache.txt files and we find there are huge amount of differences. But i am not sure what that means. So i you can provide me your emailID, i can share the txt files.

mack_emb gravatar imagemack_emb ( 2015-07-19 06:29:35 -0600 )edit