Rekognition Face Detection and Matching
DynamoDB table schema and Lambda workflow for face detection, similarity matching, and person creation in Nomad Media.
The Nomad Media face detection pipeline uses Amazon Rekognition together with DynamoDB to detect faces in assets, cluster similar faces, and build a person identity model over time.
DynamoDB Tables
PersonFace
externalFaceId— String, Primary KeypersonId— String
Person
id— String, Primary Keyname— StringnamingPriority— Number, Sort KeyautomatchCount— NumberprobableMatchCount— Number
If
nameis defined,namingPrioritymust be set to0.
Face
externalFaceId— String, Primary Keyid— StringboundingBox— StringassetId— StringpreviewImageUrl— StringmatchType— StringpersonId— String
UnassignedFace
externalFaceId— String, Primary Keycount— Number, Sort Key
When a face is inserted into the Face table with no personId, it is also inserted into UnassignedFace with count = 0. Each time a face-to-face match is inserted into FaceFace, the count is incremented for both matched faces in UnassignedFace. When a person is created, their associated faces are removed from UnassignedFace and added to PersonFace.
Workflow
1. Rekognition Lambda
- Detects faces in the asset using Rekognition.
- Inserts each face into the Face table with an empty
personId. - Inserts each face into the UnassignedFace table with
count = 0.
2. Search Image Faces Lambda
- For each detected face, calls Rekognition to find similar faces.
- Loops through similar faces:
- Verifies both the original and similar face exist in the Face table; inserts if missing.
- If similarity exceeds
application/rekognitionSettings/probableMatchSimilarityThreshold:- Inserts into the FaceFace table.
- Increments
countin UnassignedFace for bothFaceIdandSimilarFaceId. - If the similar face already has a
personId, queues the original face for person ID assignment.
- For each face queued for person ID assignment:
- Updates
personIdandmatchTypein the Face table. - Removes from UnassignedFace.
- Updates
automatchCountandprobableMatchCountin the Person table. - Adds
externalFaceIdandpersonIdto the PersonFace table. - Sets
namingPriority=automatchCount + probableMatchCountifPerson.Nameis blank; sets to0ifPerson.Nameis populated.
- Updates
3. Create Persons Lambda
Runs on a scheduled basis (frequency TBD).
- Queries UnassignedFace for the face with the highest
count. - Queries FaceFace for all entries matching that
externalFaceId. - Creates a new Person with
namingPriority= number of FaceFace matches. - Updates the Face table for all matched faces to assign the new
personId. - Deletes matched faces from UnassignedFace.
- Inserts matched faces into PersonFace.
