How Can I extract data from tilt invoice based on Saved coordinate of labels?

32 Views Asked by At

I am using google vision for OCR, I get invoice Json from google vision Saving it to local storage Sample JSON :

 {
      "boundingPoly": {
        "vertices": [
          {
            "x": 194,
            "y": 127
          },
          {
            "x": 224,
            "y": 128
          },
          {
            "x": 223,
            "y": 148
          },
          {
            "x": 193,
            "y": 147
          }
        ]
      },
      "description": "Ph"
    }

And using https://fengyuanchen.github.io/cropperjs/ for getting the coordinates of specific labels from invoice what I am doing with the below logic, I get coordinated from cropper and saving coordinates in database When the next invoice will be uploaded so based on the saved coordinates. I am fetching data from new invoice

 const filteredCoordinates = vertices.filter(
      (obj) =>
        obj.boundingPoly.vertices[0].x >= startX &&
        obj.boundingPoly.vertices[2].x <= endX &&
        obj.boundingPoly.vertices[0].y >= startY &&
        obj.boundingPoly.vertices[2].y <= endY
    );

By default the code matching saved coordinates and new invoice coordinates, fetching nearest value of labels.

But the issue is the new invoice angle is little tilt so the logic is fetch irrelevant data for saved labels.

How can I resolve this issue?

0

There are 0 best solutions below