如何通过Python使用Google Vision OCR API进行字数统计?

问题描述 投票:0回答:1

我想扫描image文档并从图像中绘制word的图形,我也想获取word count。使用Google Vision API是否可以?

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

python google-vision
1个回答
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库一个机会。

© www.soinside.com 2019 - 2024. All rights reserved.