hi
I'm using this code for face and eye detection :
when I run it it throws memory exception and in the cmd this message dispalyed :
why this happening can you help me please
Thanks
int main()
{
CascadeClassifier faceCascade;
CascadeClassifier eyeCascade1;
CascadeClassifier eyeCascade2;
Rect faceRect;
VideoCapture videoCapture ("nn.mp4");
cout << "Face Detection ." << endl;
cout << "Realtime face detection using LBP " << endl;
cout << "Compiled with OpenCV version " << CV_VERSION << endl << endl;
// Load the face and 1 or 2 eye detection XML classifiers.
initDetectors(faceCascade,eyeCascade2);
Mat thresh, gray;
while (1)
{
Mat frame;
videoCapture>> frame;
detectLargestObject(frame, faceCascade, faceRect);
if (faceRect.width > 0)
{
rectangle(frame, faceRect, CV_RGB(255, 0, 0), 2, CV_AA);
}
Mat faceImg = frame(faceRect);
Mat gray;
if (faceImg.channels() == 3) {
cvtColor(faceImg, gray, CV_BGR2GRAY);
}
else if (faceImg.channels() == 4) {
cvtColor(faceImg, gray, CV_BGRA2GRAY);
}
else {
// Access the input image directly, since it is already grayscale.
gray = faceImg;
}
Point leftEye, rightEye;
Rect searchedLeftEye, searchedRightEye;
detectBothEyes(gray, eyeCascade1, eyeCascade2, leftEye, rightEye, & searchedLeftEye, & searchedRightEye);
rectangle(faceImg, searchedLeftEye,Scalar(0, 255, 0), 2, 8, 0);
rectangle(faceImg, searchedRightEye, Scalar(0, 255, 0), 2, 8, 0);
searchedRightEye.y += searchedRightEye.height / 3;
searchedRightEye.height -= searchedRightEye.height / 3;
Mat eye_region=faceImg(searchedRightEye);
cvtColor(eye_region, gray, CV_BGR2GRAY);
threshold(gray, thresh, 60, 255, THRESH_BINARY);
imshow("eye_ video", thresh);
imshow("video", frame);
// Press 'c' to escape
if (waitKey(30) == 'c') break;
}
return 0;
}