【问题标题】:Python: what's the gdata method for uploading an image with enabled OCR?Python:上传启用 OCR 的图像的 gdata 方法是什么?
【发布时间】:2010-07-04 21:25:21
【问题描述】:
【问题讨论】:
标签:
python
ocr
gdata-python-client
【解决方案1】:
假设您从这里开始:
http://code.google.com/apis/documents/docs/3.0/developers_guide_python.html
您已经创建了一个经过身份验证的 client 对象。
f = open('/path/to/your/test.pdf')
ms = gdata.data.MediaSource(file_handle=f, content_type='application/pdf', content_length=os.path.getsize(f.name))
folder = "https://docs.google.com/feeds/default/private/full" # folder in google docs.
entry = client.Upload(ms, f.name, folder_or_uri= folder + '?ocr=true') # ?ocr=true is the kicker
使用尾随 ?ocr=true 参数指定 folder_or_uri 是导致转换发生的原因。
创建后,您现在可以将其导出为 txt 文档。