Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Detectmultiscale for face detection in opencv 3.1 C++ doesn't work properly

Dear all, I recently develop an app for face detection using C++, Visual Studio 2015 and lbp cascades filter. Initially, my app, was developed with OpenCV 3.0 and face detection was very very good. The code is similar to others hundreds of Code on hundreds and hundreds of blogs:

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include "opencv2/objdetect/objdetect.hpp"
#include <opencv2/imgproc.hpp>
#include "main.h"

using namespace cv;
using namespace std;
Mat cameraFrame;
CascadeClassifier face_cascade;
int main()
{
    VideoCapture stream1(0);
    Mat mGray;
    Mat eye;
    vector<Rect> faces;
face_cascade.load("C:\\MyFile\\Lavoro\\EyeTracking\\OpenCVwindows\\opencv\\build\\etc\\lbpcascades\\lbpcascade_frontalface.xml");
while (true) {
        stream1.read(cameraFrame);
        cvtColor(cameraFrame, mGray, CV_RGB2GRAY);
        equalizeHist(mGray, mGray);
        face_cascade.detectMultiScale(mGray, faces, 1.1, 2, CV_HAAR_FIND_BIGGEST_OBJECT | CV_HAAR_SCALE_IMAGE, Size(30, 30));
}
}
// ...other not usefull code for this questions

So, basically, I load an lbp filter and I apply this filter on GRAY image for detect faces. In OpenCV 3.0 all run very well, in opencv3.1 the results is that vector faces has a size of about 1.5 Millions. Watching this results I noticed that x and y coordinates are, in some case, wrong! For example into an image of 640x480 I have x and y of about 3000-4000.

Is this a bug of OpenCV 3.1? How can I resolve it?