【问题标题】:Python: what's the gdata method for uploading an image with enabled OCR?Python:上传启用 OCR 的图像的 gdata 方法是什么?
【发布时间】:2010-07-04 21:25:21
【问题描述】:

如此 PHP 代码所示,(http://code.google.com/p/gdata-samples/source/browse/trunk/doclist/OCRDemo/ocr.php?r=194)

可以将图像上传到自动转换为文本的谷歌文档。我想知道如何在python中做到这一点。有一个“上传”方法,但我只是想知道如何启用 OCR 功能。

【问题讨论】:

    标签: 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 文档。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-12-04
      • 2012-08-08
      • 1970-01-01
      • 2021-01-04
      • 2012-05-21
      • 2020-02-01
      • 1970-01-01
      相关资源
      最近更新 更多