@@ -13,56 +13,58 @@ internal static class Program
1313 private const string API_BASE_PATH = "API_BASE_PATH" ;
1414 private const string TEST_LICENSE = "TEST_LICENSE" ;
1515 private const string LICENSE_FILE_NAME = "regula.license" ;
16-
16+
1717 public static void Main ( )
1818 {
19- string apiBaseUrl = Environment . GetEnvironmentVariable ( API_BASE_PATH ) ?? "https://api.regulaforensics.com" ;
19+ var apiBaseUrl = Environment . GetEnvironmentVariable ( API_BASE_PATH ) ?? "https://api.regulaforensics.com" ;
2020
21- string licenseFromEnv = Environment . GetEnvironmentVariable ( TEST_LICENSE ) ; // optional, used here only for smoke test purposes
22- var licenseFromFile = File . Exists ( LICENSE_FILE_NAME )
23- ? File . ReadAllBytes ( LICENSE_FILE_NAME )
21+ var licenseFromEnv =
22+ Environment . GetEnvironmentVariable ( TEST_LICENSE ) ; // optional, used here only for smoke test purposes
23+ var licenseFromFile = File . Exists ( LICENSE_FILE_NAME )
24+ ? File . ReadAllBytes ( LICENSE_FILE_NAME )
2425 : null ;
25-
26+
2627 var whitePage0 = File . ReadAllBytes ( "WHITE.jpg" ) ;
2728 var irPage0 = File . ReadAllBytes ( "IR.jpg" ) ;
2829 var uvPage0 = File . ReadAllBytes ( "UV.jpg" ) ;
29-
30+
3031 var requestParams = new RecognitionParams ( )
31- . WithScenario ( Scenario . FULL_PROCESS )
32+ . WithScenario ( Scenario . FULL_AUTH )
3233 . WithResultTypeOutput ( new List < int >
3334 {
34- // actual results
35- Result . STATUS , Result . AUTHENTICITY , Result . TEXT , Result . IMAGES ,
36- Result . DOCUMENT_TYPE , Result . DOCUMENT_TYPE_CANDIDATES , Result . DOCUMENT_POSITION ,
37- // legacy results
38- Result . MRZ_TEXT , Result . VISUAL_TEXT , Result . BARCODE_TEXT , Result . RFID_TEXT ,
39- Result . VISUAL_GRAPHICS , Result . BARCODE_GRAPHICS , Result . RFID_GRAPHICS ,
40- Result . LEXICAL_ANALYSIS , Result . IMAGE_QUALITY
41- } ) ;
42-
43- var request = new RecognitionRequest ( requestParams , new List < ProcessRequestImage > {
44- new ProcessRequestImage ( new ImageData ( whitePage0 ) , Light . WHITE ) ,
45- new ProcessRequestImage ( new ImageData ( irPage0 ) , Light . IR ) ,
46- new ProcessRequestImage ( new ImageData ( uvPage0 ) , Light . UV ) ,
35+ // actual results
36+ Result . STATUS , Result . AUTHENTICITY , Result . TEXT , Result . IMAGES ,
37+ Result . DOCUMENT_TYPE , Result . DOCUMENT_TYPE_CANDIDATES , Result . DOCUMENT_POSITION ,
38+ // legacy results
39+ Result . MRZ_TEXT , Result . VISUAL_TEXT , Result . BARCODE_TEXT , Result . RFID_TEXT ,
40+ Result . VISUAL_GRAPHICS , Result . BARCODE_GRAPHICS , Result . RFID_GRAPHICS ,
41+ Result . LEXICAL_ANALYSIS , Result . IMAGE_QUALITY
4742 } ) ;
48- var api = licenseFromEnv != null
43+
44+ var request = new RecognitionRequest ( requestParams , new List < ProcessRequestImage >
45+ {
46+ new ProcessRequestImage ( new ImageData ( whitePage0 ) , Light . WHITE ) ,
47+ new ProcessRequestImage ( new ImageData ( irPage0 ) , Light . IR ) ,
48+ new ProcessRequestImage ( new ImageData ( uvPage0 ) , Light . UV )
49+ } ) ;
50+ var api = licenseFromEnv != null
4951 ? new DocumentReaderApi ( apiBaseUrl ) . WithLicense ( licenseFromEnv )
5052 : new DocumentReaderApi ( apiBaseUrl ) . WithLicense ( licenseFromFile ) ;
51-
53+
5254 var response = api . Process ( request ) ;
53-
55+
5456 // overall status results
5557 var status = response . Status ( ) ;
56- string docOverallStatus = status . OverallStatus == CheckResult . OK ? "valid" : "not valid" ;
57- string docOpticalTextStatus = status . DetailsOptical . Text == CheckResult . OK ? "valid" : "not valid" ;
58+ var docOverallStatus = status . OverallStatus == CheckResult . OK ? "valid" : "not valid" ;
59+ var docOpticalTextStatus = status . DetailsOptical . Text == CheckResult . OK ? "valid" : "not valid" ;
5860
5961 // text results
6062 var docNumberField = response . Text ( ) . GetField ( TextFieldType . DOCUMENT_NUMBER ) ;
61- string docNumberVisual = docNumberField . GetValue ( Source . VISUAL ) ;
62- string docNumberMrz = docNumberField . GetValue ( Source . MRZ ) ;
63- int docNumberVisualValidity = docNumberField . SourceValidity ( Source . VISUAL ) ;
64- int docNumberMrzValidity = docNumberField . SourceValidity ( Source . MRZ ) ;
65- int docNumberMrzVisualMatching = docNumberField . CrossSourceComparison ( Source . MRZ , Source . VISUAL ) ;
63+ var docNumberVisual = docNumberField . GetValue ( Source . VISUAL ) ;
64+ var docNumberMrz = docNumberField . GetValue ( Source . MRZ ) ;
65+ var docNumberVisualValidity = docNumberField . SourceValidity ( Source . VISUAL ) ;
66+ var docNumberMrzValidity = docNumberField . SourceValidity ( Source . MRZ ) ;
67+ var docNumberMrzVisualMatching = docNumberField . CrossSourceComparison ( Source . MRZ , Source . VISUAL ) ;
6668
6769 var docAuthenticity = response . Authenticity ( ) ;
6870 var docIRB900 = docAuthenticity . IrB900Checks ( ) ;
@@ -90,12 +92,12 @@ public static void Main()
9092 var documentImage = response . Images ( ) . GetField ( GraphicFieldType . DOCUMENT_FRONT ) . GetValue ( ) ;
9193 var portraitField = response . Images ( ) . GetField ( GraphicFieldType . PORTRAIT ) ;
9294 var portraitFromVisual = portraitField . GetValue ( Source . VISUAL ) ;
93-
95+
9496 File . WriteAllBytes ( "document-image.jpg" , documentImage ) ;
9597 File . WriteAllBytes ( "portrait.jpg" , portraitFromVisual ) ;
9698
9799 // how to get low lvl individual results
98100 // var lexResult = response.ResultByType<LexicalAnalysisResult>(Result.LEXICAL_ANALYSIS);
99101 }
100102 }
101- }
103+ }
0 commit comments