Exemple #1
0
void
DiscardShapesWithDifferentNbrOfPoints (vec_SHAPE &Shapes,    // io: updated
                                       vec_string &Tags,     // io: updated
                                       int nWantedPoints)
{
unsigned iShape1 = 0;
unsigned nShapes = static_cast<int>(Tags.size());

ASSERT(Shapes.size() == nShapes);

for (unsigned iShape = 0; iShape < nShapes; iShape++)
    if (Shapes[iShape].nrows() == (unsigned)nWantedPoints)
        {
        Shapes[iShape1].assign(Shapes[iShape]);
        Tags[iShape1] = Tags[iShape];
        iShape1++;
        }

// if (nShapes - iShape1)
    // lprintf("Ignored %d shape%s "
            // "not matching the reference number of points %d\n",
            // nShapes - iShape1,
            // (nShapes - iShape1 == 1? "": "s"),
            // nWantedPoints);

Shapes.resize(iShape1);
Tags.resize(iShape1);
}
Exemple #2
0
void
DiscardFaceDetectorShapes (vec_SHAPE &Shapes,       // io: updated
                           vec_string &Tags,        // io: updated
                           bool fDiscardUnderscores)
{
unsigned iShape1 = 0;
unsigned nShapes = Tags.size();

ASSERT(Shapes.size() == nShapes);

for (unsigned iShape = 0; iShape < nShapes; iShape++)
    {
    const char *sTag = Tags[iShape].c_str();
    // tag string should be of the form: "1234 filename" or "12345678 filename"
    if (sTag[4] != ' ' && sTag[8] != ' ')
        Err("malformed tag \"%s\"", sTag);
    unsigned Attr;
    if (1 == sscanf(sTag, "%x", &Attr) &&
        !((Attr & FA_ViolaJones) || (Attr & FA_Rowley)) && // not a face detector shape
        (!fDiscardUnderscores || sGetBasenameFromTag(sTag)[0] != '_'))
        {
        Shapes[iShape1].assign(Shapes[iShape]);
        Tags[iShape1] = Tags[iShape];
        iShape1++;
        }
    }
if (nShapes - iShape1)
    lprintf("Ignored %d face detector%s shape%s\n",
            nShapes - iShape1,
            (fDiscardUnderscores? " and underscore": ""),
            (nShapes - iShape1 == 1? "": "s"));

Shapes.resize(iShape1);
Tags.resize(iShape1);
}