Exemple #1
0
void OpenEyeMouthDetectors(
    const vec_Mod& mods,    // in: the ASM models (used to see if we need eyes or mouth)
    const char*    datadir) // in
{
    static bool needeyes = true; // static for efficiency
    if (needeyes && leye_det_g.empty()) // not yet opened?
    {
        // we need the eyes if the estart field of any model
        // is ESTART_EYES or ESTART_EYE_AND_MOUTH
        needeyes = false;
        for (int imod = 0; imod < NSIZE(mods); imod++)
            if (mods[imod]->Estart_() == ESTART_EYES ||
                    mods[imod]->Estart_() == ESTART_EYE_AND_MOUTH)
                needeyes = true;
        if (needeyes)
        {
            // I tried all the eye XML files that come with OpenCV 2.1 and found that
            // the files used below give the best results.  The other eye XML files
            // often failed to detect eyes, even with EYE_MIN_NEIGHBORS=1.
            //
            // In the XML filenames, "left" was verified empirically by me to respond
            // to the image left (not the subject's left).  I tested this on the on
            // the MUCT and BioID sets: haarcascade_mcs_lefteye.xml finds more eyes
            // on the viewer's left than it finds on the right (milbo Lusaka Dec 2011).

            OpenDetector(leye_det_g,  "haarcascade_mcs_lefteye.xml",  datadir);
            OpenDetector(reye_det_g,  "haarcascade_mcs_righteye.xml", datadir);
        }
    }
    static bool needmouth = true; // static for efficiency
    if (needmouth && mouth_det_g.empty()) // not yet opened?
    {
        // we need the eyes if the estart field of any model is ESTART_EYE_AND_MOUTH
        needmouth = false;
        for (int imod = 0; imod < NSIZE(mods); imod++)
            if (mods[imod]->Estart_() == ESTART_EYE_AND_MOUTH)
                needmouth = true;
        if (needmouth)
            OpenDetector(mouth_det_g, "haarcascade_mcs_mouth.xml", datadir);
    }
}
void OpenEyeMouthDetectors(    // open eye and mouth detectors, if necessary
    bool           need_eyes,  // in: true if we need the eye detectors
    bool           need_mouth, // in: true if we need the mouth detector
    const char*    datadir)    // in
{
    if (need_eyes)
    {
        // I tried all the eye XML files that come with OpenCV 2.1 and found that
        // the files used below give the best results.  The other eye XML files
        // often failed to detect eyes, even with EYE_MIN_NEIGHBORS=1.
        //
        // In the XML filenames, "left" was verified empirically by me to respond
        // to the image left (not the subject's left).  I tested this on the on
        // the MUCT and BioID sets: haarcascade_mcs_lefteye.xml finds more eyes
        // on the viewer's left than it finds on the right (milbo Lusaka Dec 2011).

        OpenDetector(leye_det_g,  "haarcascade_mcs_lefteye.xml",  datadir);
        OpenDetector(reye_det_g,  "haarcascade_mcs_righteye.xml", datadir);
    }
    if (need_mouth)
        OpenDetector(mouth_det_g,  "haarcascade_mcs_mouth.xml", datadir);
}
Exemple #3
0
void FaceDet::OpenFaceDetector_( // called by stasm_init, init face det from XML file
    const char* datadir,         // in: directory of face detector files
    void*)                       // in: unused (func signature compatibility)
{
    OpenDetector(facedet_g, "haarcascade_frontalface_alt2.xml",  datadir);
}