Quickly and easily process your images that are in your S3 bucket throughAmazon Rekognition.
This example provides two programs:
- a scanner that finds all the images you'd like to process, and adds them toSQS(Simple Queue Service)
- a processor to run those images through Rekognition for label analysis, and saves those results toDynamoDB.
You can run these commands locally and drive a high throughput of image analysis, as this program is executing the processing and network transfers within AWS.
The examples can be run from the command line or by incorporating into your existing codebase. You can modify the code to run different image analysis, or to add different downstream processing (like writing to RDS, Elastic Search, or your on-premise DBs).
You should feel free to extend the code in these examples to meet your needs.
The scanner can be run in parallel to the processor; the processor monitors SQS and starts executing as soon as it sees jobs hit the queue.
$java-jars3batch.jar-scan
usage:scanner-bucket<arg>[-filter <arg>] [-help] [-max <arg>] [-prefix <arg>] [-profile <arg>]-queue<arg>
-bucket<arg>S3BucketName
-filter<arg>KeyFilterRegex.Default'\.(jpg|jpeg|png)$'
-helpGetthishelp.
-max<arg>Maxnumberofimagestoaddtoqueue.
-prefix<arg>S3BucketPrefix
-profile<arg>AWSCredentialProfileName(in~/.aws/credentials).
Default'default'
-queue<arg>SQSQueuetopopulate.Willcreateifitdoesn'texit.
$java-jars3batch.jar-process
usage:scanner[-cloudsearch <arg>] [-concurrency <arg>]
[-confidence <arg>] [-disablecerts] [-dynamo <arg>] [-endpoint <arg>] [-help]
[-max <arg>] [-profile <arg>]-queue<arg>
-cloudsearch<arg>CloudSearchindextooptionallyinsertinto.
-concurrency<arg>NumberofconcurrentRekognitionjobs.Default20
-confidence<arg>Minimumconfidenceinlabels.Default70.
-disablecertsDisablecertificatechecking.
-dynamo<arg>DynamoDBtabletooptionallyinsertinto.
-endpoint<arg>OverridetheRekognitionendpoint.
-helpGetthishelp.
-max<arg>Maxnumberofimagestoindex.
-profile<arg>AWSCredentialProfileName(in~/.aws/credentials).
Default'default'
-queue<arg>SQSQueuetofetchtasksfrom.
-tagprefix<arg>S3labeltagprefix.Default'rek.'
-tagS3WritedetectedlabelsbacktoS3asObjectTags.