2016-11-18 89 views

回答

1

,因为没有其他答案现在已经存在了一段时间,我只添加这为未来的读者(我还添加了一个赏金):

from googleapiclient.discovery import build 

# ... 

service = build('vision', 'v1', developerKey=API_KEY, cache_discovery=False) 
image_b64 = base64.b64encode(image_bytes).decode() 
return service.images().annotate(body={ 
    'requests': [{ 
     'image': { 
      'content': image_b64 
     }, 
     'features': [{ 
      'type': 'DOCUMENT_TEXT_DETECTION', 
      'maxResults': 5, 
     }] 
    }] 
}).execute() 

这(Python)的样本明显不使用的客户端在问题中,但这是我目前在做这个简单的OCR的方式。

您可以更改功能或图像规格以适应您的需求。