When i run my program in VS 2015 this is the error im getting :
Unhandled exception at 0x00007FFA3A268B9C in opencv.exe: Microsoft C++ exception: cv::Exception at memory location 0x000000484DBDDFA0.
my program is :
include <stdio.h>
include <opencv cv.h="">
include <opencv highgui.h="">
include <opencv cxcore.h="">
/------ Declaration des variables globales ------/ char key; CvHaarClassifierCascade cascade; CvMemStorage *storage; /---------- Declaration des fonctions -----------/ void detectFaces(IplImage *img); /------------------------------------------------/ int main(void) { / Declaration des variables */ CvCapture *capture; IplImage *img; const char *filename = "C:Users\Acer\Desktop\faceDetect\haarcascade_frontalface_alt.xml";
/* Chargement du classifieur */
cascade = (CvHaarClassifierCascade*)cvLoadHaarClassifierCascade(filename, cvSize(24, 24));
/* Ouverture du flux video de la camera */
capture = cvCreateCameraCapture(-1);
// Ouverture d'un fichier video
//capture = cvCreateFileCapture("C:Users\Acer\Desktop\faceDetect\cam.avi");
/* Initialisation de l'espace memoire */
storage = cvCreateMemStorage(0);
/* Creation d'une fenetre */
cvNamedWindow("Window-FT", 1);
/* Boucle de traitement */
while (key != 'q')
{
img = cvQueryFrame(capture);
detectFaces(img);
key = cvWaitKey(10);
}
/* Liberation de l'espace memoire*/
cvReleaseCapture(&capture);
cvDestroyWindow("Window-FT");
cvReleaseHaarClassifierCascade(&cascade);
cvReleaseMemStorage(&storage);
return 0;
} /------------------------------------------------/ void detectFaces(IplImage img) { / Declaration des variables */ int i; CvSeq *faces = cvHaarDetectObjects(img, cascade, storage, 1.1, 3, 0, cvSize(40, 40));
for (i = 0; i<(faces ? faces->total : 0); i++)
{
CvRect *r = (CvRect*)cvGetSeqElem(faces, i);
cvRectangle(img, cvPoint(r->x, r->y), cvPoint(r->x + r->width, r->y + r->height), CV_RGB(255, 0, 0), 1, 8, 0);
}
cvShowImage("Window-FT", img);
}