in src/lambda/notification_function.py [0:0]
def lambda_handler(event, context):
# Extract and transform
camera_ID = event['camera_ID']
img = base64.b64decode(event['img'])
labels = event['labels']
timestamp = datetime.fromisoformat(event['timestamp'])
base_key = build_filename(timestamp, camera_ID)
# Annotate and upload image
buffer = annotate_img(img, labels)
s3_path = upload_img_to_s3(buffer, base_key)
# Send SNS notification
send_notification(timestamp, camera_ID, s3_path)
# Upload csv file
response = ','.join([timestamp.date().isoformat(),
timestamp.time().isoformat(timespec='seconds'),
camera_ID,
str(len(labels['Person']['Instances'])),
str(len(labels['Helmet']['Instances']))])
upload_response_to_s3(response, base_key)
return {
'statusCode': 200,
'body': base_key
}