for (;;)
{
std::cout << "capturing..." << std::endl; // test
capture >> frame;
if (frame.empty())
break;
Mat frame1 = frame.clone();
std::cout << "Start to detect..." << std::endl; // test
detectAndDraw(frame1, cascade, nestedCascade, scale, tryflip);
int c = waitKey(10);
if (c == 27 || c == 'q' || c == 'Q')
break;
}
}
else
{
cout << "Detecting face(s) in " << inputName << endl;
if (!image.empty())
{
detectAndDraw(image, cascade, nestedCascade, scale, tryflip);
waitKey(0);
}
else if (!inputName.empty())
{
/* assume it is a text file containing the
list of the image filenames to be processed - one per line */
FILE* f = fopen(inputName.c_str(), "rt");
if (f)
{
char buf[1000 + 1];
while (fgets(buf, 1000, f))
{
int len = (int)strlen(buf), c;
while (len > 0 && isspace(buf[len - 1]))
len--;
buf[len] = '\0';
cout << "file " << buf << endl;
image = imread(buf, 1);
if (!image.empty())
{
detectAndDraw(image, cascade, nestedCascade, scale, tryflip);
c = waitKey(0);
if (c == 27 || c == 'q' || c == 'Q')
break;
}
else
{
cerr << "Aw snap, couldn't read image " << buf << endl;
}
}
fclose(f);
}
}
}
return 0;
}