Ask Your Question

Revision history [back]

CascadeClassifier strangely not linkin

Hi there

I tried to search via google and this forum for an equivalent problem, did not found... I'm trying to make a facedetector program using opencv and qt, using some tutorials code (I'm quite new to C++)... problem is with the methods of CascadeClassifier, apparently and for a strange reason, it's not linking correctly with the library

here's the code :

void ThreadVideoProcess::run()
{
std::string yo = "haarcascade_frontalface_default.xml";
CascadeClassifier haar_cascade;
if (haar_cascade.load(yo))
{
    while(1)
    {
        videoBuffer->get(matCvImage);  
        Mat original = matCvImage.clone();
        Mat gray;
        cvtColor(original, gray, CV_BGR2GRAY);
        vector< Rect_<int> > faces;
        haar_cascade.detectMultiScale(gray, faces);
        for(int i = 0; i < faces.size(); i++) {
            Rect face_i = faces[i];
            Mat face = gray(face_i);
            Mat face_resized;
            cv::resize(face, face_resized, Size(640, 480), 1.0, 1.0, INTER_CUBIC);
            rectangle(original, face_i, CV_RGB(0, 255,0), 1);
        }
        qtImageLabel->setPixmap(QPixmap::fromImage(MatToQImage(original)));
    }
}
}

I get those unique debug errors :

"undefined reference to `cv::CascadeClassifier::load(std::string const&)'

"undefined reference to `cv::CascadeClassifier::detectMultiScale(cv::Mat const&, std::vector<cv::rect_<int>, std::allocator<cv::rect_<int> > >&, double, int, int, cv::Size_<int>, cv::Size_<int>)'

Libraries included are : libopencv_core300d.dll.a libopencv_objdetect300d.dll.a libopencv_imgproc300d.dll.a libopencv_highgui300d.dll.a

Strange thing is when I remove the libopencv_objdetec300d.dll.a library, I get more errors like :

undefined reference to `cv::CascadeClassifier::CascadeClassifier()'

...and when I put this library again, I only, but still, get the errors described above... like the compiler finds the library for the CascadeClassifier class, but not for its methods!!!

I guess I'm missing some basics, as I said I'm pretty new to C++ so I don't think it's a bug...

Got stucked for 3 days now, so any help or idea would be veeerryyyy helpful !!!

Thanks in advance !

Codeblocks 13.12 on win7

Qt Qt5.2.1.minGw48.openGL

openCV 2.4.8 build via CMAKE in DEBUG mode MinGW32

click to hide/show revision 2
retagged

updated 2014-04-12 07:00:06 -0600

berak gravatar image

CascadeClassifier strangely not linkin

Hi there

I tried to search via google and this forum for an equivalent problem, did not found... I'm trying to make a facedetector program using opencv and qt, using some tutorials code (I'm quite new to C++)... problem is with the methods of CascadeClassifier, apparently and for a strange reason, it's not linking correctly with the library

here's the code :

void ThreadVideoProcess::run()
{
std::string yo = "haarcascade_frontalface_default.xml";
CascadeClassifier haar_cascade;
if (haar_cascade.load(yo))
{
    while(1)
    {
        videoBuffer->get(matCvImage);  
        Mat original = matCvImage.clone();
        Mat gray;
        cvtColor(original, gray, CV_BGR2GRAY);
        vector< Rect_<int> > faces;
        haar_cascade.detectMultiScale(gray, faces);
        for(int i = 0; i < faces.size(); i++) {
            Rect face_i = faces[i];
            Mat face = gray(face_i);
            Mat face_resized;
            cv::resize(face, face_resized, Size(640, 480), 1.0, 1.0, INTER_CUBIC);
            rectangle(original, face_i, CV_RGB(0, 255,0), 1);
        }
        qtImageLabel->setPixmap(QPixmap::fromImage(MatToQImage(original)));
    }
}
}

I get those unique debug errors :

"undefined reference to `cv::CascadeClassifier::load(std::string const&)'

"undefined reference to `cv::CascadeClassifier::detectMultiScale(cv::Mat const&, std::vector<cv::rect_<int>, std::allocator<cv::rect_<int> > >&, double, int, int, cv::Size_<int>, cv::Size_<int>)'

Libraries included are : libopencv_core300d.dll.a libopencv_objdetect300d.dll.a libopencv_imgproc300d.dll.a libopencv_highgui300d.dll.a

Strange thing is when I remove the libopencv_objdetec300d.dll.a library, I get more errors like :

undefined reference to `cv::CascadeClassifier::CascadeClassifier()'

...and when I put this library again, I only, but still, get the errors described above... like the compiler finds the library for the CascadeClassifier class, but not for its methods!!!

I guess I'm missing some basics, as I said I'm pretty new to C++ so I don't think it's a bug...

Got stucked for 3 days now, so any help or idea would be veeerryyyy helpful !!!

Thanks in advance !

Codeblocks 13.12 on win7

Qt Qt5.2.1.minGw48.openGL

openCV 2.4.8 build via CMAKE in DEBUG mode MinGW32