Problems with Opencv - Eyes Cascade and Face Cascade

Asked

Viewed 103 times

2

Hey! What’s up? I am making a program in C++ with Opencv and when running appears the error below

This is the error that is occurring without Try-catch

Este é o erro que está ocorrendo sem o try-catch

This is the error occurring with Try-catch

Este é o erro que esta ocorrendo com o try-catch

int detectEye(Mat& im, Mat& tpl, Rect& rect)
{
    vector<cv::Rect> faces, eyes;
    face_cascade.detectMultiScale(im, faces, 1.1, 2,
        CV_HAAR_SCALE_IMAGE, cv::Size(30, 30));

    for (int i = 0; i < faces.size(); i++)
    {
        Mat face = im(faces[i]);
        eyes_cascade.detectMultiScale(face, eyes, 1.1, 2,
            CV_HAAR_SCALE_IMAGE, Size(20, 20));
        if (eyes.size())
        {
            rect = eyes[0] + Point(faces[i].x, faces[i].y);
            tpl = im(rect);
        }
    }

    return eyes.size();
}

I went to debug and he threw the exception in this excerpt: face_cascade.detectMultiScale(im, faces, 1.1, 2, CV_HAAR_SCALE_IMAGE, cv::Size(30, 30));

Debug screen

inserir a descrição da imagem aqui

Any additional information is just ask. Thanks in advance.

  • I have had similar problems when Opencv libraries were not compiled correctly according to the version of Visual Studio or OS architecture (32 or 64 bits). From the log it looks like you are using VS 2012, but the tag indicates VS 2013. Are you sure you have installed the right libraries? One way to check if everything is ok is to compile and run some of Opencv’s simple tutorials.

  • Another thing that may be happening is an error in booting your Cache. You have not posted the code that initializes the face_cascade, but there you reference an xml file with the trained Cascade (by vc, or one already available in Opencv). If this file is not found, the initialization returns an error indicator. And if this error is ignored, it can also generate exceptions in later use (as perhaps your case). Worth checking this too.

  • 1

    Thank you! I will check this and post a reply later!

  • And then, the problem was the same or not? It would be important to have a reference here, to ideally help other people in the future, no?

  • Check if you are loading the cascade correctly from the disk (face_cascade), because in the code snippet you passed does not appear the part that does this procedure. The error points to this. Example: face_cascade = Cascadeclassifier("/path/to/cascade.xml");

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.