@@ -13,56 +13,58 @@ internal static class Program
13
13
private const string API_BASE_PATH = "API_BASE_PATH" ;
14
14
private const string TEST_LICENSE = "TEST_LICENSE" ;
15
15
private const string LICENSE_FILE_NAME = "regula.license" ;
16
-
16
+
17
17
public static void Main ( )
18
18
{
19
- string apiBaseUrl = Environment . GetEnvironmentVariable ( API_BASE_PATH ) ?? "https://api.regulaforensics.com" ;
19
+ var apiBaseUrl = Environment . GetEnvironmentVariable ( API_BASE_PATH ) ?? "https://api.regulaforensics.com" ;
20
20
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 )
24
25
: null ;
25
-
26
+
26
27
var whitePage0 = File . ReadAllBytes ( "WHITE.jpg" ) ;
27
28
var irPage0 = File . ReadAllBytes ( "IR.jpg" ) ;
28
29
var uvPage0 = File . ReadAllBytes ( "UV.jpg" ) ;
29
-
30
+
30
31
var requestParams = new RecognitionParams ( )
31
- . WithScenario ( Scenario . FULL_PROCESS )
32
+ . WithScenario ( Scenario . FULL_AUTH )
32
33
. WithResultTypeOutput ( new List < int >
33
34
{
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
47
42
} ) ;
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
49
51
? new DocumentReaderApi ( apiBaseUrl ) . WithLicense ( licenseFromEnv )
50
52
: new DocumentReaderApi ( apiBaseUrl ) . WithLicense ( licenseFromFile ) ;
51
-
53
+
52
54
var response = api . Process ( request ) ;
53
-
55
+
54
56
// overall status results
55
57
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" ;
58
60
59
61
// text results
60
62
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 ) ;
66
68
67
69
var docAuthenticity = response . Authenticity ( ) ;
68
70
var docIRB900 = docAuthenticity . IrB900Checks ( ) ;
@@ -90,12 +92,12 @@ public static void Main()
90
92
var documentImage = response . Images ( ) . GetField ( GraphicFieldType . DOCUMENT_FRONT ) . GetValue ( ) ;
91
93
var portraitField = response . Images ( ) . GetField ( GraphicFieldType . PORTRAIT ) ;
92
94
var portraitFromVisual = portraitField . GetValue ( Source . VISUAL ) ;
93
-
95
+
94
96
File . WriteAllBytes ( "document-image.jpg" , documentImage ) ;
95
97
File . WriteAllBytes ( "portrait.jpg" , portraitFromVisual ) ;
96
98
97
99
// how to get low lvl individual results
98
100
// var lexResult = response.ResultByType<LexicalAnalysisResult>(Result.LEXICAL_ANALYSIS);
99
101
}
100
102
}
101
- }
103
+ }
0 commit comments