Skip to content

Instantly share code, notes, and snippets.

@khuangaf
Last active August 26, 2018 03:42
Show Gist options
  • Save khuangaf/37394b1ff250c4a10b10844e2528d98e to your computer and use it in GitHub Desktop.
Save khuangaf/37394b1ff250c4a10b10844e2528d98e to your computer and use it in GitHub Desktop.
# the endpoint of the api
ENDPOINT_URL = 'https://vision.googleapis.com/v1p1beta1/images:annotate'
# the api key
os.environ['GOOGLE_APPLICATION_CREDENTIALS']='your/path/to/credentials.json'
# init api client
client = vision.ImageAnnotatorClient()
with io.open(YOUR_IMAGE_PATH, 'rb') as f:
content = f.read()
image = vision.types.Image(content=content)
image_context = vision.types.ImageContext(language_hints=['zh-TW'])
response = client.document_text_detection(image=image,image_context=image_context)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment