<reponame>vpangaldus/StepFunctionsRekognitionExp-001
import boto3 
import os
import json

# Boto3 clients
rekognition_client = boto3.client('rekognition')
s3_client = boto3.client('s3')

# Rekognition collection
collectionId = os.environ['REKOGNITION_COLLECTION_ID']

# The main handler of this lambda function
def lambda_handler(event, context):
    # Get information about the object uploaded to S3
    bucket = event['bucket']
    key = event['key']
    
    imageSearchParam = {'S3Object': {'Bucket': bucket, 'Name': key}}
    maxFacesSearchParam = 1
    faceMatchThresholdSearchParam = 88
    
    response = rekognition_client.search_faces_by_image(
                 CollectionId = collectionId,
                 Image = imageSearchParam,
                 MaxFaces = maxFacesSearchParam,
                 FaceMatchThreshold = faceMatchThresholdSearchParam
               )
               
    print(response)
    print(len(response['FaceMatches']))
               
    return {
        'bucket': bucket,
        'key': key,
        'num_face_matches': len(response['FaceMatches'])
    }
    
import boto3 
import os
import json

# Boto3 clients
rekognition_client = boto3.client('rekognition')
s3_client = boto3.client('s3')

# Rekognition collection
collectionId = os.environ['REKOGNITION_COLLECTION_ID']

# The main handler of this lambda function
def lambda_handler(event, context):
    # Get information about the object uploaded to S3
    bucket = event['bucket']
    key = event['key']
    
    imageSearchParam = {'S3Object': {'Bucket': bucket, 'Name': key}}
    maxFacesSearchParam = 1
    faceMatchThresholdSearchParam = 88
    
    response = rekognition_client.search_faces_by_image(
                 CollectionId = collectionId,
                 Image = imageSearchParam,
                 MaxFaces = maxFacesSearchParam,
                 FaceMatchThreshold = faceMatchThresholdSearchParam
               )
               
    print(response)
    print(len(response['FaceMatches']))
               
    return {
        'bucket': bucket,
        'key': key,
        'num_face_matches': len(response['FaceMatches'])
    }
# Boto3 clients # Rekognition collection # The main handler of this lambda function # Get information about the object uploaded to S3