Exemple #1
0
static void ProcessFace(
    CImage&      cimg,      // io: color version of image
    const float* landmarks, // in
    int          nfaces,    // in
    const char*  imgpath)   // in
{
    Shape shape(LandmarksAsShape(landmarks));
    shape = ConvertShape(shape, nlandmarks_g);
    if (shape.rows == 0)
        Err("Cannot convert to a %d point shape", nlandmarks_g);
    if (writeimgs_g)
        DrawShape(cimg, shape);
    if (multiface_g)
    {
        logprintf("face %d\n", nfaces);
        double xmin, xmax, ymin, ymax; // needed to position face nbr
        ShapeMinMax(xmin, xmax, ymin, ymax, shape);
        ImgPrintf(cimg,
                  (xmin + xmax)/2, ymin - (ymax-ymin)/50., 0xff0000, 1,
                 "%d", nfaces);
    }
    if (csv_g)
        LogShapeAsCsv(shape, imgpath);
    else
        LogShape(shape, imgpath);
}
Exemple #2
0
static void ProcessFace(
    const Image&     img,            // in
    const char*      imgpath,        // in
    int              foundface,      // in
    const Shape&     shape,          // in
    float            estyaw,         // in
    double           facedet_time,   // in
    double           asmsearch_time, // in
    const Shape&     refshape,       // in
    FILE*            fitfile,        // in
    const ShapeFile& sh,             // in
    int              ishape)         // in: shape index in the shapefile
{
    double meanfit = NOFIT; // fitness measure over all shapefile points
    int iworst = -1;        // worst fitting point in above measure of fitness
    double me17 = NOFIT;    // fitness measure me17
    double fm29 = NOFIT;    // fitness measure FM29 (only for 77 point shapes)
    int iworst_fm29 = -1;   // worst fitting point using FM29 measure
    if (!foundface)
        printf_g("no face ");
    else
    {
        if (trace_g)
            LogShape(shape, imgpath);
        // we will succesfully get the meanfit only if the shape can be converted to
        // the shapefile number of points (by ConvertShape in MeanFitOverInterEye)
        meanfit = MeanFitOverInterEye(iworst, shape, refshape);
        if (meanfit != NOFIT) // were able to get the mean fit?
            printf_g("meanfit %5.3f ", meanfit);
        // use fitness measure me17 if can convert the shape to a shape17
        me17 = Me17(shape, refshape);
        if (me17 != NOFIT) // were able to get the me17 fit?
            printf_g("me17 %5.3f ", me17);
        // get fitness measure fm29 if the shape has 77 points
        if (shape.rows == 77 && refshape.rows == 77)
        {
            Fm29(fm29, iworst_fm29, shape, refshape);
            printf_g("fm29 %5.3f ", fm29);
        }
        if (writeimgs_g) // -i flag
            WriteImgs(img, imgpath, shape, refshape,
                      meanfit, iworst, me17, fm29, iworst_fm29);
    }
    printf_g("\n");
    if (trace_g)
        lprintf("\n");
    const char* const base = Base(imgpath);
    const VEC pose(sh.Pose_(base));
    Fprintf(fitfile,
        "%-*s%s "
        "%7.5f % 6d "
        "%7.5f "
        "%7.5f     % 6d "
        "%8.2f %8.2f  ",
        sh.nchar_, base, " ",
        meanfit, iworst,
        me17,
        fm29, iworst_fm29,
        InterEyeDist(refshape), EyeMouthDist(refshape));
    Fprintf(fitfile,
        "% 5.0f "
        "% 6.0f % 6.0f % 6.0f %9.3f "
        "[%5.3f] [%5.3f]\n",
        estyaw,
        pose(0), pose(1), pose(2), pose(3),
        facedet_time, asmsearch_time);
}