in packages/ekyc-api/src/ekyc-api/Utils/LivenessChecker.cs [354:398]
private async Task<string> VerifyNoseLocation(SessionObject session, Image imageToVerify,
FaceDetail headOnImage)
{
var nosePointingFaces = await GetFaces(session.nosePointImageKey);
if (nosePointingFaces.Count == 0)
return $"No faces found in the nose verification image for session {session.Id}";
// Get the largest face
var nosePointingFace = nosePointingFaces.OrderByDescending(a => a.BoundingBox.Width + a.BoundingBox.Height)
.FirstOrDefault();
var noseLocation = nosePointingFace.Landmarks.FirstOrDefault(a => a.Type == LandmarkType.Nose);
if (noseLocation == null)
return "Nose not found in image.";
// Check if it's in the bounds
if (noseLocation.X >= session.nosePointAreaLeft &&
noseLocation.X <= session.nosePointAreaLeft + Globals.NosePointAreaDimensions)
{
if (noseLocation.Y >= session.nosePointAreaTop &&
noseLocation.Y <= session.nosePointAreaTop + Globals.NosePointAreaDimensions)
{
// Check the yaw, pitch and roll of the face
var compareLandmarks = await CompareFacialLandmarks(session, nosePointingFace, headOnImage);
if (!compareLandmarks)
return
"Please do not move your shoulders while pointing your nose. Instead, tilt your head so that your nose fits within the bounds of the box.";
}
else
{
return "Nose is not within the specified bounds.";
}
}
else
{
return "Nose is not within the specified bounds.";
}
return null;
}