我想扫描image
文档并从图像中绘制word
的图形,我也想获取word count
。使用Google Vision API
是否可以?
我在他们的文档中没有看到有关字数统计的任何相关信息。如果有人以前做到过这一点,请帮助我。
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库一个机会。