def lambda_handler()

in src/lambda/detection_function.py [0:0]


def lambda_handler(event, context):
    # Extract and transform
    camera_ID = event['camera_ID']
    alarm_ID = event['alarm_ID']
    encoded_img = event['img']
    timestamp = datetime.utcnow()

    # Check if equipment is present
    img = base64.b64decode(encoded_img)
    labels = detect_labels(img)
    compliant = is_compliant(labels)

    # Invoke alarm and notifications
    if not compliant:
        iot_publish(camera_ID, alarm_ID)
        invoke_notifications(camera_ID, timestamp, encoded_img, labels)

    return {
        'compliant': compliant,
        'labels': labels,
    }