· 6 years ago · Oct 09, 2019, 11:22 AM
1def ask_rekognition_api_for_faces(bucket, key):
2
3 client = boto3.client("rekognition")
4 image = {"S3Object": {"Bucket": bucket, "Name": key}}
5
6 # Ask the API for faces in the photo
7 detected_faces = client.detect_faces(Image=image)["FaceDetails"]
8
9 # Filter on faces where Amazon Rekognition is certain enough that it found one
10 detected_faces = [face for face in detected_faces if face["Confidence"] >= 0.8]
11
12 # If there is at least one face left, return true
13 return True if detected_faces else False