|
7 | 7 | class ImagesField(GetImagesField): |
8 | 8 |
|
9 | 9 | def get_value(self, source: str = None, original=False) -> Optional[bytes]: |
10 | | - field_value = None |
| 10 | + |
11 | 11 | if not source: |
12 | | - field_value = self.get_value(Source.RFID) |
13 | | - if not field_value: field_value = self.get_value(Source.VISUAL) |
14 | | - if not field_value: field_value = self.get_value(Source.BARCODE) |
| 12 | + value = self.get_value(Source.RFID) |
| 13 | + if not value: value = self.get_value(Source.VISUAL) |
| 14 | + if not value: value = self.get_value(Source.BARCODE) |
| 15 | + if not value: value = self.get_value("UNKNOWN") # temp fix, will be removed |
| 16 | + return value |
15 | 17 | else: |
| 18 | + field_value = None |
16 | 19 | for v in self.value_list: |
17 | 20 | if v.source == source: |
18 | 21 | field_value = v |
19 | 22 |
|
20 | | - if not field_value: |
21 | | - return None |
| 23 | + if not field_value: |
| 24 | + return None |
22 | 25 |
|
23 | | - if original: |
24 | | - return base64.b64decode(field_value.original_value) |
25 | | - return base64.b64decode(field_value.value) |
| 26 | + if original: |
| 27 | + return base64.b64decode(field_value.original_value) |
| 28 | + return base64.b64decode(field_value.value) |
26 | 29 |
|
27 | 30 |
|
28 | 31 | class Images(GenImages): |
29 | | - _document_images_results = None |
30 | 32 |
|
31 | 33 | def get_field(self, field_type: int) -> Optional[ImagesField]: |
32 | 34 | for field in self.field_list: |
33 | 35 | if field.field_type == field_type: |
34 | 36 | return field |
35 | 37 | return None |
36 | 38 |
|
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() |
44 | | - if not images: |
45 | | - return None |
46 | | - return images.pop() |
47 | | - |
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: |
55 | | - return [base64.b64decode(image.raw_image_container.image) |
56 | | - for image in self._document_images_results] |
57 | | - return None |
| 39 | + def get_fields(self, field_type: int) -> List[ImagesField]: |
| 40 | + return [field for field in self.field_list if field.field_type == field_type] |
0 commit comments