This commit is contained in:
2022-08-22 09:10:19 -07:00
parent f72fcee1db
commit bc2174b17a
150 changed files with 4323 additions and 6259 deletions

View File

@ -89,11 +89,40 @@ internal abstract class Face
a = y2 - y1;
double c = Math.Sqrt(Math.Pow(a, 2) + Math.Pow(b, 2));
if (y1 < y2)
result = (180 / Math.PI) * Math.Asin(a / c);
result = 180 / Math.PI * Math.Asin(a / c);
else
result = (180 / Math.PI) * Math.Asin(a / c) * -1;
result = 180 / Math.PI * Math.Asin(a / c) * -1;
}
return result;
}
internal static double? Getα(Dictionary<FacePart, Models.FacePoint[]> faceParts)
{
double? result;
int? leftEyeX = null;
int? leftEyeY = null;
int? rightEyeX = null;
int? rightEyeY = null;
foreach ((FacePart facePart, Models.FacePoint[] facePoints) in faceParts)
{
if (facePart is not FacePart.LeftEye and not FacePart.RightEye)
continue;
if (facePart is FacePart.LeftEye)
{
leftEyeX = (int)(from l in facePoints select l.X).Average();
leftEyeY = (int)(from l in facePoints select l.Y).Average();
}
if (facePart is FacePart.RightEye)
{
rightEyeX = (int)(from l in facePoints select l.X).Average();
rightEyeY = (int)(from l in facePoints select l.Y).Average();
}
}
if (rightEyeX is null || leftEyeX is null || rightEyeY is null || leftEyeY is null)
result = null;
else
result = Getα(rightEyeX.Value, leftEyeX.Value, rightEyeY.Value, leftEyeY.Value);
return result;
}
}