RPA.DocumentAI.Base64AI
module RPA.Base64AI
class RPA.DocumentAI.Base64AI.Base64AI
Library to support Base64.ai service for intelligent document processing (IDP).
Library requires at the minimum rpaframework version 19.0.0.
Service supports identifying fields in the documents, which can be given to the service in multiple different file formats and via URL.
Robot Framework example usage
Python example usage
Portal example: https://github.com/robocorp/example-idp-base64
variable BASE_URL
variable ROBOT_LIBRARY_DOC_FORMAT
variable ROBOT_LIBRARY_SCOPE
method filter_matching_signatures
Gets through all the recognized signatures in the queried image and returns only the ones passing the confidence & similarity thresholds.
Additionally, this keyword simplifies the original input match_response structure and returns a dictionary with all the detected and accepted reference signatures as keys, and lists of similar enough query signatures as values.
- Each reference signature (key) is a tuple of (index, coordinates).
- Each query signature (sub-value) is a dictionary of {index, coords, similarity}.
- The coordinates describe the bounding-box enclosing the detected signature portion from the original image, as follows: (left, top, right, bottom) corners.
Use the original match_response object and the indexes from here if you need
to retrieve extra details not found here (e.g. confidence score). Use the
Get Signature Image
to save and preview the image crop belonging to the
signature of choice.
Parameters
- match_response β The raw JSON-like response retrieved with the
Get Matching Signatures
keyword. - confidence_threshold β The minimum accepted confidence score (0.0-1.0) for a candidate to be considered a signature. (to avoid false-positives)
- similarity_threshold β The minimum accepted similarity score (0.0-1.0) for a query signature to be considered an alike signature. (to discard different or fraudulent signatures)
- Returns: A dictionary of accepted reference signatures and their similar ones found in the queried image.
Example: Robot Framework
Example: Python
method get_fields_from_prediction_result
Helper keyword to get found fields from a prediction result.
For example see Scan Document File
or Scan Document URL
keyword.
- Parameters: prediction β prediction result dictionary
- Returns: list of found fields
method get_matching_signatures
Returns a list of matching signatures found from the reference into the queried image.
The input images can be paths to the files or URLs.
The output JSON-like dictionary contains all the details from the API, like the
detected signatures in both the reference and query image and for every such
signature, its bounding-box geometry, confidence and similarity score.
Use the Filter Matching Signatures
over this value to get a simpler
structure.
Parameters
- reference_image β The reference image (jpg/png) to check query signatures against. (e.g. driving license, ID card)
- query_image β The query image containing signatures similar to the ones from the reference image. (e.g. signed contract, bank check)
- Returns: A JSON-like dictionary revealing recognized signatures and how much they resemble with each other.
Example: Robot Framework
Example: Python
Portal example: https://github.com/robocorp/example-signature-match-assistant
method get_signature_image
Retrieves and saves locally the image cut belonging to the provided index.
The image data itself is provided with the original match_response object as base64 encoded content. This utility keyword retrieves, decodes and saves it on the local disk customized with the path parameter. By default, the searched index is considered a query image, switch to the reference type by enabling it with the reference parameter.
Parameters
- match_response β The raw JSON-like response retrieved with the
Get Matching Signatures
keyword. - index β The image ID (numeric) found along the coordinates in the output
of the
Filter Matching Signatures
keyword. (the list order is stable) - reference β Set this to True if youβre looking for a reference (not query) image instead. (off by default)
- path β Set an explicit output path (including file name) for the locally saved image. (uses the output directory as default)
- Returns: The image path of the locally saved file.
Example: Robot Framework
Example: Python
method get_user_data
Get user data including details on credits used and credits remaining for the Base64 service.
Returned user data contains following keys:
- givenName
- familyName
- hasWorkEmail
- companyName
- numberOfCredits
- numberOfPages
- numberOfUploads
- numberOfCreditsSpentOnDocuments (visible if used)
- numberOfCreditsSpentOnFaceDetection (visible if used)
- numberOfCreditsSpentOnFaceRecognition (visible if used)
- hasActiveAwsContract
- subscriptionType
- subscriptionPeriod
- tags
- ccEmails
- status
- remainingCredits (calculated by the keyword)
- Returns: object containing details on the API user
Robot Framework example:
Python example:
method scan_document_file
Scan a document file. Can be given a model_types
to
specifically target certain models.
Parameters
- file_path β filepath to the file
- model_types β single model type or list of model types
- mock β set to True to use /mock/scan endpoint instead of /scan
- Returns: result of the document scan
Robot Framework example:
Python example:
method scan_document_url
Scan a document URL. Can be given a model_types
to
specifically target certain models.
Parameters
- url β valid url to a file
- model_types β single model type or list of model types
- mock β set to True to use /mock/scan endpoint instead of /scan
- Returns: result of the document scan
Robot Framework example:
Python example:
method set_authorization
Set Base64 AI request headers with email and key related to API.
Parameters
- api_email β email address related to the API
- api_key β key related to the API
Robot Framework example:
Python example: