Ask Your Question

Revision history [back]

I can confirm that this is a problem. Given the following reduced code

#include <iostream>
#include "opencv2/opencv.hpp"

using namespace std;
using namespace cv;

int main()
{
    Mat image = imread("/home/spu/Desktop/faces.jpg");
    CascadeClassifier facemodel("/home/spu/Documents/github/opencv/data/lbpcascades/lbpcascade_frontalface.xml");

    Mat temp;
    cvtColor(image, temp, COLOR_BGR2GRAY);
    equalizeHist(temp, temp);
    vector<Rect> faces;
    vector<int> rejectLevels;
    vector<double> levelWeights;

    //BASIC
    //facemodel.detectMultiScale( temp, faces, 1.1, 3 );

    //ADVANCED
    facemodel.detectMultiScale(temp, faces, rejectLevels, levelWeights, 1.1, 3, 0, Size(), Size(), true);

    for( size_t i = 0; i < faces.size(); i++ )
    {
        Point center( faces[i].x + faces[i].width*0.5, faces[i].y + faces[i].height*0.5 );
        ellipse( image, center, Size( faces[i].width*0.5, faces[i].height*0.5), 0, 0, 360, Scalar( 255, 0, 255 ), 4, 8, 0 );
    }

    resize(image, image, Size(image.cols/2, image.rows/2));
    imshow("result", image); waitKey(0);

    cout << "Hello world!" << endl;
    return 0;
}

I notice that the standard BASIC option runs fast, and returns the following result

basic

But the extended version keeps running for ages now ... it has been over multiple minutes ... and the end result is indeed wrong. So I am guessing something is terribly wrong with the backend, because a month ago when writing some book chapters, this functionality was working perfectly fine ...

I can confirm that this is a problem. Given the following reduced code

#include <iostream>
#include "opencv2/opencv.hpp"

using namespace std;
using namespace cv;

int main()
{
    Mat image = imread("/home/spu/Desktop/faces.jpg");
    CascadeClassifier facemodel("/home/spu/Documents/github/opencv/data/lbpcascades/lbpcascade_frontalface.xml");

    Mat temp;
    cvtColor(image, temp, COLOR_BGR2GRAY);
    equalizeHist(temp, temp);
    vector<Rect> faces;
    vector<int> rejectLevels;
    vector<double> levelWeights;

    //BASIC
    //facemodel.detectMultiScale( temp, faces, 1.1, 3 );

    //ADVANCED
    facemodel.detectMultiScale(temp, faces, rejectLevels, levelWeights, 1.1, 3, 0, Size(), Size(), true);

    for( size_t i = 0; i < faces.size(); i++ )
    {
        Point center( faces[i].x + faces[i].width*0.5, faces[i].y + faces[i].height*0.5 );
        ellipse( image, center, Size( faces[i].width*0.5, faces[i].height*0.5), 0, 0, 360, Scalar( 255, 0, 255 ), 4, 8, 0 );
    }

    resize(image, image, Size(image.cols/2, image.rows/2));
    imshow("result", image); waitKey(0);

    cout << "Hello world!" << endl;
    return 0;
}

I notice that the standard BASIC option runs fast, and returns the following result

basic

But the extended version keeps running for ages now ... it has been over multiple minutes ... and the end result is indeed wrong. So I am guessing something is terribly wrong with the backend, because a month ago when writing some book chapters, this functionality was working perfectly fine ...

UPDATE

I started to compare latest 2.4 and master branch

In 2.4 the normal code works as in master, and for the extended function the results are like below. We have more detections (must be a slight different implementation detail), but it does something usefull. Nevertheless I would expect equal parameters to generate equal output, which is not the case...

image description

I now took a clean master branch with same CMAKE configuration and will report back with the results.

I can confirm that this is a problem. Given the following reduced code

#include <iostream>
#include "opencv2/opencv.hpp"

using namespace std;
using namespace cv;

int main()
{
    Mat image = imread("/home/spu/Desktop/faces.jpg");
    CascadeClassifier facemodel("/home/spu/Documents/github/opencv/data/lbpcascades/lbpcascade_frontalface.xml");

    Mat temp;
    cvtColor(image, temp, COLOR_BGR2GRAY);
    equalizeHist(temp, temp);
    vector<Rect> faces;
    vector<int> rejectLevels;
    vector<double> levelWeights;

    //BASIC
    //facemodel.detectMultiScale( temp, faces, 1.1, 3 );

    //ADVANCED
    facemodel.detectMultiScale(temp, faces, rejectLevels, levelWeights, 1.1, 3, 0, Size(), Size(), true);

    for( size_t i = 0; i < faces.size(); i++ )
    {
        Point center( faces[i].x + faces[i].width*0.5, faces[i].y + faces[i].height*0.5 );
        ellipse( image, center, Size( faces[i].width*0.5, faces[i].height*0.5), 0, 0, 360, Scalar( 255, 0, 255 ), 4, 8, 0 );
    }

    resize(image, image, Size(image.cols/2, image.rows/2));
    imshow("result", image); waitKey(0);

    cout << "Hello world!" << endl;
    return 0;
}

I notice that the standard BASIC option runs fast, and returns the following result

basic

But the extended version keeps running for ages now ... it has been over multiple minutes ... and the end result is indeed wrong. So I am guessing something is terribly wrong with the backend, because a month ago when writing some book chapters, this functionality was working perfectly fine ...

UPDATE

I started to compare latest 2.4 and master branch

In 2.4 the normal code works as in master, and for the extended function the results are like below. We have more detections (must be a slight different implementation detail), but it does something usefull. Nevertheless I would expect equal parameters to generate equal output, which is not the case...

image description

I now took a clean master branch with same CMAKE configuration and will report back with the results.

UPDATE 2

Tried switching to HAAR model haarcascade_frontalface_alt.xml, because LBP is my preference, BUT same exists there. Works fine for basic version in 2.4 and master. But the extended version is again running endlessly ... not received a single result yet ...

I can confirm that this is a problem. Given the following reduced code

#include <iostream>
#include "opencv2/opencv.hpp"

using namespace std;
using namespace cv;

int main()
{
    Mat image = imread("/home/spu/Desktop/faces.jpg");
    CascadeClassifier facemodel("/home/spu/Documents/github/opencv/data/lbpcascades/lbpcascade_frontalface.xml");

    Mat temp;
    cvtColor(image, temp, COLOR_BGR2GRAY);
    equalizeHist(temp, temp);
    vector<Rect> faces;
    vector<int> rejectLevels;
    vector<double> levelWeights;

    //BASIC
    //facemodel.detectMultiScale( temp, faces, 1.1, 3 );

    //ADVANCED
    facemodel.detectMultiScale(temp, faces, rejectLevels, levelWeights, 1.1, 3, 0, Size(), Size(), true);

    for( size_t i = 0; i < faces.size(); i++ )
    {
        Point center( faces[i].x + faces[i].width*0.5, faces[i].y + faces[i].height*0.5 );
        ellipse( image, center, Size( faces[i].width*0.5, faces[i].height*0.5), 0, 0, 360, Scalar( 255, 0, 255 ), 4, 8, 0 );
    }

    resize(image, image, Size(image.cols/2, image.rows/2));
    imshow("result", image); waitKey(0);

    cout << "Hello world!" << endl;
    return 0;
}

I notice that the standard BASIC option runs fast, and returns the following result

basic

But the extended version keeps running for ages now ... it has been over multiple minutes ... and the end result is indeed wrong. So I am guessing something is terribly wrong with the backend, because a month ago when writing some book chapters, this functionality was working perfectly fine ...

UPDATE

I started to compare latest 2.4 and master branch

In 2.4 the normal code works as in master, and for the extended function the results are like below. We have more detections (must be a slight different implementation detail), but it does something usefull. Nevertheless I would expect equal parameters to generate equal output, which is not the case...

image description

I now took a clean master branch with same CMAKE configuration and will report back with the results.

UPDATE 2

Tried switching to HAAR model haarcascade_frontalface_alt.xml, because LBP is my preference, BUT same exists there. Works fine for basic version in 2.4 and master. But the extended version is again running endlessly ... not received a single result yet ...

UPDATE 3

It seems that an earlier fix to the standard interface broke down the extended function so we reverted the adaptation in a new PR: https://github.com/Itseez/opencv/pull/6062

Results are then like this

image description