Ask Your Question
0

CascadeClassifier strangely not linkin

asked 2014-04-12 06:08:15 -0600

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

berak gravatar image

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

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2014-04-12 06:56:59 -0600

berak gravatar image

updated 2014-04-12 07:02:38 -0600

you seem to use opencv 3.0 here. (not 2.4.8, just look at the libs)

they changed all of the std::string to cv::String there, so, while you code compiles correctly ( yes, both string types are compatible there ) , your linker has a different opinion on it.

try:

cv::String yo = ...

i'm not sure, why it chokes on the Rect vector, maybe

  vector< Rect > faces;

helps. ( well, if so, i'd say, at least that is worth reporting an issue. )


if you forked or cloned the code from github, the master(3.0) branch is the default one.

if you want 2.4.8 instead, do:

 git checkout 2.4

and rebuild the whole schlepp (cmake and all).

PS. i'm wondering, why it did not complain about CV_BGR2GRAY. did you include one of the c-headers ?

edit flag offensive delete link more

Comments

(my last post apparently did not work) you were right, I was using the v3.0 without knowing it, because of git... I donwload the 2.4 branch, re-compil and got still some problems but the above linking errors are gone ! thanks a lot !

(concerning cv_bgr2gray I included only imgproc and contrib... didn't get any problem with that...)

cheers

ninjatueur gravatar imageninjatueur ( 2014-04-12 11:02:48 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2014-04-12 06:08:15 -0600

Seen: 1,988 times

Last updated: Apr 12 '14