Skip to content

Rekognition

๐Ÿง  What is Amazon Rekognition?

Amazon Rekognition is a fully managed computer vision service that enables you to extract information from images and videos using pre-trained deep learning models.

โœ… It supports facial analysis, object detection, celebrity recognition, text detection (OCR), content moderation, and custom labels โ€” all without needing to build and train your own ML model.


๐Ÿงฐ Key Use Cases

Use Case Rekognition Feature
๐Ÿ‘๏ธ Face detection & analysis Detect faces, emotions, age range, gender
๐Ÿง Person tracking in video Detect and track people frame by frame
๐Ÿ›ก๏ธ Content moderation Flag unsafe or explicit content
๐Ÿ†” Face search/recognition Match faces against a collection
๐Ÿ”  OCR (text in image/video) Detect printed or handwritten text
๐Ÿ“ฆ Object detection Detect people, animals, vehicles, etc.
๐ŸŽฌ Video analysis Use Rekognition Video for temporal data
๐Ÿง  Custom image classification Train your own model using Rekognition Custom Labels

๐Ÿ”Ž Feature Overview

Feature Image Video Description
Detect Faces โœ… โœ… Bounding box, age, emotions, gender
Recognize Celebrities โœ… โœ… Prebuilt celeb face database
Detect Labels โœ… โœ… Identify scenes, objects, activities
Detect Text (OCR) โœ… โœ… Print or handwritten text from images/videos
Content Moderation โœ… โœ… Flag adult/violent/inappropriate content
Custom Labels โœ… โŒ Train on your own labeled dataset (no coding)
Face Comparison โœ… โŒ Compare two faces or against a face collection
Person Pathing โŒ โœ… Track individuals across frames in a video

๐Ÿ› ๏ธ Rekognition vs SageMaker vs OpenCV

Task Rekognition SageMaker OpenCV / Custom
Face & label detection โœ… Fully managed โŒ Custom only โŒ Needs own model
Custom classification โœ… No-code (Custom Labels) โœ… Full training pipeline โœ… From scratch
Video analytics โœ… Yes โŒ Not native โŒ Hard to scale
Serverless deployment โœ… Yes โŒ Needs infrastructure โŒ Manual setup

๐Ÿ’ต Pricing Summary (2024)

Feature Image Price (per image) Video Price (per minute)
Label detection $0.001 $0.12
Face detection $0.001 $0.12
Face comparison $0.0015 N/A
Custom Labels training $1.00/hour (training) N/A
Custom Labels inference $4.00 per 1,000 images N/A
Content moderation $0.001 $0.10

๐Ÿง  Tip: For large datasets, use batch processing (e.g., with S3 and Lambda) to reduce cost.


๐Ÿงช Sample Python Code (Boto3)

1. Detect Labels in an Image

import boto3

rekognition = boto3.client('rekognition')

response = rekognition.detect_labels(
    Image={'S3Object': {'Bucket': 'my-bucket', 'Name': 'my-image.jpg'}},
    MaxLabels=5,
    MinConfidence=80
)

for label in response['Labels']:
    print(f"{label['Name']} - {label['Confidence']:.2f}%")

2. Face Comparison

response = rekognition.compare_faces(
    SourceImage={'S3Object': {'Bucket': 'my-bucket', 'Name': 'face1.jpg'}},
    TargetImage={'S3Object': {'Bucket': 'my-bucket', 'Name': 'face2.jpg'}},
    SimilarityThreshold=80
)

for faceMatch in response['FaceMatches']:
    print("Similarity:", faceMatch['Similarity'])

3. Detect Text in Image

response = rekognition.detect_text(
    Image={'S3Object': {'Bucket': 'my-bucket', 'Name': 'receipt.jpg'}}
)

for text in response['TextDetections']:
    print(text['DetectedText'], text['Confidence'])

๐Ÿ“ฆ Rekognition Custom Labels (No-code ML)

Train your own model using S3-labeled images:

  • Step 1: Label images via Ground Truth or CSV manifest

  • Step 2: Create a Rekognition Custom Labels Project

  • Step 3: Train the model (serverless training)

  • Step 4: Deploy the model endpoint and invoke via API

โš ๏ธ Note: Custom Labels pricing is different (more expensive, but very powerful)


๐Ÿ” Security and Access Control

Feature Details
IAM Role Required to use Rekognition APIs
S3 Integration Uses S3Object for media input
KMS Encryption Supported if S3 bucket uses SSE-KMS
VPC Support Not applicable (Rekognition is regional API only)

๐Ÿ› ๏ธ Terraform Integration (Basic)

Amazon Rekognition does not have extensive Terraform support (e.g., no aws_rekognition_custom_label), but you can:

  • Manage IAM roles/policies

  • Automate image pipelines (S3 + Lambda + Rekognition)

  • Use AWS Lambda to invoke Rekognition API programmatically

Example: S3 + Rekognition + Lambda can be orchestrated via Terraform for event-driven analysis.


โœ… TL;DR Summary

Feature Amazon Rekognition
Pre-trained Models โœ… Yes
Custom Models โœ… Rekognition Custom Labels
Real-time Video โœ… Yes (via Kinesis Video Stream)
Face Search/Compare โœ… Yes
OCR โœ… Yes (text detection in images/videos)
Content Moderation โœ… Yes
Serverless โœ… Fully managed APIs
Terraform Support โš ๏ธ Limited
Ideal For Fast, no-ML-code visual recognition tasks

Service How It Works
S3 Store and analyze media (image/video)
Lambda Trigger analysis on file upload
Step Functions Build image moderation pipelines
SNS/SQS Notify users based on Rekognition results
SageMaker Extend with more complex model use cases