diff --git a/example/example.py b/example/example.py index 018de07..620c23d 100755 --- a/example/example.py +++ b/example/example.py @@ -26,23 +26,17 @@ "X-CLIENT-KEY": "123", "Authorization": "Bearer 123" } - params = ProcessParams( - scenario=Scenario.FULL_PROCESS, - result_type_output=[ - # actual results - Result.STATUS, Result.AUTHENTICITY, Result.TEXT, Result.IMAGES, - Result.DOCUMENT_TYPE, Result.DOCUMENT_TYPE_CANDIDATES, Result.IMAGE_QUALITY, - Result.DOCUMENT_POSITION, - # legacy results - Result.MRZ_TEXT, Result.VISUAL_TEXT, Result.BARCODE_TEXT, Result.RFID_TEXT, - Result.VISUAL_GRAPHICS, Result.BARCODE_GRAPHICS, Result.RFID_GRAPHICS, - Result.LEXICAL_ANALYSIS - ] - ) + params = ProcessParams(already_cropped=True, scenario=Scenario.FULL_PROCESS) + + # Add license to request + # request = RecognitionRequest(system_info=ProcessSystemInfo(license="license"), process_params=params, images=[ + # RecognitionImage(image=white_page_0, light_index=Light.WHITE, page_index=0), + # ]) + request = RecognitionRequest(process_params=params, images=[ RecognitionImage(image=white_page_0, light_index=Light.WHITE, page_index=0), - RecognitionImage(image=ir_page_0, light_index=Light.IR, page_index=0), - RecognitionImage(image=uv_page_0, light_index=Light.UV, page_index=0), + # RecognitionImage(image=ir_page_0, light_index=Light.IR, page_index=0), + # RecognitionImage(image=uv_page_0, light_index=Light.UV, page_index=0), ]) response = api.process(request) @@ -53,6 +47,7 @@ response_status = response.status doc_overall_status = "valid" if response_status.overall_status == CheckResult.OK else "not valid" + # text fields example doc_number_field = response.text.get_field(TextFieldType.DOCUMENT_NUMBER) doc_number_field_by_name = response.text.get_field_by_name("Document Number") @@ -85,21 +80,16 @@ f.write(portrait_from_visual) with open('document-image.jpg', 'wb') as f: f.write(document_image) - - print(""" + print(f""" --------------------------------------------------------------------------- - Web API version: {ping_version} + Web API version: {api.ping().version} --------------------------------------------------------------------------- - Document Overall Status: {doc_overall_status} + Document Overall Status: {doc_overall_status} Document Number Visual: {doc_number_visual} - Document Number MRZ: {doc_number_mrz} - Validity Of Document Number Visual: {doc_number_visual_validity} - Validity Of Document Number MRZ: {doc_number_mrz_validity} - MRZ-Visual values comparison: {doc_number_mrz_visual_matching} - --------------------------------------------------------------------------- - """.format( - ping_version=api.ping().version, - doc_overall_status=doc_overall_status, doc_number_visual=doc_number_visual, - doc_number_mrz=doc_number_mrz, doc_number_visual_validity=doc_number_mrz_validity, - doc_number_mrz_validity=doc_number_mrz_validity, doc_number_mrz_visual_matching=doc_number_mrz_visual_matching, - )) + Document Type: {response.result_by_type(result_type=Result.DOCUMENT_TYPE).one_candidate.document_name} + Validity Of Document Number Visual: {doc_number_visual_validity} + """) + + print("-----------------------All Text Fields------------------------") + for field in response.text.field_list: + print(f"Source: {field.field_name}, Value: {field.value}") diff --git a/regula/documentreader/webclient/ext/models/recognition_request.py b/regula/documentreader/webclient/ext/models/recognition_request.py index fbe30ad..2296a12 100755 --- a/regula/documentreader/webclient/ext/models/recognition_request.py +++ b/regula/documentreader/webclient/ext/models/recognition_request.py @@ -61,9 +61,11 @@ def __init__(self, _encrypted_rcl: Union[bytes, Base64String] = None, class RecognitionRequest(ProcessRequest): def __init__( - self, process_params: ProcessParams, + self, + process_params: ProcessParams, images: List[Union[RecognitionImage, bytes, Base64String]] = None, - container_list: ContainerList = None, tag=None + container_list: ContainerList = None, tag=None, + system_info: ProcessSystemInfo = ProcessSystemInfo(), ): input_images = [] if images: @@ -74,12 +76,12 @@ def __init__( input_images.append(image) super().__init__( process_param=process_params, list=input_images, - system_info=ProcessSystemInfo(), tag=tag + system_info=system_info, tag=tag ) if container_list: super().__init__( process_param=process_params, container_list=container_list, - system_info=ProcessSystemInfo(), tag=tag + system_info=system_info, tag=tag ) @property