Select Page

In this Azure AI Vision blog post, we will show how to extract text from images using Azure AI Vision and Azure SDK for .NET.

  • Azure AI Vision allows us to analyse images and perform operations against objects inside images. AI Vision capabilities include:
  • Optical Character Recognition (OCR) allows us to extract text from images, whether they are printed or handwritten, as we will see in this post.
  • Extract visual features, generate captions, and identify faces and objects.
  • Recognise human faces for facial recognition software, including image blurring and access control.

To perform AI operations on images, we use the official Microsoft Azure SDK for .NET. The AI Vision library is called Azure.AI.Vision.ImageAnalysis.

Deploy Azure AI Vision Resource

Before accessing the AI Vision service, we need to deploy an Azure resource that will give us access to the service. To deploy the service, we can either use the Azure portal, Azure PowerShell, Azure CLI, or the .NET SDK for Azure. In our case, we will use Azure Bicep with the following configuration.

Once the service is deployed, Open the resource from the Azure portal and note the API Key and Endpoint.

Program

Now that we have the service deployed to Azure and the access details to the service, we can use the AI Vision library to detect an image and give us a description of it. Start by creating a C# console application and installing the Vision library.

In the program root directory, create an Images directory and copy all the images from which you need AI Vision to extract text.

Before you run the program, add your Azure AI Vision resource Key and Endpoint to an appsettings.json file.

In the example below, I will extract the text from the image above (from the Azure portal).

At CPI, we help many businesses develop AI solutions using Azure AI Services. Please contact us if you need assistance with your development.