Rekognition shim (Python)
A drop-in client that lets boto3 Rekognition code run against SightRadar with a two-line change, translating method names, arguments, scores and response shapes.
pip install sightradar-rekognition-shimThe shim mirrors Rekognition's method names and argument shapes and translates responses back into Rekognition-shaped dictionaries (FaceRecords, FaceMatches, Similarity, BoundingBox). Zero dependencies, pure standard library. It is Python only; other AWS SDKs have no shim.
The two-line change
import boto3
rek = boto3.client("rekognition", region_name="us-east-1")
rek.create_collection(CollectionId="event-2026")
rek.index_faces(
CollectionId="event-2026",
Image={"S3Object": {"Bucket": "my-bucket", "Name": "guest.jpg"}},
ExternalImageId="guest-1",
)
res = rek.search_faces_by_image(
CollectionId="event-2026",
Image={"Bytes": open("selfie.jpg", "rb").read()},
FaceMatchThreshold=90,
MaxFaces=5,
)
for m in res["FaceMatches"]:
print(m["Face"]["ExternalImageId"], m["Similarity"])The rest of your call sites stay the same. client() with no arguments reads SIGHTRADAR_API_KEY.
Mapped operations
| Rekognition method | SightRadar endpoint |
|---|---|
create_collection | POST /v1/collections |
delete_collection | DELETE /v1/collections/{id} |
list_collections | GET /v1/collections |
describe_collection | GET /v1/collections/{id} |
index_faces | POST /v1/collections/{id}/index |
search_faces_by_image | POST /v1/collections/{id}/search |
search_faces (by id) | POST /v1/collections/{id}/search-by-id |
detect_faces | POST /v1/detect |
compare_faces | POST /v1/compare |
Honest differences
- Score scale. Rekognition uses 0 to 100; SightRadar uses cosine similarity 0 to 1. The shim converts both ways:
FaceMatchThreshold=90becomes0.9, and a returnedSimilarityis scaled back to 0 to 100. The scale converts; the right operating point does not. Read choosing a threshold. - Bounding boxes. Rekognition returns ratio boxes; SightRadar returns absolute pixels. The shim surfaces the pixel box under
SightRadarBBoxand computes the ratioBoundingBoxonly when you pass image dimensions via_ImageSize=(w, h). - Image input.
Image={"Bytes": ...}is uploaded as multipart. The shim also accepts{"URL": ...}and{"GcsKey": ...}, and maps{"S3Object": {"Bucket", "Name"}}to a publichttps://<bucket>.s3.amazonaws.com/<name>URL, which must be fetchable. compare_facesaccepts URL and GcsKey images, not rawBytes, matching the/v1/comparecontract.- Unsupported operations (
detect_labels,detect_text,recognize_celebrities, video, user vectors, per-face delete) raiseNotImplementedErrornaming the limitation. They never silently no-op. - Nothing is lost. Every response includes a
SightRadarRawkey with the untranslated payload.
Errors
All transport and API failures raise SightRadarShimError with .message and .status_code.
Next
The migration guide covers re-indexing, dual-writing and cut-over.
Last updated