2016-03-29 29 views
1

オフラインビデオ顔検出プログラムを作成しようとしています。私は顔検出のためのサンプルコードを使用して、それは良い仕事です。しかし、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(); 
    } 

答えて

3

DLIBは、そのためのOpenCVの統合を持っています。あなたは

顔検出のための

をここでOpenCVの関数でビデオファイルを読み込み、DLIBを使用することができますあなたが唯一

cv::VideoCapture cap(0); 

を変更する必要があり、統合

http://dlib.net/webcam_face_pose_ex.cpp.html

のような種類のサンプルです

cv::VideoCapture videoCapture; 
videoCapture.open(fileName); 
1

フレームが大きいと、検出が遅くなります。したがって、フレームのサイズを変更し、追跡/検出プロセスを実行する方がよいでしょう。

関連する問題