SightRadardocs

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-shim

The 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 methodSightRadar endpoint
create_collectionPOST /v1/collections
delete_collectionDELETE /v1/collections/{id}
list_collectionsGET /v1/collections
describe_collectionGET /v1/collections/{id}
index_facesPOST /v1/collections/{id}/index
search_faces_by_imagePOST /v1/collections/{id}/search
search_faces (by id)POST /v1/collections/{id}/search-by-id
detect_facesPOST /v1/detect
compare_facesPOST /v1/compare

Honest differences

  • Score scale. Rekognition uses 0 to 100; SightRadar uses cosine similarity 0 to 1. The shim converts both ways: FaceMatchThreshold=90 becomes 0.9, and a returned Similarity is 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 SightRadarBBox and computes the ratio BoundingBox only 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 public https://<bucket>.s3.amazonaws.com/<name> URL, which must be fetchable.
  • compare_faces accepts URL and GcsKey images, not raw Bytes, matching the /v1/compare contract.
  • Unsupported operations (detect_labels, detect_text, recognize_celebrities, video, user vectors, per-face delete) raise NotImplementedError naming the limitation. They never silently no-op.
  • Nothing is lost. Every response includes a SightRadarRaw key 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

On this page