Handprint text recognition in form documents.
conda env create -f conda_env.yaml
The tool also requires zbar shared library installed.
This functionality is split (for now) into two separate scripts.
Script select_ROIs.py
is used to find and define locations of regions of interest (ROIs) in the given PDF.
Generally, it is possible to draw ROIs (rectangles) manually but also to detect them automatically. The coordinates of ROIs are stored in a JSON file.
The tool is supposed to be run from the command line, as the control commands are entered there.
Control commands
q
or Esc
to exit editing and save the config file.r
to remove the last rectangle.Run python select_ROIs.py -h
for details.
Script annotate_ROIs.py
is used to specify the type of content for each rectangle.
The workflow is designed in a way that you can navigate over specified ROIs and assign them the expected type of their content. This is done by pressing appropriate control commands.
Control commands
q
or Esc
to exit editing and save the config file.h
to add "Handwritten" type to the current ROI.c
to add "Checkbox" type to the current ROI.b
to add "Barcode" type to the current ROI.r
or d
to delete the type from the current ROI.v
to enter the variable name.Run python select_ROIs.py -h
for details.
Script process_logsheet.py
is used to extract values from specified ROIs.
This is the crucial step that applies various techniques to extract the information as precisely as possible. It can process one logsheet at a time, given the template and config files.
Run python select_ROIs.py -h
for details.
The processing of logsheets is using external services requiring credentials to use them. Here we specify structure that is expected for credentials, always in JSON format.
{
"type": "service_account",
"project_id": "theid",,
"private_key_id": "thekey",
"private_key": "-----BEGIN PRIVATE KEY-----anotherkey-----END PRIVATE KEY-----\n"
"client_email": "emailaddress",
"client_id": "id",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "someurl",
"universe_domain": "googleapis.com"
}
Amazon
{
"ACCESS_KEY": "YOUR_KEY_ID_HERE",
"SECRET_KEY": "YOUR_ACCESS_KEY_HERE",
"REGION": "YOUR_REGION_NAME_HERE"
}
Microsoft
{
"SUBSCRIPTION_KEY": "YOURKEYHERE",
"ENDPOINT": "https://ENDPOINT"
}
It is possible to test logsheet processing using dry run without credentials on data stored in tests/
.
Run python dry_processing.py -h
for details.