cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
askingquestion9
Frequent Visitor

Search or filter specific area/coordinates with recognize text from PDF AI

I am using the default action "Recognize text in an image or a PDF document" from AI Builder

Is there a way to add like a quadrant for each image/document?

 

Or is there a way to filter this output to only include coordinates in the lower left quadrant?

 

 

[
  {
    "@odata.type": "#Microsoft.Dynamics.CRM.expando",
    "page": 1,
    "lines@odata.type": "#Collection(Microsoft.Dynamics.CRM.crmbaseentity)",
    "lines": [
      {
        "@odata.type": "#Microsoft.Dynamics.CRM.expando",
        "text": "10000 FARM- ANIMALS MILK",
        "boundingBox": {
          "@odata.type": "#Microsoft.Dynamics.CRM.expando",
          "left": 0.020272931185041865,
          "top": 0.04817338060721935,
          "width": 0.2313408557779566,
          "height": 0.020837619041856763,
          "polygon": {
            "@odata.type": "#Microsoft.Dynamics.CRM.expando",
            "coordinates@odata.type": "#Collection(Microsoft.Dynamics.CRM.crmbaseentity)",
            "coordinates": [
              {
                "@odata.type": "#Microsoft.Dynamics.CRM.expando",
                "x": 0.020272931185041865,
                "y": 0.05078715860550104
              },
              {
                "@odata.type": "#Microsoft.Dynamics.CRM.expando",
                "x": 0.25161378696299846,
                "y": 0.04817338060721935
              },
              {
                "@odata.type": "#Microsoft.Dynamics.CRM.expando",
                "x": 0.25161378696299846,
                "y": 0.06770411064993527
              },
              {
                "@odata.type": "#Microsoft.Dynamics.CRM.expando",
                "x": 0.020272931185041865,
                "y": 0.06901099964907612
              }
            ]
          }
        }
      },

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
takolota
Multi Super User
Multi Super User

@askingquestion9 

 

Yes. You will want to use 1 Filter array action with a more complex condition expression or 2 sequential Filter array actions with simpler condition expressions to filter to only the items below a certain Y coordinate on a scale of 0 to 1 and to only the items below a certain X coordinate on a 0 to 1 scale.

 

Each object/item there has 4 sets of x-y coordinates and they are ordered as shown below

IMG_3814.jpeg

 Where there is a bounding box around each piece of text where the 1st coordinates are the top left point of the box, the 2nd are the top right, 3rd are bottom right, & fourth are bottom left.

 

You can probably just base the coordinates filter on the 1st top left coordinates for each item.

 

Looks like for the From input of the 1st or only Filter you will need to reference the lines array property so like body(‘OCRaction…’)?[‘lines’]
Then for the condition expression you will need to reference the 1st coordinate set with something similar to

item()?[‘boundingBox’]?[‘coordinates’][0][‘x’]

And

item()?[‘boundingBox’]?[‘coordinates’][0][‘y’]

So you can set what coordinates the items returned should be greater than or less than.

View solution in original post

14 REPLIES 14
takolota
Multi Super User
Multi Super User

@askingquestion9 

 

Yes. You will want to use 1 Filter array action with a more complex condition expression or 2 sequential Filter array actions with simpler condition expressions to filter to only the items below a certain Y coordinate on a scale of 0 to 1 and to only the items below a certain X coordinate on a 0 to 1 scale.

 

Each object/item there has 4 sets of x-y coordinates and they are ordered as shown below

IMG_3814.jpeg

 Where there is a bounding box around each piece of text where the 1st coordinates are the top left point of the box, the 2nd are the top right, 3rd are bottom right, & fourth are bottom left.

 

You can probably just base the coordinates filter on the 1st top left coordinates for each item.

 

Looks like for the From input of the 1st or only Filter you will need to reference the lines array property so like body(‘OCRaction…’)?[‘lines’]
Then for the condition expression you will need to reference the 1st coordinate set with something similar to

item()?[‘boundingBox’]?[‘coordinates’][0][‘x’]

And

item()?[‘boundingBox’]?[‘coordinates’][0][‘y’]

So you can set what coordinates the items returned should be greater than or less than.

askingquestion9
Frequent Visitor

Thank you! I will try to implement that

Also thanks for the CSV to Dataset, I found it today and improved the speed of my flows so much!

I need to go over all your posts, they are a gold mine

JStell
Frequent Visitor

Awesome! This is exactly what I was looking for!

 

I appreciate it! 👍

@takolota  I am trying to filter the array after apply to each 5 using the lines output, but it doesnt even let me add the "item()?['boundingBox']?['coordinates'][0]['x']" in the expression

 

below is the flow without the filter array

 

askingquestion9_0-1702293238183.png

 

I

 

 

@askingquestion9 

I don’t know what you’re doing, but that looks like an unnecessary Apply to Each loop on the Lines when you need to use a Filter array action. 

@takolota I managed to get it  to work but it doesn't seem optimal

 

askingquestion9_0-1702372304793.png

 

@takolota, would you be able to help with how to reference the specific lines? For instance, after you see "body":[ which leads down to "lines": [, how would I reference the specific call outs below this point in order to pull the desired information? Would each instance of open and closed brackets following this be considered an idividual line? Let me know if this doesn't make sense so I can try and re word it.

 

"body": [
        {
            "@odata.type": "#Microsoft.Dynamics.CRM.expando",
            "page": 1,
            "lines@odata.type": "#Collection(Microsoft.Dynamics.CRM.crmbaseentity)",
            "lines": [

 

 

@JStell Can you share more of the output? Like maybe paste it into a text file & attach it?

@takolota, I'll attach the output here. I removed the irrelevant information leaving on the text that I would like to extract. It is in the Format of Title then Text to be extracted. For example, the first one you will see is "text": "QC Package ID#" which would be the title of the field, followed by "text": "SW-001" which would be the extract value. In total, I have 8 fields I would like to extract.

takolota
Multi Super User
Multi Super User

@askingquestion9 & @JStell 

Here is a picture that I think may help better answer the original question of the thread asking for the lower-left quadrant

ExampleSelectLowerLeftQuad.png

@JStell 
To extract specific fields you will either need
-All the fields to be findable/filterable with simple logic like if it starts with, ends with, or contains specific characters
-Regex logic

-Pass all the text for the given document to a GPT prompt asking it to extract the data fields like in this template: https://powerusers.microsoft.com/t5/Power-Automate-Cookbook/Extract-Data-From-PDFs-and-Images-With-G... 

I tried an example like this with multiple apply to each fields, but it failed after running for 3 minutes. However I din't put it in this location so maybe that would make a difference?

 

The trouble seems to be in defining the 3rd or lower right side coordinates. The "left" or "top" fields make it easier to reference the first set in many ways, but not the other three. Would it be possible to add some math functions to add the width of the box to first "left" coordinates to give a field a "less than" side? I can't seem to actually box in the values while avoiding the apply to each trouble.

 

I did use all four fields for my filter but it is still pulling alot of unnecessary information. Heres what that looks like, let me know if you see any thing that could be improved. I have been at it all day so my brain is not up to par :D.

 

@Or(and(greaterOrEquals(item()?['boundingBox']?['left'], 0.4023454545454545),lessOrEquals(item()?['boundingBox']?['top'], 0.14263529411764705),lessOrEquals(item()?['boundingBox']?['width'], 0.033009090909091),lessOrEquals(item()?['boundingBox']?['height'], 0.012058823529411)),and(greaterOrEquals(item()?['boundingBox']?['left'], 0.3215272727272727),lessOrEquals(item()?['boundingBox']?['top'], 0.18784705882352942),lessOrEquals(item()?['boundingBox']?['width'], 0.126127272727273),lessOrEquals(item()?['boundingBox']?['height'], 0.010141176470588)),and(greaterOrEquals(item()?['boundingBox']?['left'], 0.3221363636363636),lessOrEquals(item()?['boundingBox']?['top'], 0.20941176470588235),lessOrEquals(item()?['boundingBox']?['width'], 0.122336363636364),lessOrEquals(item()?['boundingBox']?['height'], 0.01015294117647)),and(greaterOrEquals(item()?['boundingBox']?['left'], 0.3934545454545455),lessOrEquals(item()?['boundingBox']?['top'], 0.09150588235294119),lessOrEquals(item()?['boundingBox']?['width'], 0.0505272727272727),lessOrEquals(item()?['boundingBox']?['height'], 0.012199999999999989)),and(greaterOrEquals(item()?['boundingBox']?['left'], 0.028445454545454548),lessOrEquals(item()?['boundingBox']?['top'], 0.2804941176470588),lessOrEquals(item()?['boundingBox']?['width'], 0.0493545454545455),lessOrEquals(item()?['boundingBox']?['height'], 0.575941176470589)),and(greaterOrEquals(item()?['boundingBox']?['left'], 0.8116363636363637),lessOrEquals(item()?['boundingBox']?['top'], 0.28054117647058824),lessOrEquals(item()?['boundingBox']?['width'], 0.143772727272727),lessOrEquals(item()?['boundingBox']?['height'], 0.575894117647059)),and(greaterOrEquals(item()?['boundingBox']?['left'], 0.08896363636363637),lessOrEquals(item()?['boundingBox']?['top'], 0.20941176470588235),lessOrEquals(item()?['boundingBox']?['width'], 0.152254545454545),lessOrEquals(item()?['boundingBox']?['height'], 0.012823529411765)),and(greaterOrEquals(item()?['boundingBox']?['left'], 0.4629818181818182),lessOrEquals(item()?['boundingBox']?['top'], 0.28036470588235296),lessOrEquals(item()?['boundingBox']?['width'], 0.044804545454545),lessOrEquals(item()?['boundingBox']?['height'], 0.570658823529413)),and(greaterOrEquals(item()?['boundingBox']?['left'], 0.0882),lessOrEquals(item()?['boundingBox']?['top'], 0.25372941176470587),lessOrEquals(item()?['boundingBox']?['width'], 0.149381818181818),lessOrEquals(item()?['boundingBox']?['height'], 0.010141176470589)))

 

@JStell 

Okay I thought the top & left may be easier for you to create a json reference for, but to avoid needing to add field box widths / heights to things you may want to change the references to one of the 4 x & y coordinates in the polygon section of the json mentioned at the start of this thread.

But really if you have multiple pieces of text boxed around the same area of the screen it may be hard to pinpoint to the exact text box you want. You may need Regex or the GPT piece to extract the specific field from the text.

 

JStell
Frequent Visitor

@takolota,

 

It took some time, but I was able to make it work. It is pulling all 8 areas of interest without fail! If you'd like, ill send it over for you to exam and see what could be improved / simplified.

 

Thanks!

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (1,071)