Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Let OpenCV face detection score output codes     - CentOS 5.11 Open VNC access (Linux)

- RPM package fabrication method (Linux)

- J2EE Example of Filter (Programming)

- Achieve single backup of MySQL by innobackupex (Database)

- Ubuntu 14.04 Boot Repair (Linux)

- Installation Yarock 1.1.4 Music Player in Ubuntu (Linux)

- Ubuntu 14.10 splash screen brightness settings (Linux)

- Linux 0.12 kernel and modern kernels difference in memory management (Linux)

- SSH Filesystem use a secure connection for network file system (Linux)

- Eclipse configuration GTK (Linux)

- Father of Python: Why Python zero-based index (Programming)

- Configuring Allatori code confusion when developing general Java applications in NetBeans (Programming)

- CentOS7 install and configure Nagios (Server)

- DVD production using CentOS installation source within the company Yum (Linux)

- Linux user status query, and to unlock locked user (Linux)

- How do I delete a NEEDS RECOVERY rollback state of undo tablespace (Database)

- Forbid screen change the window size when creating a new window under CentOS (Linux)

- VSFTPD Security (Linux)

- iscsiadm command usage (Linux)

- How to Install Telegram instant messaging software on Ubuntu (Linux)

 
         
  Let OpenCV face detection score output codes
     
  Add Date : 2018-11-21      
         
         
         
  Slightly more recent project, one needs to find some negative samples and more like the face but not the face, want to use OpenCV face detection sensor errors such as the face of negative samples.

However, the domestic (including foreign) actually almost no relevant information on how to output detectMultiScale () Confidence rate or a face score

So write a little summary for those who need relevant reference.

I looked at the face recognition function OpenCV source code

\ Sources \ modules \ objdetect \ src \ cascadedetect.cpp

 

The detectMultiScale has two overloaded, second overloaded in opencv developer documentation actually mention:

void CascadeClassifier :: detectMultiScale (const Mat & image, vector < Rect> & objects,
                                          vector < int> & rejectLevels,
                                          vector < double> & levelWeights,
                                          double scaleFactor, int minNeighbors,
                                          int flags, Size minObjectSize, Size maxObjectSize,
                                          bool outputRejectLevels)

He has found a rejectLevels and levelWeight two reference parameters, look at the name is a feeling of scoring output.

google found a bit foreign to many people asked to explain, but basically nothing (or I did not seriously looking for?)

Then looked under it calls cvHaarDetectObjectsForROC () source code to achieve, probably you understand maybe vectors are doing.

First Conclusion: Are you sure about the score and face.

First of all we should understand that detectMultiScale () This method is a cascade classifier, using boosting method. Therefore, the input image to go through layers (grade level) selection, is left to the last real man (positive samples)

rejectLevels is to represent the first layers to be out of. If this is the last one (in lbpcascade_frontalface.xml is 20, depending on xml Narrative) is out, then the sample is likely to be positive.

Why say it is possible?

Because there are parameters: levelWeight. Even in the last layer being out of, levelWeight small or even negative, can also be seen as a negative sample.

It is in fact a lot of negative samples were out of the last layer.

I am here only interception of the level in only 20 out of the box. Their output levelWeight. Is where the largest multi-4.23 face, the other small. Not too much to explain it ~

Therefore, the principle of this function is such that (personal understanding, there is an error, please advise):

First, a level a level test sample, then each level corresponding to a score that is levelWeight, if the weight is below or above the corresponding level of the threshold, were abandoned.

Adhere to the last level and still meet the threshold level last frame is the right face (positive samples).

Therefore, the face should be divided like this: level the greater the higher the score, at the same level, levelWeight greater the higher the score.

But in fact the real face is to stick to the level20 (last level), so the only match all of the more than 1 frame levelWeight last level for comparison can know the face scores friends ~

Finally, gray often dapper demo source code:

#include < opencv2 \ opencv.hpp>
#include < iostream>
#include < vector>
#include < fstream>
#include < math.h>
using namespace std;
using namespace cv;
const string xmlpath = "lbpcascade_frontalface.xml";
CascadeClassifier face_cc;

int tic = 0;

void detect (Mat img) {
    vector < Rect> faces;
    vector < int> rejLevel;
    vector < double> levelW;
    Mat grayimg;
    cvtColor (img, grayimg, CV_RGB2GRAY);
    equalizeHist (grayimg, grayimg);
    int minl = min (img.rows, img.cols);
    face_cc.detectMultiScale (grayimg, faces, rejLevel, levelW, 1.1, 3, 0, Size (), Size (), true);
    //face_cc.detectMultiScale(grayimg, faces, 1.1);
    for (int i = 0; i < faces.size (); i ++)
    {
        if (rejLevel [i] < 00)
        {
            continue;
        }
        stringstream text1, text2;
        text1 < < "rejLevel:" < < rejLevel [i];
        text2 < < "levelW:" < < levelW [i];
        string ttt = text1.str ();
        rectangle (img, faces [i], Scalar (255, 255, 0), 2, 8, 0);
        putText (img, ttt, cvPoint (faces [i] .x, faces [i] .y - 3), 1, 1, Scalar (0,255,255));
        ttt = text2.str ();
        putText (img, ttt, cvPoint (faces [i] .x, faces [i] .y + 12), 1, 1, Scalar (255, 0, 255));
    }
    imshow ( "IMG", img);
    waitKey (0);
}

int main () {
    if (! face_cc.load (xmlpath))
    {
        cout < < "load error \ n!";
        return -1;
    }
    ifstream pathin;
    pathin.open ( "imgpath.txt");
    string t;
    while (pathin >> t && tic < 10000)
    {
        Mat img = imread (t);
        detect (img);
    }
    pathin.close ();
    return 0;
}
     
         
         
         
  More:      
 
- Differences Shell scripting languages and compiled languages (Programming)
- Eclipse 3.7.2 can not start solving under Ubuntu 14.04 (Linux)
- File compression and packaging commands under Linux (Linux)
- Docker startups use continuous integration deployment (Server)
- Android memory optimization of the disk cache (Linux)
- Why learn Java EE (Programming)
- The security configuration of Linux (Linux)
- Windows and Ubuntu dual system, repair of two ways UEFI boot (Linux)
- How to use nmap command in Linux (Linux)
- 4 lvcreate example commonly used commands (Linux)
- Configure the ASM process on Red Hat Linux 6.5 (Database)
- Linux ln command - create a file / directory link (Linux)
- Oracle conditional select statements and looping statements (Database)
- error no.2013 lost connection Tom with SQLServer during query (Database)
- 10046 trace only open for a particular SQL statement (Database)
- Linux daemon (Linux)
- Unetbootin make use U disk loading Linux system (Linux)
- How do you turn on and off IPv6 address on Fedora (Linux)
- RHEL6.4 x86_64 build SVN service (Server)
- Redis performance test (Database)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.