#include "../const.h"
#include "Init_para.h"
#include "Image.h"
#include "ProcessFace.h"   


// This method finds the face in the given image and localize its major features: mouth and eyes
bool
ProcessFace(int serialNumber, const Image& im_cr, const Image& im_cb, const Image& im_clust, const Init_para& parameters,
            Image& mouth, Image& eye_left, Image& eye_right, int*& face_bb, int*& face_centroid)
{

    bool result;
    Image im_skin;

    #ifdef FUNC_TRACK
    PRN(("Starting ProcessFace\n"));
    #endif

                                                // Looking for face...

    result = FindFace(im_clust, im_skin, face_bb, face_centroid, parameters, serialNumber);
    if (!result)
       return false;

                                                // Looking for mouth...

    result = FindMouth(face_bb, im_cb, im_cr, mouth, im_skin.width * im_skin.height, parameters, serialNumber);
    if (!result)
       return result;

                                                // Looking for eyes...

    result = FindEye(im_skin, mouth, eye_left, LEFT, parameters, serialNumber);
    if (!result)
       return false;
    result = FindEye(im_skin, mouth, eye_right, RIGHT, parameters, serialNumber);
    if (!result)
       return false;


    FreeImg(im_skin);

    #ifdef FUNC_TRACK
    PRN(("Ending ProcessFace\n"));
    #endif

    return true;

}


