Power Automate: Extract Text from SharePoint Library Image using Computer Vision Cognitive Service

Introduction

Cognitive Services are a set of machine learning algorithms that Microsoft has developed to solve problems in the field of Artificial Intelligence (AI).In this article we will be using the Computer Vision API to analyse the image uploaded to SharePoint Online and derive the description about it. We will be uploading the image of Taj mahal and we will see how we can derive its description and save it back to a column in SharePoint Library.

Create Cognitive Service API Subscription

Before we can use it in flow we have to subscribe to it and get the keys so that we can authenticate to the API from flow. Head over to the Cognitve Service blade in Azure Portal and click on Add.

This will list out all the available cognitive service APIs. Select Computer Vision.

It will open up the dialog box where we can name the instance of the Computer Vision API and select the pricing tier and resource group.

Once its created, head over to the Overview section from which we can get the endpoint and keys which will be used within the flow. Take a note of it.

 

Create the Flow

Now lets head over to the Flow Portal and create the flow with the trigger “When an file is created” so that the flow will run whenever an image is uploaded to the library.

Add the Get File Content action so as to retrieve the file content of the recently uploaded image. We will be using the File Content output from this action within the cognitive analysis action. Now , add the Computer Vision API action .

Specify the name and the Account Key as well as the endpoint URL which we had noted down earlier.

On Clicking create it will establish the connection with the API and provide us the option to enter the Image Source and Image Content. Select Image Content as the value for Image Source and Specify File Content (output from Get File Content action) as the value for Image Content              

Finally we will save the output of the Cognitive analysis action which is the description of the image back to the SharePoint Library

Test the implementation

Now lets head over to the SharePoint Library and upload an image with the text “Save Tree”. It should ideally kickstart the flow and extract the text back to the “Embedded Text” column in the library

Heading over to Power Automate portal, we can see that the flow has run successfully.

In the library we can see the text extracted has been saved to the column

Summary

Thus we saw how we can use Computer Vision Cognitive Analysis to extract the text from an image and save it back to SharePoint Library