Ask Your Question

Revision history [back]

Basically what you doing wrong is using the standard project path of visual studio. Windows allows folders to be named with spacings, but this screws up your code. So change the following lines, to contain simple locations:

if( !face_cascade.load( "D:/Visual Studio 2010/Projects/newfaceDetection/haarcascade_frontalface_alt.xml" ) ){ printf("--(!)Error loading\n"); return -1; }
if( !eyes_cascade.load( "D:/Visual Studio 2010/Projects/newfaceDetection/haarcascade_eye_tree_eyeglasses.xml" ) ){ printf("--(!)Error loading\n"); return -1; }

into for example

if( !face_cascade.load( "D:/models/haarcascade_frontalface_alt.xml" ) ){ printf("--(!)Error loading\n"); return -1; }
if( !eyes_cascade.load( "D:/models/haarcascade_eye_tree_eyeglasses.xml" ) ){ printf("--(!)Error loading\n"); return -1; }

Next try to start with the basic detector parametes and leave the more specialized ones for later. Change the following line

face_cascade.detectMultiScale( frame_gray, faces, 1.1, 2, 0|CV_HAAR_SCALE_IMAGE, Size(40, 40) )

into

face_cascade.detectMultiScale( frame_gray, faces, 1.1, 2)