/*
  Face.cpp
  
  Author: Sergi Diaz Planas (2017)
*/
#include "Face.h"

// Constructor.
Face::Face() {}

// Set eyes position.
void Face::setEyes(std::vector<cv::Point> eyes)
{
    this->eyes = eyes;
}

// Fill an input array with (x,y) position of the left eye found
// in this face image.
int* Face::getLeftEye(int left[])
{
    // Return input array without modifying it if it not matches
    // minimum size or if there are no eye positions loaded into
    // this instance
    if (sizeof(left) < 2 || this->eyes.size() < 2)
        return left;

    // Fill input array before returning.
    left[0] = this->eyes[0].x;
    left[1] = this->eyes[0].y;
    return left;
}

// Fill an input array with (x,y) position of the right eye found
// in this face image.
int* Face::getRightEye(int right[])
{
    // Return input array without modifying it if it not matches
    // minimum size or if there are no eye positions loaded into
    // this instance
    if (sizeof(right) < 2 || this->eyes.size() < 2)
        return right;

    // Fill input array before returning.
    right[0] = this->eyes[1].x;
    right[1] = this->eyes[1].y;
    return right;
}

// Return left eye's x-coordinate.
int Face::getLeftX()
{
    if (this->eyes.size() < 2)
        return -1;

    return this->eyes[0].x;
}

// Return left eye's y-coordinate.
int Face::getLeftY()
{
    if (this->eyes.size() < 2)
        return -1;

    return this->eyes[0].y;
}

// Return right eye's x-coordinate.
int Face::getRightX()
{
    if (this->eyes.size() < 2)
        return -1;

    return this->eyes[1].x;
}

// Return right eye's y-coordinate.
int Face::getRightY()
{
    if (this->eyes.size() < 2)
        return -1;

    return this->eyes[1].y;
}
