1414import java .util .Map ;
1515
1616public class ScanbotSDKExample {
17- static final int SCANBOTSDK_LICENSE_CHECK_TIMEOUT_MS = 15000 ;
18-
1917 public static void main (String [] args ) throws Exception {
2018 if (args .length < 2 ) {
2119 ExampleUsage .print ();
@@ -37,71 +35,64 @@ public static void main(String[] args) throws Exception {
3735 final String writablePath = "." ;
3836
3937 ScanbotSDK .initialize (licenseKey , writablePath );
40- ScanbotSDK .waitForOnlineLicenseCheckCompletion (SCANBOTSDK_LICENSE_CHECK_TIMEOUT_MS );
4138
4239 LicenseInfo licenseInfo = ScanbotSDK .getLicenseInfo ();
4340 System .out .println ("License Status: " + licenseInfo .getStatus ());
44-
45- // If you are not using floating license, it is not required to use io.scanbot.sdk.DeviceSession as there is no
46- // need to notify server you are no longer using the license. Alternatively, you can manually call
47- // io.scanbot.sdk.ScanbotSDK.deregisterDevice and io.scanbot.sdk.ScanbotSDK.waitForDeviceDeregistrationCompletion if you need asynchronous
48- // deregistration behaviour
49- try (DeviceSession ignored = new DeviceSession (DeviceSession .DEFAULT_CLOSE_TIMEOUT_MS )) {
50- switch (category ) {
51- case "scan" : {
52- if (file == null && resource == null ) { ExampleUsage .print (); return ; }
5341
54- // NOTE: Using try-with-resources on ImageRef is optional, since images are also
55- // released when their parent container is closed. However, because images are
56- // stored compressed and decompressed on first access, it’s better to close them
57- // early to avoid keeping too many decompressed images in memory.
58- try (ImageRef image = Utils .createImageRef (file , resource )) {
59- switch (subcommand ) {
60- case "barcode" : DetectBarcodesSnippet .run (image ); break ;
61- case "document" : DetectDocumentSnippet .run (image ); break ;
62- case "check" : CheckScannerSnippet .run (image ); break ;
63- case "credit_card" : CreditCardScannerSnippet .run (image ); break ;
64- case "document_extractor" : DocumentDataExtractorSnippet .run (image ); break ;
65- case "medical_certificate" : MedicalCertificateScannerSnippet .run (image ); break ;
66- case "mrz" : MrzScannerSnippet .run (image ); break ;
67- case "ocr" : OcrSnippet .run (image ); break ;
68- case "text_pattern" : TextPatternScannerSnippet .run (image ); break ;
69- case "vin" : VINScannerSnippet .run (image ); break ;
70- default : ExampleUsage .print ();
71- }
72- }
73- break ;
74- }
75- case "analyze" : {
76- if (file == null && resource == null ) { ExampleUsage .print (); return ; }
42+ switch (category ) {
43+ case "scan" : {
44+ if (file == null && resource == null ) { ExampleUsage .print (); return ; }
45+
46+ // NOTE: Using try-with-resources on ImageRef is optional, since images are also
47+ // released when their parent container is closed. However, because images are
48+ // stored compressed and decompressed on first access, it’s better to close them
49+ // early to avoid keeping too many decompressed images in memory.
50+ try (ImageRef image = Utils .createImageRef (file , resource )) {
7751 switch (subcommand ) {
78- case "analyze_multi_page" : AnalyzeMultiPageSnippet .run (file , resource ); break ;
79- case "crop_analyze" : CropAndAnalyzeSnippet .run (file , resource , save ); break ;
52+ case "barcode" : DetectBarcodesSnippet .run (image ); break ;
53+ case "document" : DetectDocumentSnippet .run (image ); break ;
54+ case "check" : CheckScannerSnippet .run (image ); break ;
55+ case "credit_card" : CreditCardScannerSnippet .run (image ); break ;
56+ case "document_extractor" : DocumentDataExtractorSnippet .run (image ); break ;
57+ case "medical_certificate" : MedicalCertificateScannerSnippet .run (image ); break ;
58+ case "mrz" : MrzScannerSnippet .run (image ); break ;
59+ case "ocr" : OcrSnippet .run (image ); break ;
60+ case "text_pattern" : TextPatternScannerSnippet .run (image ); break ;
61+ case "vin" : VINScannerSnippet .run (image ); break ;
8062 default : ExampleUsage .print ();
8163 }
82- break ;
8364 }
84- case "classify" : {
85- if (file == null && resource == null ) { ExampleUsage .print (); return ; }
86- try (ImageRef image = Utils .createImageRef (file , resource )) {
87- switch (subcommand ) {
88- case "document" : DocumentClassifierSnippet .run (image ); break ;
89- default : ExampleUsage .print ();
90- }
91- break ;
92- }
65+ break ;
66+ }
67+ case "analyze" : {
68+ if (file == null && resource == null ) { ExampleUsage .print (); return ; }
69+ switch (subcommand ) {
70+ case "analyze_multi_page" : AnalyzeMultiPageSnippet .run (file , resource ); break ;
71+ case "crop_analyze" : CropAndAnalyzeSnippet .run (file , resource , save ); break ;
72+ default : ExampleUsage .print ();
9373 }
94- case "parse" : {
95- if (text == null || text .trim ().isEmpty ()) { ExampleUsage .print (); return ; }
74+ break ;
75+ }
76+ case "classify" : {
77+ if (file == null && resource == null ) { ExampleUsage .print (); return ; }
78+ try (ImageRef image = Utils .createImageRef (file , resource )) {
9679 switch (subcommand ) {
97- case "mrz" : MrzParserSnippet .run (text ); break ;
98- case "barcode_doc" : ParseBarcodeDocumentSnippet .run (text ); break ;
80+ case "document" : DocumentClassifierSnippet .run (image ); break ;
9981 default : ExampleUsage .print ();
10082 }
10183 break ;
10284 }
103- default : ExampleUsage .print ();
10485 }
86+ case "parse" : {
87+ if (text == null || text .trim ().isEmpty ()) { ExampleUsage .print (); return ; }
88+ switch (subcommand ) {
89+ case "mrz" : MrzParserSnippet .run (text ); break ;
90+ case "barcode_doc" : ParseBarcodeDocumentSnippet .run (text ); break ;
91+ default : ExampleUsage .print ();
92+ }
93+ break ;
94+ }
95+ default : ExampleUsage .print ();
10596 }
10697
10798 // This demonstrates that no images remain in memory, after the ImageRef has been closed.
0 commit comments