【发布时间】:2017-12-19 20:39:06
【问题描述】:
想要使用 Google 的 Cloud Vision API 进行 OCR。使用python示例代码here我们有:
def detect_text(path):
"""Detects text in the file."""
client = vision.ImageAnnotatorClient()
with io.open(path, 'rb') as image_file:
content = image_file.read()
image = types.Image(content=content)
response = client.text_detection(image=image)
texts = response.text_annotations
print('Texts:')
for text in texts:
print('\n"{}"'.format(text.description))
vertices = (['({},{})'.format(vertex.x, vertex.y)
for vertex in text.bounding_poly.vertices])
print('bounds: {}'.format(','.join(vertices)))
我的 API 密钥应该放在哪里?没有它我(显然)无法进行身份验证。
【问题讨论】:
-
我也有同样的问题。有文档说明如何直接将 API 密钥与 REST API 一起使用,但没有说明如何将其与提供的客户端一起使用。
标签: python ocr google-cloud-vision