Image Processing- Invoice recording using Power App, Microsoft Flow and Cognitive Service- Part 1

For a month I am looking to create a Microsoft App that user able to take a picture from an invoice then able to see the items in Power BI or store it in storage such as SQL server, excel and so forth.

In this posts, first I will show how to create a Power APP for taking a photo, then the process of how to create a Microsoft Flow to apply the cognitive service, convert image to text service (OCR), then post back data to Power APP and also to Power BI.

The first step is to create a Microsoft Power APP

Create a Microsoft Power App for taking Photo

first, you need to go to theย https://powerapps.microsoft.com/en-us/, log into the account that you have or simply sing up for the free one. Power App is an easy to use tool to create mobile and tablet app.

For this scenario, we need to capture the image. IN Power app we able to have a different page that has been shown in SCREENS pannel in the left side of the window.

first, I am going to create a page header for the app

click on theย Insert and choose theย Iconย scroll down to fin the rectangle.

then, I put the rectangle on the top of the page. I want o to follow the same color theme for my app, so I am going to create a separate screen (page) to define the color them. I want to make all button and rectangle red and the icon black. Just recommend to Save the app by click on theย Fileย  save the app by allocating a name to it to not lose it ๐Ÿ™‚

I create a new screen by click on theย New Screen option at the top of the page and rename it to Theme Color.

Now I define a new label to assign it the color theme, then reuse it in other tools. So click on theย Insert then choose theย Lable. As you can see in the picture, on the left side of the page there is a dropdown that shows Text, this drop-down also holds other attributes regarding the label such as color, on select action and so forth. You able to change the text by changing the text inย the Function area. I changed the text fromย Text toย Red Color as shown below. Also

Now, I will change theย Text toย Colorย  and replace theย RGBA(0, 0, 0, 1) withย ColorValue(“Red”)

also, I change the label name fromย Lable1 toย Redcolor.

Now, you able to back to the screen1 and change the rectangle color toย RedColor. Click on the rectangle and from the drop-down in the left side of the window choose theย Fill and replace the current value withย RedColor.Color. Now I define another label in Theme color screen for texts black same as one I define for Red color.

After creating the second label, I rename it to BlackColor

In screen one, I am going to change the title of the APP by adding a new Lable object to the rectangle.

The other object we need is theย Camera, from the optionย Insert->Media-> Camera chooses the camera object. The camera Object shows the default camera on your machine. there is a properties nameย  Camera that the default value is 0, which is the default camera number you able to change it toย 1 or 2 or more to switch between camera.

I will show you later how to change the camera setting via some codes.

Now we need aย Button to take a photo and an image Object to show the captured image.

Click on theย Button, and change the color same as before (choose the fill attribute and

Then choose theย Text attribute and change it to “Take Photo”.

Now we need t capture the picture in the camera by writing some codes. Click on theย Take Photo button and select theย OnSelect properties.

initially, it has false value, but we are going to change it fromย falseย  toย UpdateContext({TakenPic:Camera1.Stream})ย 

now, we need an image object to show us the taken image. it is an easy process, just click on theย Insert->Media->Image. Now, an image object locates in the Power APP dashboard design. The image object needs to show the taken image.

so, click on theย image attribute then change the initial one that isย SampleImage toย ย TakenPic. To see the run, click on the run option at the top right of the page

Before the run, click on theย Camera1, then choose the settingย StreamRate and set it to 100.

then run the app, you should see some thing as below!

There is a possibility that you need to change the camera via APP. so we can write some code to solve it.

we need to object: one camera icon and the other refresh icon to setย  the camera to default one

First, need to go toย insert->icon->camera icon there. then, change the color of it to black.

this time I choose theย colorย  attribute instead of fill and then change the value toย BlackColor.Color, now click onย OnSelect object and change the formula to :

Switch(Cam,
0,UpdateContext({Cam:1}),
1,UpdateContext({Cam:2}),
2,UpdateContext({Cam:0}))

we define a varibale namedย  Cam that we want any time we push the Camera icon, it change the Camera. from camera 0 to 1 or 2 then to 0.

however the variableย Cam should be conneted toย Camera1.

so click on the camera icon and chose the attributeย  Camera and in front of it write Cam.ย  Now, if tou run the app, by clicking on the camera icon you will get a picture from the differentย  camera:

Now, I am going to create a button to send the picture to Microsoft Flow for image processing just create a button same as before.

However, for OCR we need to first set it up in Microsoft Flow (Which I will explain it in the next post).

 

we have our power app half ready, in the next post I will show how to connect it with a flow so able to call the OCR from cognitive service then store it in other resources

I get help from this video to set up the Power APP:ย https://www.youtube.com/watch?v=ovLIwnj6QjU

 

Leila Etaati on LinkedinLeila Etaati on TwitterLeila Etaati on Youtube
Leila Etaati
Trainer, Consultant, Mentor
Leila is the first Microsoft AI MVP in New Zealand and Australia, She has Ph.D. in Information System from the University Of Auckland. She is the Co-director and data scientist in RADACAD Company with more than 100 clients in around the world. She is the co-organizer of Microsoft Business Intelligence and Power BI Use group (meetup) in Auckland with more than 1200 members, She is the co-organizer of three main conferences in Auckland: SQL Saturday Auckland (2015 till now) with more than 400 registrations, Difinity (2017 till now) with more than 200 registrations and Global AI Bootcamp 2018. She is a Data Scientist, BI Consultant, Trainer, and Speaker. She is a well-known International Speakers to many conferences such as Microsoft ignite, SQL pass, Data Platform Summit, SQL Saturday, Power BI world Tour and so forth in Europe, USA, Asia, Australia, and New Zealand. She has over ten yearsโ€™ experience working with databases and software systems. She was involved in many large-scale projects for big-sized companies. She also AI and Data Platform Microsoft MVP. Leila is an active Technical Microsoft AI blogger for RADACAD.

3 thoughts on “Image Processing- Invoice recording using Power App, Microsoft Flow and Cognitive Service- Part 1

Leave a Reply

Your email address will not be published. Required fields are marked *