-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtext_image.py
26 lines (22 loc) · 1.05 KB
/
text_image.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import boto3
from pprint import pprint
import image_helpers
client = boto3.client('rekognition')
imgurl = 'http://docs.aws.amazon.com/rekognition/latest/dg/images/text.png'
imgurl = 'https://image.slidesharecdn.com/howtooverlaytextonimagesjpgs-141214122828-conversion-gate01/95/how-to-overlay-text-on-images-5-simple-methods-1-638.jpg?cb=1433017251'
#imgurl = 'https://lh3.ggpht.com/AIOlcNtjP5seRwQp62nUEpleulvRgvgMjTm9bR72uMQNJsJfp1O0Op1_ZXfnEYD5uA=h900'
imgurl = 'https://blog.njsnet.co/content/images/2017/02/trumprecognition.png'
imgurl = 'http://ww2.eclipseadvantage.com/images/Photos/people_resized.jpg'
# grab the image from online
imgbytes = image_helpers.get_image_from_url(imgurl)
rekresp = client.detect_text(Image={'Bytes': imgbytes})
#pprint(rekresp['TextDetections'])
imgString=""
for img in rekresp['TextDetections']:
imgString=imgString+img['DetectedText']+" "
pprint(imgString);
half, rem = divmod(len(imgString), 2)
frontA = imgString[:half + rem]
backA = imgString[half + rem:]
pprint(frontA)
#pprint(', '.join(imgText))