Created
January 17, 2020 09:27
-
-
Save vittorio-nardone/49f6c5fa2ef4841293afc9426079f1bc to your computer and use it in GitHub Desktop.
Text detection in Python and AWS Rekognition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def detect_text(photo, bucket): | |
"""Detect text in an image hosted as bucket object | |
:param phone: Object name | |
:param bucket: Bucket name | |
:return: | |
""" | |
client=boto3.client('rekognition') | |
response=client.detect_text(Image={'S3Object':{'Bucket':bucket,'Name':photo}}) | |
textDetections=response['TextDetections'] | |
print ('Detected text\n----------') | |
for text in textDetections: | |
if 'ParentId' in text: | |
continue | |
print ('Detected text:' + text['DetectedText']) | |
print ('Confidence: ' + "{:.2f}".format(text['Confidence']) + "%") | |
print ('Id: {}'.format(text['Id'])) | |
print ('Type:' + text['Type']) | |
print() | |
return response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment