我正在尝试制作一个离线视频人脸检测程序。我已经使用示例代码进行人脸检测,效果很好。但是由于 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();
}
最佳答案
Dlib 有一个 OpenCV 集成。您可以使用OpenCV函数读取视频文件并使用Dlib进行人脸检测
这是一个关于这种集成的示例
http://dlib.net/webcam_face_pose_ex.cpp.html
你应该只改变
cv::VideoCapture cap(0);
进入
cv::VideoCapture videoCapture;
videoCapture.open(fileName);
关于c++ - 使用 dlib 进行视频人脸检测,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36283368/