0

I have regular digital forms with blanks, boxes, checkboxes, tables, and signature fields. My aim is to extract the field name along with its fillable coordinates.

For e.g. if form has a field named "Name of benificiary" and has it's corresponding blank space at (x=500,y=750), I require the field Name and it blank space coordinates.

AWS and Azure, didn't provide blank space coordinates. Please let me know if there is any existing library or model to capture the names and their corresponding blank spaces.

If in case, I have to develop a custom model, kindly suggest a baseline model i can start with and how can i tell my model which field name to map with which blank space.

Thanks in advance.

Sample forms are: enter image description here

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
R.K
  • 1,721
  • 17
  • 22

1 Answers1

1

Amazon Textract allows you to do that, it can help you extract the Key fields and the area where the value would go, even if the value is not filled.

You can use the amazon-textract-textractor package to simplify calling and parsing the Amazon Textract API.

Using your provided sample:

from textractor import Textractor
from textractor.data.constants import TextractFeatures
extractor = Textractor(profile_name="default")
document = extractor.analyze_document(
    file_source="./az0HQ.png",
    features=[TextractFeatures.FORMS],
)
document.visualize()

enter image description here

You can access the bounding box of the value field that way:

document.key_values[1]
> Date of issue : 

This is a key value with "Date of issue:" as the key, you can access the fillable value bbox like this:

document.key_values[1].value.bbox
> x: 0.4474363923072815, y: 0.10488211363554001, width: 0.02369014546275139, height: 0.01737912744283676
Thomas
  • 676
  • 3
  • 18
  • One Query... AWS returns coordinates in decimals, while the same when I try with Opencv, they are decimal numbers greater than 0. Why is that? – R.K Mar 02 '23 at 08:09
  • 1
    Do you mean greater than 1? If so that's because Textract uses relative coordinates. You can get the absolute positions by multiplying by the image width and height. – Belval Mar 02 '23 at 14:43