Document recognition
Last updated
Was this helpful?
Last updated
Was this helpful?
The algorithm looks for rectangular shapes on the incoming image that look like documents and cuts them out.
The Classifier assigns a class to each cut out area: Passport, Driver’s License, and so on.
The algorithm evaluates the orientation of the document in space. If necessary, the classifier rotates or mirrors the document.
The algorithm finds and cuts out information fields from the document. In a document like the passport, for example, this could be just the First Name, the Last Name, Passport Series, MRZ, etc.
The OCR algorithm reads and extracts information from the cut out information fields.
The OCR algorithm assigns a "confidence level" to the extracted information from each of the fields.
If manual OCR mode is enabled, the HITL feature processes the "cut out field + extracted text" pair.
The extracted text is verified with masks and dictionaries.
The confidence parameter in the answer shows the level of confidence of the algorithm in the correctness of character recognition:
0.90-1.00 - absolutely sure;
0.70-0.89 - quite sure;
0.50-0.69 - possible mistake in the answer;
0.01-0.49 - there must be an error in the field;
0 - there is definitely an error in the field.
The algorithm will return an empty answer with zero confidence if the digitized text does not pass the mask and dictionary checks. For example, the date of birth "56.12.1988" will not be returned as an answer.
This function compares the results of field detection with the text in your file. This is useful when you want to reconcile data from image documents with data from other sources. To use the function, optionally specify a JSON file in the verify_fields
parameter.
An example JSON file for comparing series-number and full name from RF passport with recognition results is shown below:
To compose your JSON file, copy the field names from the API specification.
The reconciliation function returns a "valid" attribute for each field of the document. Available attribute values are:
true - the field text in the JSON file and in the recognition results match;
false - the text of the field does not match;
null - the field does not exist in JSON-file.
POST
https://latest.handl.ai/recognize
external_check_fake
boolean
true - when using checks against external databases (external_check_...) no actual checking is performed, but a template response is returned (necessary for debugging) false - the check imitation is disabled
external_check_vehicle_dtp_and_restrict
boolean
true - search available Government Automobile databases for accidents involving the given vehicle and encumbrance by certificate of registration (vehicle_registration_certificate_front) false - the access to the database is disabled for this check
external_check_vehicle_wanted_list
boolean
true - search in the external databases if the vehicle is wanted by using the vehicle_registration_certificate_front or pts_front values. false - the access to the database is disabled for this check
external_check_vehicle_restrict_list
boolean
true - search in the external databases for the vehicle's encumbrance using the vehicle_registration_certificate_front or pts_front values. false - the access to the database for this check is disabled
external_check_fico
boolean
true - returns FICO financial scoring for an individual by passport (passport_main). false - this check is disabled for the database
external_check_pledges_list
boolean
true - searches external databases for outstanding debts of an individual using the given passport information (passport_main) false - database access is disabled for this check
external_check_inn
boolean
true - searches external databases to find the INN number using the given passport information (passport_main). false - reference to external databases by INN number is disabled
external_check_is_valid
boolean
true - checks document authenticity via available government databases. At the moment only passport authentication is available (doc_type="passport_main"). false - document authentication by databases is disabled.
doc_type
array
A list of document types to be recognized in the incoming file. It is used for deterministic processes, for example, if only the main passport spread needs to be processed in the flow, and all other types do not need to be answered.
priority
integer
>0, the default value is 1. Priority of asynchronous task in the queue for processing
simple_cropper
boolean
false (default) - the simplified algorithm of cutting documents from images is not used. true - the simplified algorithm of cutting documents from images is used: it is faster but less accurate. Documents in images with complex backgrounds may be cut out less accurately.
async
boolean
true - asynchronous mode of request processing. false - synchronous mode of processing requests.
check_fake_experimental
boolean
Out of date and not used.
check_fake
boolean
true - the algorithm looks for signs of modification in the file metadata via digital editors, the result is returned in a separate field called “fake”. false - the metadata checking algorithm is disabled.
use_internal_api
boolean
true - normalizes the "Issued by" field in the passport according to the embedded database. This allows you to get the text without misprints even from low-quality images, but may lead to inconsistency between the document and the result false — normalization is disabled
use_external_api
boolean
Out of date and not used.
pdf_raw_images
boolean
true - the algorithm leaves the decision of PDF files’ rasterization to the auto_pdf_raw_images parameter. false - all PDF files will be rasterized, the value of the auto_pdf_raw_images parameter will be ignored.
auto_pdf_raw_images
boolean
true - the algorithm looks for a text layer in PDF files. If it is found, the PDF will be rasterized. false - the algorithm will never rasterize PDF files.
dpi
integer
>0, , the default value is 300 - sets the number of pixels per inch for PDF rasterization. We recommend 300. Higher values usually do not increase the quality, but increase the weight of the image.
quality
integer
0-100, the default value is 75 - sets the degree of JPEG compression for PDF rasterization. The recommended value is 75 for balance between the weight of the image and its quality.
gauss
number
Out of date and is not used.
mode
string
default - the whole recognition pipeline is used; recognize_only - disables the cutting and orienting algorithms, the original image goes to the recognition stage
with_hitl
boolean
true - sends the document fields to human validators for verification and manual recognition. false - manual recognition is disabled
hitl_async
boolean
true - allows the HITL module to return the document information field values asynchronously, without waiting for the whole set of document information fields to be completed. The parameter works only when using manual document recognition mode with_hitl=true. The response with an incomplete set of fields is followed by code 202, the complete set of fields is followed by by code 200. false - switches off asynchronous HITL mode, the method will return the answer only after all the fields in the document are processed
hitl_required_fields
array
Allows for identification of required information fields in the document within the array - this tells the HITL module that it can return fields asynchronously only after the required information fields have been processed. Only works with with_hitl and hitl_async enabled.
hitl_sla
string
Not used
verify_fields
string
Activates the function of checking the fields against information in an external file (see above)
image
object
File whose contents must be p
In addition, the reconciliation function returns the levenshtein
attribute - for the recognition result and the similar field from the external JSON file.
Below is the API specification for the document recognition method. See for more information on how to put together a recognition request.