hey @EnoxSoftware
i managed to accurately calculate the tilt of the head. by adding this function to the code.
it would be nice if you can add it to your documentation. i think it is quite useful.
it takes the two eye locations and calculates it from there.
///
/// calculate the head tilt by using the straight triangle rules: cos alpha = A / C
///
///
///
///
private float CalculateHeadTiltAngle(List _landmarks)
{
//take left eye and right eye from the face landmarks
Vector2 lefteye = _landmarks[36];
Vector2 righteye = _landmarks[45];
//identify the distance between the two points (one triangle line)
float C = Vector2.Distance(lefteye, righteye);
//identify the length of the second triangle line
float A = righteye.x - lefteye.x;
//convert the cos alpha to the angle. dont forget to convert to degrees from radians
float tilt = Mathf.Acos(A / C) * 57.2958f; //radians to degrees
//add direction of the tilt (minus or plus)
tilt = (lefteye.y < righteye.y) ? tilt * -1 : tilt;
Debug.Log(tilt);
return tilt;
}
hey @EnoxSoftware i managed to accurately calculate the tilt of the head. by adding this function to the code. it would be nice if you can add it to your documentation. i think it is quite useful. it takes the two eye locations and calculates it from there.
///
/// calculate the head tilt by using the straight triangle rules: cos alpha = A / C
///
///
///
///
private float CalculateHeadTiltAngle(List _landmarks)
{
//take left eye and right eye from the face landmarks
Vector2 lefteye = _landmarks[36];
Vector2 righteye = _landmarks[45];