Extracting text from images with Google Cloud Vision AI
We can use the power of the Google Cloud interface to detect and extract text in images. This process is called Optical Character Recognition, or OCR.
Getting ready
We need to enable the Google Cloud Vision API and create credentials to work with it, as described in the previous recipe, Analyzing Images with Google Cloud Vision AI. We need to use the generated service account key in JSON format. We will call it credentials.json
throughout the chapter.
We need to add the official Google Cloud Vision library. We should install the module, adding it to our requirements.txt
file as follows:
$ echo " google-cloud-vision==1.0.0" >> requirements.txt
$ pip install -r requirements.txt
We will use the image_text.py
script and the photo-text.jpg
and dublin-a-text.jpg
files that were also used in Chapter 4, Searching and Reading Local Files. You can download them from the GitHub repository at https:/...