【问题标题】:How to get Word Count using Google Vision OCR API by Python?如何使用 Python 的 Google Vision OCR API 获取字数?
【发布时间】:2020-04-12 20:29:25
【问题描述】:

我想扫描image 文档并从图像中绘制word,我还想获得word count。这可以通过使用Google Vision API 来实现吗?

我没有在他们的文档中看到任何有关字数的相关信息。如果有人以前做到这一点,请帮助我。

【问题讨论】:

    标签: python google-vision


    【解决方案1】:

    改编自codelabs中的示例:

    from google.cloud import vision
    
    def count_words(str):
        ls1 = str.split()
        return len(ls1)
    
    
    image_uri = 'gs://cloud-vision-codelab/otter_crossing.jpg'
    
    client = vision.ImageAnnotatorClient()
    image = vision.types.Image()
    image.source.image_uri = image_uri
    
    response = client.text_detection(image=image)
    
    for text in response.text_annotations:
        print(text.description)
        print(count_words(text.description))
    

    我的公平建议:也试试其他 OCR 库。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-01-25
      • 1970-01-01
      • 1970-01-01
      • 2023-03-02
      • 2020-03-03
      • 2021-05-16
      • 2020-07-13
      相关资源
      最近更新 更多