in src/rekognition/detect-faces/handler.py [0:0]
def function_main(event:Mapping[str,Any], _=None):
'''
Convert the input into a Amazon Rekognition call...
'''
response = detect_faces(event['Image'])
'''
Confirm the face is usable...
'''
valid_faces = [face for face in response['FaceDetails'] if face['Confidence'] > 90]
if len(valid_faces) == 0:
raise NoFacesDetectedException()
elif len(valid_faces) > 1:
raise TooManyFacesDetectedException()
user_face = valid_faces[0]
'''
Confirm the face position is within range
Each pose dimension is between -180 to 180 degress
'''
pose = user_face['Pose']
for dimension in ['Pitch','Roll','Yaw']:
if not valid_pose_value(pose[dimension]):
raise InvalidPoseDetectedException(dimension)
'''
Do not permit users to wear sunglasses
'''
if user_face['Sunglasses']['Value']:
raise SunglassesDetectedException()
'''
Return the valid faces...
'''
return {
'FaceDetails': user_face
}