0% found this document useful (0 votes)
11 views3 pages

#Debes Instalar Primero Boto3 y Pillow Asi #Sudo Pip-3.6 Install Pillow #Este Programa Detecta Labels

This document contains Python code to perform various image analysis tasks using the Amazon Rekognition API including: 1) Detecting labels in an image of the Mona Lisa. 2) Detecting faces in the Mona Lisa image and outputting attributes of each face. 3) Drawing landmarks on detected faces in the Mona Lisa. 4) Detecting text in an image and drawing polygons around the detected text. 5) Saving new images with labels, faces, and text detections marked.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views3 pages

#Debes Instalar Primero Boto3 y Pillow Asi #Sudo Pip-3.6 Install Pillow #Este Programa Detecta Labels

This document contains Python code to perform various image analysis tasks using the Amazon Rekognition API including: 1) Detecting labels in an image of the Mona Lisa. 2) Detecting faces in the Mona Lisa image and outputting attributes of each face. 3) Drawing landmarks on detected faces in the Mona Lisa. 4) Detecting text in an image and drawing polygons around the detected text. 5) Saving new images with labels, faces, and text detections marked.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

#debes instalar primero boto3 y pillow asi #sudo pip-3.

6 install pillow
#este programa detecta labels
import boto3

import pprint

from PIL import Image, ImageDraw

rek=boto3.client('rekognition')

with open('monalisaOriginal.jpg', 'rb') as f:

image_bytes=f.read()

response=rek.detect_labels(

Image={

'Bytes': image_bytes

})

pprint.pprint(response)

#este segundo programa detecta LAS CARACTERISTICAS DE LA CARA

response=rek.detect_faces(

Image={

'Bytes': image_bytes

},

Attributes=['ALL'])

pprint.pprint(response)
#este ter cerprograma imprime reconoce las expresiones faciales y
las redondea
src=Image.open('monalisaOriginal.jpg')
draw1=ImageDraw.Draw(src)
width, height=src.size
img=Image.new('RGB',src.size)
draw=ImageDraw.Draw(img)
img.paste(src, (0,0))

for face in response['FaceDetails']:


for point in face['Landmarks']:
x=point['X']*width
y=point['Y']*height
r=5

draw.ellipse((x-r, y-r, x+r, y+r), fill='red')

img.save('monalisaOriginal-rek.jpg')

#este programa reconoce texto


rek=boto3.client('rekognition')

with open('calleFalta.jpg', 'rb') as f:


image_bytes=f.read()
response=rek.detect_text(
Image={
'Bytes': image_bytes

} )

pprint.pprint(response)
# este programa circula el texto detectado y lo guarda en un
nuevo archivo llamado calleFalta-rek
src=Image.open('calleFalta.jpg')
draw1=ImageDraw.Draw(src)
width, height=src.size
img=Image.new('RGB',src.size)
draw=ImageDraw.Draw(img)
img.paste(src, (0,0))

for text in response['TextDetections']:


points=[(point['X']*width, point['Y']*height) for point in text['Geometry']
['Polygon']]
points.append(points[0])
draw.line(points, fill='red',width=9)

img.save('calleFalta-rek.jpg')

You might also like