• Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

Getting Started with the AWS Rekognition API

Lomanu4 Оффлайн

Lomanu4

Команда форума
Администратор
Регистрация
1 Мар 2015
Сообщения
1,481
Баллы
155
A Developer's Guide

Computer vision made easy with AWS Rekognition.
Amazon Rekognition is a powerful image and video analysis service provided by AWS. With just a few lines of code, you can analyze faces, detect objects, read text, and even identify unsafe content.

In this post, I’ll walk you through the basics of integrating Rekognition into your app using the AWS SDK. Whether you're building a photo moderation system or facial recognition features, this guide will help you get started quickly.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



Prerequisites


Before diving in, make sure you have the following:

  • An AWS account
  • AWS credentials configured (~/.aws/credentials or IAM role if using EC2/Lambda)
  • AWS SDK installed (I'll use Python’s boto3, but the logic is similar in other SDKs)
  • An image file to test with
Installing boto3


pip install boto3
Setting Up Credentials


Ensure your credentials are properly configured. For example:


# ~/.aws/credentials
[default]
aws_access_key_id = YOUR_ACCESS_KEY
aws_secret_access_key = YOUR_SECRET_KEY

Or set them as environment variables:


export AWS_ACCESS_KEY_ID=your-access-key
export AWS_SECRET_ACCESS_KEY=your-secret-key
Using Rekognition to Detect Labels


Label detection identifies objects, people, text, scenes, and activities in an image.


import boto3

client = boto3.client('rekognition')

with open('image.jpg', 'rb') as image:
response = client.detect_labels(Image={'Bytes': image.read()}, MaxLabels=10, MinConfidence=80)

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


Rekognition can detect faces and even return landmarks like eyes and nose positions.


with open('face.jpg', 'rb') as image:
response = client.detect_faces(Image={'Bytes': image.read()}, Attributes=['ALL'])

for face in response['FaceDetails']:
print(f"Age Range: {face['AgeRange']}")
print(f"Smile: {face['Smile']['Value']}")
print(f"Emotions: {[e['Type'] for e in face['Emotions']]}")
Text Detection


You can also extract text from images, similar to OCR.


with open('text_image.jpg', 'rb') as image:
response = client.detect_text(Image={'Bytes': image.read()})

for text in response['TextDetections']:
print(f"Detected: {text['DetectedText']} - Type: {text['Type']}")
Content Moderation


Useful for platforms where user-generated content needs filtering.


with open('moderation.jpg', 'rb') as image:
response = client.detect_moderation_labels(Image={'Bytes': image.read()}, MinConfidence=80)

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


Compare faces between two images, often used for verification.


source_img = open('source.jpg', 'rb').read()
target_img = open('target.jpg', 'rb').read()

response = client.compare_faces(SourceImage={'Bytes': source_img},
TargetImage={'Bytes': target_img},
SimilarityThreshold=90)

for match in response['FaceMatches']:
print(f"Similarity: {match['Similarity']:.2f}%")
Pricing


Rekognition offers a free tier for the first 12 months with:

5,000 images for label and face analysis

1,000 images for moderation

After that, pricing is based on per-image or per-second analysis.

Tips for Production

  • Store and reference images via S3 for better performance and scalability.
  • Always handle exceptions (botocore.exceptions.ClientError) for more resilient code.
  • Monitor API usage with AWS CloudWatch.
  • Use IAM roles with least privilege for security.
Final Thoughts


AWS Rekognition abstracts away the complexity of computer vision. Whether you’re adding face detection to a photo app or moderating uploaded content, Rekognition offers a reliable and scalable solution.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх Снизу