...

/

Building an OCR script for Images using Read API

Building an OCR script for Images using Read API

Learn to extract text from Images using Computer Vision's Read API.

Introduction

We are going to build an OCR script which will use the Azure Computer Vision’s Read API to perform OCR on some sample images.

If you want to execute the code snippets mentioned in this chapter on your local machine, then you can visit the Appendix section where you can follow the steps to install the dependencies (python packages).

Implementing OCR

First let’s import all the required packages that we would need to complete our OCR functionality.

Importing the required packages

Let us first import all the required packages that we would need to complete our OCR functionality.

Press + to interact
from azure.cognitiveservices.vision.computervision import ComputerVisionClient
from azure.cognitiveservices.vision.computervision.models import OperationStatusCodes
from msrest.authentication import CognitiveServicesCredentials
from PIL import Image, ImageDraw
import requests
from io import BytesIO
import shutil
import time

Authenticating and calling the read API

Now, once we have imported all the required ...