Skip to content

Commit 95a2391

Browse files
committed
Rename raw-image to document-image
1 parent 33ab3e7 commit 95a2391

File tree

4 files changed

+24
-14
lines changed

4 files changed

+24
-14
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.idea
2-
example/portraitFromVisual.jpg
3-
example/normalizedInputImage.jpg
2+
example/portrait.jpg
3+
example/document-image.jpg
44

55

66
# Byte-compiled / optimized / DLL files

example/example.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
input_image = f.read()
1313

1414
with DocumentReaderApi(host) as api:
15-
api.license = license # used here only for smoke test purposes, most of clients will attach license on server side
15+
api.license = license # used here only for smoke test purposes, most clients will attach license on server side
1616

1717
params = ProcessParams(
1818
scenario=Scenario.FULL_PROCESS,
19-
result_type_output=[Result.RAW_IMAGE, Result.STATUS, Result.TEXT, Result.IMAGES]
19+
result_type_output=[Result.DOCUMENT_IMAGE, Result.STATUS, Result.TEXT, Result.IMAGES]
2020
)
2121
request = RecognitionRequest(process_params=params, images=[input_image])
2222
response = api.process(request)
@@ -34,11 +34,11 @@
3434
doc_number_mrz_visual_matching = doc_number_field.cross_source_comparison(Source.MRZ, Source.VISUAL)
3535

3636
# images fields example
37-
normalized_input_image = response.images.normalized_input_image()
37+
document_image = response.images.document_image()
3838
portrait_Field = response.images.get_field(GraphicFieldType.PORTRAIT)
3939
portrait_From_Visual = portrait_Field.get_value(Source.VISUAL)
40-
with open('portraitFromVisual.jpg', 'wb') as f: f.write(portrait_From_Visual)
41-
with open('normalizedInputImage.jpg', 'wb') as f: f.write(normalized_input_image)
40+
with open('portrait.jpg', 'wb') as f: f.write(portrait_From_Visual)
41+
with open('document-image.jpg', 'wb') as f: f.write(document_image)
4242

4343
# low-lvl(original) response
4444
response.low_lvl_response

regula/documentreader/webclient/ext/models/images.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,32 @@ def get_value(self, source: str = None, original=False) -> Optional[bytes]:
2626

2727

2828
class Images(GenImages):
29-
_normalized_input_images_results = None
29+
_document_images_results = None
3030

3131
def get_field(self, field_type: int) -> Optional[ImagesField]:
3232
for field in self.field_list:
3333
if field.field_type == field_type:
3434
return field
3535
return None
3636

37-
def normalized_input_image(self) -> Optional[bytes]:
38-
images = self.normalized_input_images()
37+
def document_image(self) -> Optional[bytes]:
38+
"""
39+
Contains cropped and rotated with perspective compensation image of document.
40+
Single input image can contain multiple document side/pages, which will be returned as separated results.
41+
Most coordinates in other types defined on that image.
42+
"""
43+
images = self.document_images()
3944
if not images:
4045
return None
4146
return images.pop()
4247

43-
def normalized_input_images(self) -> Optional[List[bytes]]:
44-
if self._normalized_input_images_results:
48+
def document_images(self) -> Optional[List[bytes]]:
49+
"""
50+
Contains cropped and rotated with perspective compensation image of document.
51+
Single input image can contain multiple document side/pages, which will be returned as separated results.
52+
Most coordinates in other types defined on that image.
53+
"""
54+
if self._document_images_results:
4555
return [base64.b64decode(image.raw_image_container.image)
46-
for image in self._normalized_input_images_results]
56+
for image in self._document_images_results]
4757
return None

regula/documentreader/webclient/ext/models/recognition_response.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def status(self) -> Optional[Status]:
3131
def images(self) -> Optional[Images]:
3232
result = self.result_by_type(Result.IMAGES)
3333
if result:
34-
result.images._normalized_input_images_results = self.results_by_type(Result.RAW_IMAGE)
34+
result.images._document_images_results = self.results_by_type(Result.DOCUMENT_IMAGE)
3535
return result.images
3636
return None
3737

0 commit comments

Comments
 (0)