I want to scan a image
document and graph the word
from image and I also want to get the word count
. Is this possible by using Google Vision API
?
I didn't seen any related information regarding word count within their documentation. If anybody achieved this before, please help me on this.
Adapted example from the sample available in 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))
Fair suggestion from my side: Give the other OCR libraries a shot as well.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.