Camel Components

AWS Rekognition

Since Camel 4.17

Only producer is supported

The AWS2 Rekognition component supports analyzing images (faces, labels, text, celebrities and protective equipment), managing face collections and users, and running media analysis jobs on AWS Rekognition. The operations are listed under Usage.

Prerequisites

You must have a valid Amazon Web Services developer account, and be signed up to use Amazon Rekognition. More information is available at AWS Rekognition.

URI Format

aws2-rekognition://label[?options]

You can append query options to the URI in the following format:

?options=value&option2=value&…​

Configuring Options

Camel components are configured on two separate levels:

  • component level

  • endpoint level

Configuring Component Options

At the component level, you set general and shared configurations that are, then, inherited by the endpoints. It is the highest configuration level.

For example, a component may have security settings, credentials for authentication, urls for network connection and so forth.

Some components only have a few options, and others may have many. Because components typically have pre-configured defaults that are commonly used, then you may often only need to configure a few options on a component; or none at all.

You can configure components using:

  • the Component DSL.

  • in a configuration file (application.properties, *.yaml files, etc).

  • directly in the Java code.

Configuring Endpoint Options

You usually spend more time setting up endpoints because they have many options. These options help you customize what you want the endpoint to do. The options are also categorized into whether the endpoint is used as a consumer (from), as a producer (to), or both.

Configuring endpoints is most often done directly in the endpoint URI as path and query parameters. You can also use the Endpoint DSL and DataFormat DSL as a type safe way of configuring endpoints and data formats in Java.

A good practice when configuring options is to use Property Placeholders.

Property placeholders provide a few benefits:

  • They help prevent using hardcoded urls, port numbers, sensitive information, and other settings.

  • They allow externalizing the configuration from the code.

  • They help the code to become more flexible and reusable.

The following two sections list all the options, firstly for the component followed by the endpoint.

Component Options

The AWS Rekognition component supports the following options which are listed below.

Name Description Default Type

configuration (producer)

Component configuration.

Rekognition2Configuration

lazyStartProducer (producer)

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

boolean

operation (producer)

Required The operation that the producer performs. The CamelAwsRekognitionOperation header replaces this option.

Enum values:

  • associateFaces

  • compareFaces

  • createCollection

  • createUser

  • deleteCollection

  • deleteFaces

  • deleteUser

  • describeCollection

  • detectFaces

  • detectLabels

  • detectModerationLabels

  • detectProtectiveEquipment

  • detectText

  • disassociateFaces

  • getCelebrityInfo

  • getMediaAnalysisJob

  • indexFaces

  • listCollections

  • listMediaAnalysisJobs

  • listFaces

  • listUsers

  • recognizeCelebrities

  • searchFaces

  • searchFacesByImage

  • searchUsers

  • searchUsersByImage

  • startMediaAnalysisJob

Rekognition2Operations

overrideEndpoint (producer)

Whether to send the requests to the URI of the uriEndpointOverride option instead of the endpoint of the region. It has no effect when uriEndpointOverride is not set.

false

boolean

pojoRequest (producer)

Whether the body is the request of the AWS SDK for the operation, such as a DetectLabelsRequest for detectLabels. If true, the producer sends that request as it is, without the headers, and a body of another type fails. If false, the producer builds the request from the headers and does not use the body.

false

boolean

profileCredentialsName (producer)

The name of the profile in the AWS shared credentials and config files, used when useProfileCredentialsProvider is true. If not set, the AWS SDK uses its default profile, which the AWS_PROFILE environment variable can change.

String

region (producer)

The AWS region of Amazon Rekognition, as a region ID such as eu-west-1, which is the value of Region.EU_WEST_1.id(). If not set, the default region provider chain of the AWS SDK is used. Amazon Rekognition is not available in every region.

Enum values:

  • ap-south-2

  • ap-south-1

  • eu-south-1

  • eu-south-2

  • us-gov-east-1

  • me-central-1

  • il-central-1

  • ca-central-1

  • eu-central-1

  • us-iso-west-1

  • eu-central-2

  • eu-isoe-west-1

  • us-west-1

  • us-west-2

  • af-south-1

  • eu-north-1

  • eu-west-3

  • eu-west-2

  • eu-west-1

  • ap-northeast-3

  • ap-northeast-2

  • ap-northeast-1

  • me-south-1

  • sa-east-1

  • ap-east-1

  • cn-north-1

  • ca-west-1

  • us-gov-west-1

  • ap-southeast-1

  • ap-southeast-2

  • us-iso-east-1

  • ap-southeast-3

  • ap-southeast-4

  • us-east-1

  • us-east-2

  • cn-northwest-1

  • us-isob-east-1

  • aws-global

  • aws-cn-global

  • aws-us-gov-global

  • aws-iso-global

  • aws-iso-b-global

String

trustAllCertificates (producer)

Whether the HTTP client of Amazon Rekognition trusts every TLS certificate without checking it. It applies to any endpoint, not only to an overridden one, so use it only for testing, for example against a local emulator.

false

boolean

uriEndpointOverride (producer)

The URI of the endpoint to use instead of the endpoint of the region, for example http://localhost:4566 for a local emulator. It is used only when overrideEndpoint is true.

String

useDefaultCredentialsProvider (producer)

Whether to load the credentials with the default credentials provider chain of the AWS SDK, which looks in system properties, environment variables, the shared credentials and config files, and the container or instance role. It takes precedence over the other credentials options.

false

boolean

useProfileCredentialsProvider (producer)

Whether to load the credentials from a profile of the AWS shared credentials and config files, the one of the profileCredentialsName option. It is not used when useDefaultCredentialsProvider is true, and it takes precedence over the session and static credentials.

false

boolean

autowiredEnabled (advanced)

Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc.

true

boolean

awsRekognitionClient (advanced)

Autowired To use a custom software.amazon.awssdk.services.rekognition.RekognitionClient, which is autowired when the registry has a single one. When this option is set, the credentials, region, proxy, endpoint override and trustAllCertificates options are not used. The endpoint does not close a client that is set or autowired.

RekognitionClient

healthCheckConsumerEnabled (health)

Used for enabling or disabling all consumer based health checks from this component.

true

boolean

healthCheckProducerEnabled (health)

Used for enabling or disabling all producer based health checks from this component. Notice: Camel has by default disabled all producer based health-checks. You can turn on producer checks globally by setting camel.health.producersEnabled=true.

true

boolean

proxyHost (proxy)

The host name of the proxy that the HTTP client of Amazon Rekognition connects through. The proxy is used only when the proxyPort option is set too.

String

proxyPort (proxy)

The port of the proxy that the HTTP client of Amazon Rekognition connects through. The proxy is used only when the proxyHost option is set too.

Integer

proxyProtocol (proxy)

The protocol that the HTTP client of Amazon Rekognition uses to connect to the proxy. It is used only when the proxyHost and proxyPort options are set.

Enum values:

  • HTTP

  • HTTPS

HTTPS

Protocol

accessKey (security)

The access key ID of the AWS credentials, used together with the secretKey option. The endpoint requires it, unless awsRekognitionClient is set or useDefaultCredentialsProvider or useProfileCredentialsProvider is true. It is also required when useSessionCredentials is true.

String

secretKey (security)

The secret access key of the AWS credentials, used together with the accessKey option. The endpoint requires it, unless awsRekognitionClient is set or useDefaultCredentialsProvider or useProfileCredentialsProvider is true. It is also required when useSessionCredentials is true.

String

sessionToken (security)

The session token of temporary AWS credentials, for example of an assumed IAM role. It is used only when useSessionCredentials is true, together with the accessKey and secretKey options. All three are then required: if one of the three is missing, creating the client fails.

String

useSessionCredentials (security)

Whether to use temporary credentials made of the accessKey, secretKey and sessionToken options, for example those of an assumed IAM role. It is not used when useDefaultCredentialsProvider or useProfileCredentialsProvider is true.

false

boolean

Endpoint Options

The AWS Rekognition endpoint is configured using URI syntax:

aws2-rekognition:label

With the following path and query parameters:

Path Parameters

Name Description Default Type

label (producer)

Required A logical name of the endpoint, which you choose freely. The producer does not use it: the operation and its input are given by the options and the headers.

String

Query Parameters

Name Description Default Type

operation (producer)

Required The operation that the producer performs. The CamelAwsRekognitionOperation header replaces this option.

Enum values:

  • associateFaces

  • compareFaces

  • createCollection

  • createUser

  • deleteCollection

  • deleteFaces

  • deleteUser

  • describeCollection

  • detectFaces

  • detectLabels

  • detectModerationLabels

  • detectProtectiveEquipment

  • detectText

  • disassociateFaces

  • getCelebrityInfo

  • getMediaAnalysisJob

  • indexFaces

  • listCollections

  • listMediaAnalysisJobs

  • listFaces

  • listUsers

  • recognizeCelebrities

  • searchFaces

  • searchFacesByImage

  • searchUsers

  • searchUsersByImage

  • startMediaAnalysisJob

Rekognition2Operations

overrideEndpoint (producer)

Whether to send the requests to the URI of the uriEndpointOverride option instead of the endpoint of the region. It has no effect when uriEndpointOverride is not set.

false

boolean

pojoRequest (producer)

Whether the body is the request of the AWS SDK for the operation, such as a DetectLabelsRequest for detectLabels. If true, the producer sends that request as it is, without the headers, and a body of another type fails. If false, the producer builds the request from the headers and does not use the body.

false

boolean

profileCredentialsName (producer)

The name of the profile in the AWS shared credentials and config files, used when useProfileCredentialsProvider is true. If not set, the AWS SDK uses its default profile, which the AWS_PROFILE environment variable can change.

String

region (producer)

The AWS region of Amazon Rekognition, as a region ID such as eu-west-1, which is the value of Region.EU_WEST_1.id(). If not set, the default region provider chain of the AWS SDK is used. Amazon Rekognition is not available in every region.

Enum values:

  • ap-south-2

  • ap-south-1

  • eu-south-1

  • eu-south-2

  • us-gov-east-1

  • me-central-1

  • il-central-1

  • ca-central-1

  • eu-central-1

  • us-iso-west-1

  • eu-central-2

  • eu-isoe-west-1

  • us-west-1

  • us-west-2

  • af-south-1

  • eu-north-1

  • eu-west-3

  • eu-west-2

  • eu-west-1

  • ap-northeast-3

  • ap-northeast-2

  • ap-northeast-1

  • me-south-1

  • sa-east-1

  • ap-east-1

  • cn-north-1

  • ca-west-1

  • us-gov-west-1

  • ap-southeast-1

  • ap-southeast-2

  • us-iso-east-1

  • ap-southeast-3

  • ap-southeast-4

  • us-east-1

  • us-east-2

  • cn-northwest-1

  • us-isob-east-1

  • aws-global

  • aws-cn-global

  • aws-us-gov-global

  • aws-iso-global

  • aws-iso-b-global

String

trustAllCertificates (producer)

Whether the HTTP client of Amazon Rekognition trusts every TLS certificate without checking it. It applies to any endpoint, not only to an overridden one, so use it only for testing, for example against a local emulator.

false

boolean

uriEndpointOverride (producer)

The URI of the endpoint to use instead of the endpoint of the region, for example http://localhost:4566 for a local emulator. It is used only when overrideEndpoint is true.

String

useDefaultCredentialsProvider (producer)

Whether to load the credentials with the default credentials provider chain of the AWS SDK, which looks in system properties, environment variables, the shared credentials and config files, and the container or instance role. It takes precedence over the other credentials options.

false

boolean

useProfileCredentialsProvider (producer)

Whether to load the credentials from a profile of the AWS shared credentials and config files, the one of the profileCredentialsName option. It is not used when useDefaultCredentialsProvider is true, and it takes precedence over the session and static credentials.

false

boolean

lazyStartProducer (producer (advanced))

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

boolean

awsRekognitionClient (advanced)

Autowired To use a custom software.amazon.awssdk.services.rekognition.RekognitionClient, which is autowired when the registry has a single one. When this option is set, the credentials, region, proxy, endpoint override and trustAllCertificates options are not used. The endpoint does not close a client that is set or autowired.

RekognitionClient

proxyHost (proxy)

The host name of the proxy that the HTTP client of Amazon Rekognition connects through. The proxy is used only when the proxyPort option is set too.

String

proxyPort (proxy)

The port of the proxy that the HTTP client of Amazon Rekognition connects through. The proxy is used only when the proxyHost option is set too.

Integer

proxyProtocol (proxy)

The protocol that the HTTP client of Amazon Rekognition uses to connect to the proxy. It is used only when the proxyHost and proxyPort options are set.

Enum values:

  • HTTP

  • HTTPS

HTTPS

Protocol

accessKey (security)

The access key ID of the AWS credentials, used together with the secretKey option. The endpoint requires it, unless awsRekognitionClient is set or useDefaultCredentialsProvider or useProfileCredentialsProvider is true. It is also required when useSessionCredentials is true.

String

secretKey (security)

The secret access key of the AWS credentials, used together with the accessKey option. The endpoint requires it, unless awsRekognitionClient is set or useDefaultCredentialsProvider or useProfileCredentialsProvider is true. It is also required when useSessionCredentials is true.

String

sessionToken (security)

The session token of temporary AWS credentials, for example of an assumed IAM role. It is used only when useSessionCredentials is true, together with the accessKey and secretKey options. All three are then required: if one of the three is missing, creating the client fails.

String

useSessionCredentials (security)

Whether to use temporary credentials made of the accessKey, secretKey and sessionToken options, for example those of an assumed IAM role. It is not used when useDefaultCredentialsProvider or useProfileCredentialsProvider is true.

false

boolean

Message Headers

The AWS Rekognition component supports the following message header(s), which is/are listed below:

Name Description Default Type

CamelAwsRekognitionOperation (producer)

Constant: OPERATION

The operation that the producer performs, which replaces the operation option. The value is the name of the operation, such as detectLabels.

String

CamelAwsRekognitionCollectionId (producer)

Constant: COLLECTION_ID

The ID of the face collection that the operation works on: the collection to create, delete or describe, or the collection of the faces and users of indexFaces, listFaces, deleteFaces, searchFaces, searchFacesByImage, createUser, deleteUser, listUsers, associateFaces, disassociateFaces, searchUsers and searchUsersByImage.

String

CamelAwsRekognitionUserId (producer)

Constant: USER_ID

The ID of the user in the collection: the user to create or delete, or the user that associateFaces and disassociateFaces associate the faces with or disassociate them from. listFaces returns only the faces of this user, and searchUsers searches for the users that match this user. searchUsers takes either this header or CamelAwsRekognitionFaceId.

String

CamelAwsRekognitionFaceIds (producer)

Constant: FACE_IDS

The IDs of the faces in the collection, as a collection of String: the faces that associateFaces associates with the user (up to 100), that disassociateFaces disassociates from it, or that deleteFaces deletes. listFaces returns only these faces.

Collection

CamelAwsRekognitionUserMatchThreshold (producer)

Constant: USER_MATCH_THRESHOLD

The minimum confidence of the match between a face and a user, in percent from 0 to 100. associateFaces does not associate a face whose match with a user that has faces already is of lower confidence (default 75), and searchUsers and searchUsersByImage do not return the users whose match is of lower confidence (default 80).

Float

CamelAwsRekognitionClientRequestToken (producer)

Constant: CLIENT_REQUEST_TOKEN

Idempotency token of the request: a retry of associateFaces, createUser, deleteUser, disassociateFaces or startMediaAnalysisJob with the same token is not processed again.

String

CamelAwsRekognitionSourceImage (producer)

Constant: SOURCE_IMAGE

The source image of compareFaces, as an Image of the AWS SDK with the bytes or the Amazon S3 object of a JPEG or PNG image. Its largest face is compared with the faces of the target image.

Image

CamelAwsRekognitionTargetImage (producer)

Constant: TARGET_IMAGE

The target image of compareFaces, as an Image of the AWS SDK with the bytes or the Amazon S3 object of a JPEG or PNG image. Its faces, up to the 100 largest, are compared with the face of the source image.

Image

CamelAwsRekognitionSimilarityThreshold (producer)

Constant: SIMILARITY_THRESHOLD

The minimum similarity, in percent, of the faces that compareFaces returns as matches. If not set, Amazon Rekognition uses 80.

Float

CamelAwsRekognitionQualityFilter (producer)

Constant: QUALITY_FILTER

How strictly compareFaces, indexFaces, searchFacesByImage and searchUsersByImage filter out the detected faces of low quality before they use them: NONE, AUTO (Amazon Rekognition chooses), LOW, MEDIUM or HIGH. The default is AUTO for indexFaces and NONE for the others. A filter other than NONE needs a collection of face model version 3 or later.

String

CamelAwsRekognitionImage (producer)

Constant: IMAGE

The image that detectFaces, detectLabels, detectModerationLabels, detectProtectiveEquipment, detectText, indexFaces, recognizeCelebrities, searchFacesByImage and searchUsersByImage analyze, as an Image of the AWS SDK with the bytes or the Amazon S3 object of a JPEG or PNG image. A byte array in this header is not used, and neither is the body.

Image

CamelAwsRekognitionFacialAttributes (producer)

Constant: FACIAL_ATTRIBUTES

The facial attributes that detectFaces returns besides the default ones (bounding box, confidence, pose, quality and landmarks): a collection or array of attribute names, such as FACE_OCCLUDED, EMOTIONS or ALL, or of Attribute values of the AWS SDK, or a comma separated String of names.

Collection

CamelAwsRekognitionMaxLabels (producer)

Constant: MAX_LABELS

The maximum number of labels that detectLabels returns, the ones of the highest confidence. If not set, Amazon Rekognition returns up to 1000. It is used only with the GENERAL_LABELS feature.

Integer

CamelAwsRekognitionMinConfidence (producer)

Constant: MIN_CONFIDENCE

The minimum confidence, in percent, of the labels that detectLabels and detectModerationLabels return. If not set, detectLabels returns the labels of at least 55 and detectModerationLabels those of at least 50. detectLabels uses it only with the GENERAL_LABELS feature.

Float

CamelAwsRekognitionFeatures (producer)

Constant: FEATURES

The types of analysis that detectLabels performs, as a collection of DetectLabelsFeatureName values of the AWS SDK: GENERAL_LABELS for the labels of the objects, scenes and concepts, and IMAGE_PROPERTIES for the quality and the colors of the image. If not set, Amazon Rekognition uses GENERAL_LABELS.

Collection

CamelAwsRekognitionDetectLabelsSettings (producer)

Constant: DETECT_LABELS_SETTINGS

The filters of detectLabels, as a DetectLabelsSettings of the AWS SDK: the labels or label categories to include or exclude for GENERAL_LABELS, and the maximum number of dominant colors for IMAGE_PROPERTIES.

DetectLabelsSettings

CamelAwsRekognitionHumanLoopConfig (producer)

Constant: HUMAN_LOOP_CONFIG

The human review of the image by detectModerationLabels, as a HumanLoopConfig of the AWS SDK with the name of the human loop and the ARN of the flow definition, created with the CreateFlowDefinition operation of Amazon SageMaker.

HumanLoopConfig

CamelAwsRekognitionProjectVersion (producer)

Constant: PROJECT_VERSION

The ARN of the project version of the custom adapter that detectModerationLabels uses, which the CreateProject and CreateProjectVersion operations of Amazon Rekognition create.

String

CamelAwsRekognitionProtectiveEquipmentSummarizationAttributes (producer)

Constant: PROTECTIVE_EQUIPMENT_SUMMARIZATION_ATTRIBUTES

The summary that detectProtectiveEquipment returns, as a ProtectiveEquipmentSummarizationAttributes of the AWS SDK: the minimum confidence and the types of protective equipment (FACE_COVER, HAND_COVER, HEAD_COVER) that a person must wear. If not set, the response has no summary.

ProtectiveEquipmentSummarizationAttributes

CamelAwsRekognitionWordFilter (producer)

Constant: WORD_FILTER

The filters of detectText, as a DetectTextFilters of the AWS SDK: the minimum confidence and bounding box size of the words to return, and the regions of the image to look in.

DetectTextFilters

CamelAwsRekognitionCelebrityId (producer)

Constant: CELEBRITY_ID

The ID of the celebrity that getCelebrityInfo returns the name and links of, as returned by recognizeCelebrities.

String

CamelAwsRekognitionJobId (producer)

Constant: JOB_ID

The ID of the media analysis job that getMediaAnalysisJob returns, as returned by startMediaAnalysisJob.

String

CamelAwsRekognitionJobName (producer)

Constant: JOB_NAME

The name of the media analysis job that startMediaAnalysisJob starts. It does not have to be unique.

String

CamelAwsRekognitionInput (producer)

Constant: INPUT

The input of startMediaAnalysisJob, as a MediaAnalysisInput of the AWS SDK with the Amazon S3 object of the manifest file that lists the images to analyze.

MediaAnalysisInput

CamelAwsRekognitionOutputConfig (producer)

Constant: OUTPUT_CONFIG

Where startMediaAnalysisJob stores the results, as a MediaAnalysisOutputConfig of the AWS SDK with the Amazon S3 bucket and key prefix.

MediaAnalysisOutputConfig

CamelAwsRekognitionOperationsConfig (producer)

Constant: OPERATIONS_CONFIG

What startMediaAnalysisJob does, as a MediaAnalysisOperationsConfig of the AWS SDK, which holds the configuration of the detectModerationLabels analysis.

MediaAnalysisOperationsConfig

CamelAwsRekognitionKmsKeyId (producer)

Constant: KMS_KEY_ID

The name or ARN of the customer managed AWS KMS key that encrypts the images that startMediaAnalysisJob copies and the results it writes to Amazon S3.

String

CamelAwsRekognitionExternalImageId (producer)

Constant: EXTERNAL_IMAGE_ID

An ID of your choice that indexFaces assigns to all the faces it detects in the image, for example the name of the image file. listFaces returns it with each face.

String

CamelAwsRekognitionDetectionAttributes (producer)

Constant: DETECTION_ATTRIBUTES

The facial attributes that indexFaces returns besides the default ones (bounding box, confidence, pose, quality and landmarks): a collection or array of attribute names, such as FACE_OCCLUDED, EMOTIONS or ALL, or of Attribute values of the AWS SDK, or a comma separated String of names.

Collection

CamelAwsRekognitionMaxFaces (producer)

Constant: MAX_FACES

The maximum number of faces: the faces that indexFaces indexes (at least 1, and it indexes at most 100 even if this is larger; the faces of the lowest quality and then the smallest are left out first), or the matching faces of the highest confidence that searchFaces and searchFacesByImage return.

Integer

CamelAwsRekognitionMaxResults (producer)

Constant: MAX_RESULTS

The maximum number of results that listCollections, listFaces, listUsers and listMediaAnalysisJobs return in one response. Use CamelAwsRekognitionNextToken to get the next results.

Integer

CamelAwsRekognitionNextToken (producer)

Constant: NEXT_TOKEN

The NextToken of the previous response of listCollections, listFaces, listUsers or listMediaAnalysisJobs, to get the next results.

String

CamelAwsRekognitionFaceId (producer)

Constant: FACE_ID

The ID of a face in the collection, as returned by indexFaces: searchFaces searches for the faces that match it, and searchUsers for the users that match it. searchUsers takes either this header or CamelAwsRekognitionUserId.

String

CamelAwsRekognitionFaceMatchThreshold (producer)

Constant: FACE_MATCH_THRESHOLD

The minimum confidence, in percent, of the matching faces that searchFaces and searchFacesByImage return. If not set, Amazon Rekognition uses 80.

Float

CamelAwsRekognitionMaxUsers (producer)

Constant: MAX_USERS

The maximum number of matching users that searchUsers and searchUsersByImage return.

Integer

Message Body

The message body at each side of the AWS Rekognition component: Consumer is the body of the messages the consumer creates, Consumer reply the bodies a consumer that answers its caller can reply with, Producer input the bodies the producer can send or write, and Producer output the body after the producer.

Side Body Description

Producer input

any

Not used, not even for the picture: the image comes from the CamelAwsRekognitionImage header, and for compareFaces from the CamelAwsRekognitionSourceImage and CamelAwsRekognitionTargetImage headers, as an Image of the AWS SDK with the bytes or the S3 object of a JPEG or PNG; bytes in these headers are not used. The other inputs come from headers too, such as CamelAwsRekognitionCollectionId. With pojoRequest=true the request of the AWS SDK for the operation, such as a DetectLabelsRequest: another body fails.

  • With pojoRequest=true: pojo

Producer output

pojo

The response of the AWS SDK for the operation, such as the DetectLabelsResponse of detectLabels, whose labels hold the names and the confidence of what the image shows.

The bodies are the ones with the default options. A side that is not listed is not known, and tooling does not guess it. The carriers, the sides and the tools that use them are described in Message Body Types.

Required Rekognition component options

You have to provide the awsRekognitionClient in the Camel Registry or your accessKey and secretKey to access the AWS Rekognition service.

Usage

Static credentials, Default Credential Provider and Profile Credentials Provider

You have the possibility of avoiding the usage of explicit static credentials by specifying the useDefaultCredentialsProvider option and set it to true.

The order of evaluation for Default Credentials Provider is the following:

  • Java system properties - aws.accessKeyId and aws.secretKey.

  • Environment variables - AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.

  • Web Identity Token from AWS STS.

  • The shared credentials and config files.

  • Amazon ECS container credentials - loaded from the Amazon ECS if the environment variable AWS_CONTAINER_CREDENTIALS_RELATIVE_URI is set.

  • Amazon EC2 Instance profile credentials.

You have also the possibility of using Profile Credentials Provider, by specifying the useProfileCredentialsProvider option to true and profileCredentialsName to the profile name.

Only one of static, default and profile credentials could be used at the same time.

For more information about this you can look at AWS credentials documentation

Rekognition Producer operations

Camel-AWS Rekognition component provides the following operation on the producer side:

  • associateFaces

  • compareFaces

  • createCollection

  • createUser

  • deleteCollection

  • deleteFaces

  • deleteUser

  • describeCollection

  • detectFaces

  • detectLabels

  • detectModerationLabels

  • detectProtectiveEquipment

  • detectText

  • disassociateFaces

  • getCelebrityInfo

  • getMediaAnalysisJob

  • indexFaces

  • listCollections

  • listMediaAnalysisJobs

  • listFaces

  • listUsers

  • recognizeCelebrities

  • searchFaces

  • searchFacesByImage

  • searchUsers

  • searchUsersByImage

  • startMediaAnalysisJob

The input image

The operations that analyze an image (detectFaces, detectLabels, detectModerationLabels, detectProtectiveEquipment, detectText, indexFaces, recognizeCelebrities, searchFacesByImage and searchUsersByImage) read the image from the CamelAwsRekognitionImage header, which holds an software.amazon.awssdk.services.rekognition.model.Image of the AWS SDK. The compareFaces operation reads the two images from the CamelAwsRekognitionSourceImage and CamelAwsRekognitionTargetImage headers, which hold an Image as well.

An Image holds either the bytes of the image or the location of an object in Amazon S3. The message body is not used as the image, and neither is a byte array in the image header: build the Image from it.

Java-only: building the Image from the bytes in the message body
from("direct:detectFaces")
    .process(exchange -> {
        byte[] bytes = exchange.getMessage().getBody(byte[].class);
        Image image = Image.builder().bytes(SdkBytes.fromByteArray(bytes)).build();
        exchange.getMessage().setHeader(Rekognition2Constants.IMAGE, image);
    })
    .to("aws2-rekognition://test?awsRekognitionClient=#awsRekognitionClient&operation=detectFaces");

An image stored in Amazon S3 is given as Image.builder().s3Object(S3Object.builder().bucket("my-bucket").name("photo.jpg").build()).build().

The CamelAwsRekognitionFacialAttributes header of detectFaces and the CamelAwsRekognitionDetectionAttributes header of indexFaces hold the names of the facial attributes to return, such as DEFAULT or ALL, as a collection of Strings (or of Attribute values of the AWS SDK), or as a comma separated String.

Examples

Producer Examples

  • createCollection: this operation will create a collection with the id of the CamelAwsRekognitionCollectionId header

  • Java

  • XML

  • YAML

from("direct:createCollection")
    .setHeader(Rekognition2Constants.COLLECTION_ID, constant("my-collection"))
    .to("aws2-rekognition://test?awsRekognitionClient=#awsRekognitionClient&operation=createCollection");
<route>
  <from uri="direct:createCollection"/>
  <setHeader name="CamelAwsRekognitionCollectionId">
    <constant>my-collection</constant>
  </setHeader>
  <to uri="aws2-rekognition://test?awsRekognitionClient=#awsRekognitionClient&amp;operation=createCollection"/>
</route>
- route:
    from:
      uri: direct:createCollection
      steps:
        - setHeader:
            name: CamelAwsRekognitionCollectionId
            expression:
              constant:
                expression: my-collection
        - to:
            uri: aws2-rekognition://test
            parameters:
              awsRekognitionClient: "#awsRekognitionClient"
              operation: createCollection

Using a POJO as body

Sometimes building an AWS Request can be complex because of multiple options. We introduce the possibility to use a POJO as the body. In AWS Rekognition, there are multiple operations you can submit, as an example for Create Collection request, you can do something like:

Java-only: using a POJO request body with the AWS SDK builder
from("direct:start")
  .setBody(CreateCollectionRequest.builder().collectionId("test-collection").build())
  .to("aws2-rekognition://test?awsRekognitionClient=#awsRekognitionClient&operation=createCollection&pojoRequest=true")

In this way, you’ll pass the request directly without the need of passing headers and options specifically related to this operation.

Dependencies

Maven users will need to add the following dependency to their pom.xml.

pom.xml

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-aws2-rekognition</artifactId>
    <version>${camel-version}</version>
</dependency>

where ${camel-version} must be replaced by the actual version of Camel.