|
| 1 | +import java.nio.file.Paths; |
| 2 | +import java.util.Scanner; |
| 3 | + |
1 | 4 | import com.dynamsoft.core.EnumErrorCode; |
| 5 | +import com.dynamsoft.core.basic_structures.FileImageTag; |
| 6 | +import com.dynamsoft.core.basic_structures.ImageTag; |
2 | 7 | import com.dynamsoft.cvr.CaptureVisionException; |
3 | 8 | import com.dynamsoft.cvr.CaptureVisionRouter; |
4 | 9 | import com.dynamsoft.cvr.CapturedResult; |
|
8 | 13 | import com.dynamsoft.license.LicenseException; |
9 | 14 | import com.dynamsoft.license.LicenseManager; |
10 | 15 |
|
11 | | -import java.nio.file.Paths; |
12 | | -import java.util.Scanner; |
13 | | - |
14 | 16 | public class ReadDPMBarcode { |
15 | 17 | public static void main(String[] args) { |
16 | 18 | Scanner scanner = new Scanner(System.in); |
@@ -62,12 +64,15 @@ public static void main(String[] args) { |
62 | 64 | System.out.println("Error: " + result.getErrorCode() + ", " + result.getErrorString()); |
63 | 65 | } |
64 | 66 |
|
65 | | - DecodedBarcodesResult barcodeResult = result != null ? result.getDecodedBarcodesResult() : null; |
| 67 | + ImageTag tag = result.getOriginalImageTag(); |
| 68 | + int pageNumber = tag instanceof FileImageTag ? ((FileImageTag)tag).getPageNumber() : index; |
| 69 | + |
| 70 | + DecodedBarcodesResult barcodeResult = result.getDecodedBarcodesResult(); |
66 | 71 | BarcodeResultItem[] items = barcodeResult != null ? barcodeResult.getItems() : null; |
67 | 72 | if (items == null || items.length == 0) { |
68 | | - System.out.println("Page-" + (index + 1) + " No barcode detected."); |
| 73 | + System.out.println("Page-" + (pageNumber + 1) + " No barcode detected."); |
69 | 74 | } else { |
70 | | - System.out.println("Page-" + (index + 1) + " Decoded " + items.length + " barcodes."); |
| 75 | + System.out.println("Page-" + (pageNumber + 1) + " Decoded " + items.length + " barcodes."); |
71 | 76 | for (int i = 0; i < items.length; i++) { |
72 | 77 | BarcodeResultItem item = items[i]; |
73 | 78 | System.out.println(); |
|
0 commit comments