我正在尝试制作一个离线视频人脸检测程序。我已经使用示例代码进行人脸检测,它运行良好。但是由于 dlib 库不能直接在视频上工作(或者我不知道它是否可以),所以我正在为图像人脸检测程序提供帧。对于诸如 20-30 帧视频之类的小视频,它可以正常工作,但如果给定更大的视频,则会出现缓冲区溢出错误。我是否必须明确删除数据或清除一些动态内存?还是它只处理少量图像进行人脸检测?
下面是代码片段
// Loop over all the images provided on the command line.
for (int i = 1; i <= 629; ++i)
{
//cout << "processing image " << endl;
array2d<unsigned char> img;
//load_image(img, argv[i]);
sprintf(image, "./frame/frame%d.jpg",i);
load_image(img, image);
pyramid_up(img);
// Now tell the face detector to give us a list of bounding boxes
// around all the faces it can find in the image.
std::vector<rectangle> dets = detector(img);
//cout << "Number of faces detected: " << dets.size() << endl;
//cout<<i<<"\t"<<dets.size()<<endl;
// Now we show the image on the screen and the face detections as
// red overlay boxes.
win.clear_overlay();
win.set_image(img);
win.add_overlay(dets, rgb_pixel(255,0,0));
//cout << "Hit enter to process the next image..." << endl;
//cin.get();
}