我正在嘗試製作離線視頻臉部檢測程序。我已經使用示例代碼進行人臉檢測,並且工作良好。但由於dlib庫不能直接在視頻上工作(或者我不知道它是否會),所以我正在爲圖像人臉檢測程序提供幀。對於像20-30幀視頻這樣的小視頻來說,它工作正常,但是如果給出更大的視頻,則會出現緩衝區溢出錯誤。我是否必須刪除數據或明確清除一些動態內存?或者它只處理少量圖像進行人臉檢測?使用dlib進行視頻臉部檢測
下面是代碼片段
// 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();
}