Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何通过Python使用Google Vision OCR API获得字数?_Python_Google Vision - Fatal编程技术网

如何通过Python使用Google Vision OCR API获得字数?

如何通过Python使用Google Vision OCR API获得字数?,python,google-vision,Python,Google Vision,我想扫描一个图像文档,并将图像中的单词绘制成图表,我还想获得单词数。使用Google Vision API可以实现这一点吗 我在他们的文档中没有看到任何关于字数的相关信息。如果有人以前做到了这一点,请在这方面帮助我 改编自以下样本的示例: 我这边的合理建议是:也尝试一下其他OCR库 from google.cloud import vision def count_words(str): ls1 = str.split() return len(ls1) image_uri

我想扫描一个图像文档,并将图像中的单词绘制成图表,我还想获得单词数。使用Google Vision API可以实现这一点吗


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

改编自以下样本的示例:

我这边的合理建议是:也尝试一下其他OCR库

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))