-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwatson_OCR.py
25 lines (15 loc) · 1.08 KB
/
watson_OCR.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
# Visual Recognition with IBM Watson - Text Recognition
# Requirements 1: IBM Bluemix Account (free) - https://console.ng.bluemix.net/
# Requirements 2: watson_developer_cloud module python module
# Once registered, login to your account, go to Services -> Watson and create a Visual Recognition instance
# Once you have your VR instance created, you will use its API credentials in your python code
from watson_developer_cloud import VisualRecognitionV3 as vr
# creating a VR instance
instance = vr(api_key='ff644e192cbf2fcd509165d85a7b053f360ca6a1', version='2016-05-20')
# select an image (local or url) with text in it. Recognizing text:
img = instance.recognize_text(images_url='https://pbs.twimg.com/media/ClFro9UWkAAvVxX.jpg')
# you can run this code in the interpreter. If you request >>> img it will output a json formatted result
# going down the json tree, you can retrieve the text in the image with the following command:
print(img['images'][0]['text'])
# I posted a demo of this here: http://bit.ly/2hlC20a
# If you need help with Watson and Visual Recognition, send me a message.