2014-12-23 32 views
2

有沒有一種方法來優化哈爾級聯分類器的人臉檢測?哈爾級聯分類器增加人臉檢測的準確性

我創造了這個功能,它工作得很好,但我仍然有一些問題,一些照片:

void ImageManager::detectAndDisplay(Mat frame, CascadeClassifier face_cascade){ 


    string window_name = "Capture - Face detection"; 
    string filename; 

    std::vector<Rect> faces; 
    std::vector<Rect> eyes; 
    Mat frame_gray; 
    Mat crop; 
    Mat res; 
    Mat gray; 
    string text; 
    stringstream sstm; 


    cvtColor(frame, frame_gray, COLOR_BGR2GRAY); 
    equalizeHist(frame_gray, frame_gray); 

    // Detect faces 
    face_cascade.detectMultiScale(frame_gray, faces, 1.1, 2, 0 | CASCADE_SCALE_IMAGE, Size(30, 30)); 

    // Set Region of Interest 
    cv::Rect roi_b; 
    cv::Rect roi_c; 

    size_t ic = 0; // ic is index of current element 


    for (ic = 0; ic < faces.size(); ic++) // Iterate through all current elements (detected faces) 
    { 

     roi_c.x = faces[ic].x; 
     roi_c.y = faces[ic].y; 
     roi_c.width = (faces[ic].width); 
     roi_c.height = (faces[ic].height); 



     crop = frame_gray(roi_c); 

     faces_img.push_back(crop); 

     rectangle(frame, Point(roi_c.x, roi_c.y), Point(roi_c.x + roi_c.width, roi_c.y + roi_c.height), Scalar(0,0,255), 2); 


    } 

    imshow("test", frame); 
    waitKey(0); 

    cout << faces_img.size(); 


} 

框架:照片我必須analize。

face_cascade:從haar_cascade.xml

創建級聯分類這是我作爲試驗的algoritm的照片,結果是這樣的:enter image description here

結果是相當不錯,臉部都能正確檢測到,但正如你所看到的,我想刪除三個誤報。

在此先感謝

+2

可能會將minNeighbours參數從2增加到5(直到您開始錯過正數)。 – berak

+0

哇,它的工作原理。謝謝 –

+0

順便說一句,如果你發現更好的錯誤檢測, - 隨時[在這裏添加它們](http://machine-pareidolia.appspot.com/) – berak

回答

6

內部,CascadeClassifier做一些檢測,並且基團的那些。

minNeighbours(在detectMultiScale調用)是檢測在大約相同的地方nessecary計算爲一次有效的檢測量,從而增加從目前的2〜也許5左右,直到你開始想念陽性。