Detecting People and Vehicles with Amazon Rekognition

In today’s article, I’ll demonstrate how to use the Amazon Rekognition SDK to detect people and vehicles in images with varying resolutions and quality.

Use case

Recently, I was tasked with showcasing Amazon Rekognition’s ability to detect people and vehicles in images. The goal was to identify non-compliance in the provided photos, such as detecting people or vehicles in restricted areas. Upon detection, an event is triggered, which then sends a notification. However, for this tutorial, we will focus solely on using Amazon Rekognition for detection.

Initial Setup

I began by setting up my code with the necessary library imports and retrieving credentials using a predefined profile.

You can configure a profile with your credentials as follows:

Initializing Services

Next, I initialized the S3 and Rekognition services and specified the S3 bucket where the images are stored.

Detecting Labels and Drawing Bounding Boxes

With the services initialized, I created a function to detect labels (such as people and vehicles) in images stored in S3. The function returns a bounding box around detected objects.

Processing Images from S3

Finally, I processed each image stored in the S3 bucket. The script downloads each image, applies the detection function, draws bounding boxes around the detected objects, and saves the annotated images.

Results

After processing the images using Amazon Rekognition, the results will include labels indicating detected objects, such as people and vehicles, along with their respective bounding boxes drawn on the images.

These annotated images, saved to your local file system, clearly highlight the detected objects, enabling easy identification of any non-compliance or anomalies. By automating this process, you can efficiently analyze large volumes of images, trigger alerts, and take necessary actions based on the detected results, ensuring compliance and enhancing security in your operations.

Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *

Rolar para cima