|
53 | 53 | if results is None or len(results) == 0: |
54 | 54 | print("No barcode detected.") |
55 | 55 | else: |
56 | | - for result in results: |
| 56 | + for i, result in enumerate(results): |
| 57 | + page_number = i + 1 |
| 58 | + tag = result.get_original_image_tag() |
| 59 | + if isinstance(tag, FileImageTag): |
| 60 | + page_number = tag.get_page_number() + 1 |
| 61 | + |
57 | 62 | if result.get_error_code() == EnumErrorCode.EC_UNSUPPORTED_JSON_KEY_WARNING: |
58 | 63 | print("Warning:", result.get_error_code(), result.get_error_string()) |
59 | 64 | elif result.get_error_code() != EnumErrorCode.EC_OK: |
60 | 65 | print("Error:", result.get_error_code(), result.get_error_string()) |
61 | 66 |
|
62 | 67 | barcode_result = result.get_decoded_barcodes_result() |
63 | 68 | if barcode_result is None or barcode_result.get_items() == 0: |
64 | | - print("No barcode detected.") |
| 69 | + print("No barcode found in page", page_number) |
65 | 70 | else: |
66 | 71 | items = barcode_result.get_items() |
67 | | - print("Decoded", len(items), "barcodes.") |
| 72 | + print("Page", page_number, "decoded", len(items), "barcodes.") |
68 | 73 | for index,item in enumerate(items): |
69 | 74 | print() |
70 | | - print("Barcode", index) |
| 75 | + print("Result", str(page_number) + "-" + str(index + 1)) |
71 | 76 | print("Barcode Format:", item.get_format_string()) |
72 | 77 | print("Barcode Text:", item.get_text()) |
73 | 78 | print() |
|
0 commit comments