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?
did you build OpenCV 3.1 libraries from source?
Hi sturkmen. No, I download the self-extract file from opencv website, I set environment variable and path. And finally set my visual studio project properties ( like linker input and additional include directories). I follow the tutorial provide from opencv. This worked for 3.0. I do the same procedure for 3.1 and I succesfully build and run my code. I have problem just with face detection
AFAIK Visual Studio 2015 compatibility is only by building libraries yourself. could you try both of OpenCV tutorials and tell us the results.
Yes!! I will try and I will tell you the results. Thank you
Hi! I have some problem on Visual Studio 2015 Community, C++, Windows 10, OpenCV 3.1, x64, tried both Debug and Releas. Source code like above. I tried various combinations of the debug configurations: MT, MD, MDd I tried all of classifiers for faces: haarcascade_frontalcatface.xml, haarcascade_frontalface_alt.xml, haarcascade_frontalface_default.xml from opencv\build\etc\haarcascades
When I tried source line
face_cascade.detectMultiScale(frame_gray, faces, 1.1, 3, 0 | CV_HAAR_SCALE_IMAGE, Size(30, 30));
the error access violation record appears ('record' or 'writing' i do not shure because have a Russian interface)
Next I tried change Size(500,500), and when line pass but faces keeps billlllions of faces:
@using again i ask, did you build OpenCV 3.1 libraries from source?
@sturkmen No, I did not build the library. I used ready-made from opencv3.1.0\opencv\build\x64\vc14\lib
@sturkmen i tried your code above in 3.0.0 and it don work properly. There is access violation error at size < 462. (At size >462 faces.size=0). And also, you are using LBP cascade and CV_HAAR_SCALE_IMAGE key. Is it correct?
where is the whole source ? i think you have a problem about configuration of Visual Studio. did you try to run some of other examples
i advise you to try rebuilding library from source