mirror of
https://github.com/floci-io/floci.git
synced 2026-12-05 11:07:59 -05:00
* feat(rekognition): add Amazon Rekognition sync image-analysis actions Implements DetectLabels, DetectFaces, DetectText, CompareFaces, and DetectModerationLabels as fixed AWS-shaped stub responses over the real JSON 1.1 wire protocol (X-Amz-Target: RekognitionService.*). Image/SourceImage/TargetImage input is required and validated (must specify Bytes or S3Object) but never decoded, matching the pattern already used for Textract's Document input. Content-listing operations (DetectLabels, DetectText) always return one canned entry, matching TextractService's stub precedent. Face and moderation operations (DetectFaces, CompareFaces, DetectModerationLabels) return empty results by default rather than fabricating biometric attributes or a moderation flag for content that was never analyzed, matching ComprehendService's PII-detection precedent. Face-collection persistence, custom-model training, live video (StreamProcessor), async video jobs, and Face Liveness sessions are out of scope for this PR. Closes #2705 * fix(rekognition): reject wrong-typed Bytes/S3Object as SerializationException requireImage() only checked field presence via hasNonNull(), so a wrong-typed Bytes (e.g. a number) or S3Object (e.g. a string) was silently accepted instead of rejected, same class of bug as the Comprehend Text/LanguageCode type-coercion fix. Bytes must now be textual and S3Object must be an object when present, both rejected as SerializationException (a shape/marshalling mismatch) otherwise. Content-level validation (well-formed base64 in Bytes, S3Object's Bucket/Name presence, rejecting both Bytes and S3Object together) is intentionally not added: S3Object has no required members in AWS's own model, and nothing in the model declares supplying both fields invalid — documented as intentional deviations. Addresses review feedback on #2706.
3.7 KiB
3.7 KiB
Rekognition
Protocol: JSON 1.1 (X-Amz-Target: RekognitionService.*)
Endpoint: POST http://localhost:4566/
Supported Actions
| Action | Description |
|---|---|
DetectLabels |
Detect objects, scenes, and concepts in an image |
DetectFaces |
Detect faces in an image and their attributes |
DetectText |
Detect text in an image |
CompareFaces |
Compare a face in a source image with faces in a target image |
DetectModerationLabels |
Detect unsafe or inappropriate content in an image |
Emulation Behavior
- Stub responses: every action returns a fixed, AWS-shaped response — no real
image analysis is performed.
Image/SourceImage/TargetImagecontent is accepted but never decoded, the same way Textract acceptsDocumentwithout reading it. - Content-listing operations return one canned entry:
DetectLabelsandDetectTextalways report a single stub label/text detection, matching the Textract stub's block-hierarchy convention. - Face/moderation operations return empty results:
DetectFaces,CompareFaces, andDetectModerationLabelsalways report nothing found (emptyFaceDetails/FaceMatches/ModerationLabels) rather than fabricating biometric attributes or a moderation flag for content that was never analyzed — an honest "nothing detected" response, matching the Comprehend PII-detection stub's precedent. - Real input validation:
Image(orSourceImage/TargetImageforCompareFaces) is required, must be a JSON structure, and must specifyBytes(string-typed) orS3Object(structure-typed) — matching AWS's own modeling and rejecting wrong JSON types asSerializationException. This is protocol compatibility, not content analysis. - Intentional deviations:
Bytes's content is not validated as well-formed base64 (theS3Objectshape has no required members in AWS's own model, so its fields aren't validated either), and supplying bothBytesandS3Objectis accepted rather than rejected — nothing in the Rekognition API model declares that combination invalid, and the stub never reads either field's content regardless. - Out of scope: face-collection persistence (
CreateCollection,IndexFaces,SearchFaces), custom-model training (Projects,Datasets,ProjectVersions), live video (StreamProcessor), async video jobs (Start*/Get*Celebrity/Content/Face/Label/Person/Segment/Text detection), and Face Liveness sessions are not implemented.
Configuration
| Variable | Default | Description |
|---|---|---|
FLOCI_SERVICES_REKOGNITION_ENABLED |
true |
Enable or disable the service |
Examples
export AWS_ENDPOINT_URL=http://localhost:4566
aws rekognition detect-labels \
--image '{"S3Object":{"Bucket":"my-bucket","Name":"photo.jpg"}}' \
--endpoint-url $AWS_ENDPOINT_URL
aws rekognition detect-text \
--image '{"S3Object":{"Bucket":"my-bucket","Name":"photo.jpg"}}' \
--endpoint-url $AWS_ENDPOINT_URL
aws rekognition compare-faces \
--source-image '{"S3Object":{"Bucket":"my-bucket","Name":"source.jpg"}}' \
--target-image '{"S3Object":{"Bucket":"my-bucket","Name":"target.jpg"}}' \
--endpoint-url $AWS_ENDPOINT_URL
SDK Example (Java)
RekognitionClient rekognition = RekognitionClient.builder()
.endpointOverride(URI.create("http://localhost:4566"))
.region(Region.US_EAST_1)
.credentialsProvider(StaticCredentialsProvider.create(
AwsBasicCredentials.create("test", "test")))
.build();
DetectLabelsResponse response = rekognition.detectLabels(req -> req
.image(img -> img.s3Object(s3 -> s3.bucket("my-bucket").name("photo.jpg"))));
System.out.println("Labels: " + response.labels());