@regulaforensics/cordova-plugin-document-reader-api 6.8.0 → 6.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/example/config.xml +1 -8
- package/example/package.json +8 -12
- package/example/www/js/index.js +21 -10
- package/package.json +1 -1
- package/plugin.xml +2 -2
- package/src/android/BluetoothUtil.kt +6 -6
- package/src/android/DocumentReader.java +147 -136
- package/src/android/Helpers.java +117 -3
- package/src/android/JSONConstructor.java +182 -261
- package/src/android/RegulaConfig.java +114 -26
- package/src/android/build.gradle +9 -1
- package/src/ios/RGLWDocumentReader.m +42 -36
- package/src/ios/RGLWJSONConstructor.h +8 -6
- package/src/ios/RGLWJSONConstructor.m +109 -92
- package/src/ios/RGLWRegulaConfig.h +2 -1
- package/src/ios/RGLWRegulaConfig.m +139 -41
- package/www/DocumentReader.js +263 -2958
|
@@ -1,180 +1,31 @@
|
|
|
1
1
|
package cordova.plugin.documentreader;
|
|
2
2
|
|
|
3
|
-
import static
|
|
3
|
+
import static cordova.plugin.documentreader.Helpers.*;
|
|
4
4
|
|
|
5
5
|
import android.content.Context;
|
|
6
6
|
import android.graphics.Bitmap;
|
|
7
7
|
import android.graphics.Rect;
|
|
8
|
-
import android.os.Bundle;
|
|
9
8
|
import android.util.Base64;
|
|
10
9
|
|
|
11
|
-
import com.regula.
|
|
12
|
-
import com.regula.documentreader.api.
|
|
13
|
-
import com.regula.documentreader.api.
|
|
14
|
-
import com.regula.documentreader.api.enums
|
|
15
|
-
import com.regula.documentreader.api.
|
|
16
|
-
import com.regula.documentreader.api.
|
|
17
|
-
import com.regula.documentreader.api.params.
|
|
18
|
-
import com.regula.documentreader.api.
|
|
19
|
-
import com.regula.documentreader.api.
|
|
20
|
-
import com.regula.documentreader.api.
|
|
21
|
-
import com.regula.documentreader.api.params.rfid.authorization.PAAttribute;
|
|
22
|
-
import com.regula.documentreader.api.params.rfid.authorization.PAResourcesIssuer;
|
|
23
|
-
import com.regula.documentreader.api.params.rfid.authorization.TAChallenge;
|
|
24
|
-
import com.regula.documentreader.api.results.Bounds;
|
|
25
|
-
import com.regula.documentreader.api.results.BytesData;
|
|
26
|
-
import com.regula.documentreader.api.results.Coordinate;
|
|
27
|
-
import com.regula.documentreader.api.results.DocReaderDocumentsDatabase;
|
|
28
|
-
import com.regula.documentreader.api.results.DocReaderFieldRect;
|
|
29
|
-
import com.regula.documentreader.api.results.DocumentReaderBarcodeField;
|
|
30
|
-
import com.regula.documentreader.api.results.DocumentReaderBarcodeResult;
|
|
31
|
-
import com.regula.documentreader.api.results.DocumentReaderComparison;
|
|
32
|
-
import com.regula.documentreader.api.results.DocumentReaderDocumentType;
|
|
33
|
-
import com.regula.documentreader.api.results.DocumentReaderGraphicField;
|
|
34
|
-
import com.regula.documentreader.api.results.DocumentReaderGraphicResult;
|
|
35
|
-
import com.regula.documentreader.api.results.DocumentReaderNotification;
|
|
36
|
-
import com.regula.documentreader.api.results.DocumentReaderResults;
|
|
37
|
-
import com.regula.documentreader.api.results.DocumentReaderResultsStatus;
|
|
38
|
-
import com.regula.documentreader.api.results.DocumentReaderRfidOrigin;
|
|
39
|
-
import com.regula.documentreader.api.results.DocumentReaderScenario;
|
|
40
|
-
import com.regula.documentreader.api.results.DocumentReaderSymbol;
|
|
41
|
-
import com.regula.documentreader.api.results.DocumentReaderTextField;
|
|
42
|
-
import com.regula.documentreader.api.results.DocumentReaderTextResult;
|
|
43
|
-
import com.regula.documentreader.api.results.DocumentReaderTextSource;
|
|
44
|
-
import com.regula.documentreader.api.results.DocumentReaderValidity;
|
|
45
|
-
import com.regula.documentreader.api.results.DocumentReaderValue;
|
|
46
|
-
import com.regula.documentreader.api.results.ElementPosition;
|
|
47
|
-
import com.regula.documentreader.api.results.ImageQuality;
|
|
48
|
-
import com.regula.documentreader.api.results.ImageQualityGroup;
|
|
49
|
-
import com.regula.documentreader.api.results.VDSNCData;
|
|
50
|
-
import com.regula.documentreader.api.results.authenticity.DocumentReaderAuthenticityCheck;
|
|
51
|
-
import com.regula.documentreader.api.results.authenticity.DocumentReaderAuthenticityElement;
|
|
52
|
-
import com.regula.documentreader.api.results.authenticity.DocumentReaderAuthenticityResult;
|
|
53
|
-
import com.regula.documentreader.api.results.rfid.AccessControlProcedureType;
|
|
54
|
-
import com.regula.documentreader.api.results.rfid.Application;
|
|
55
|
-
import com.regula.documentreader.api.results.rfid.Attribute;
|
|
56
|
-
import com.regula.documentreader.api.results.rfid.Authority;
|
|
57
|
-
import com.regula.documentreader.api.results.rfid.CardProperties;
|
|
58
|
-
import com.regula.documentreader.api.results.rfid.CertificateChain;
|
|
59
|
-
import com.regula.documentreader.api.results.rfid.CertificateData;
|
|
60
|
-
import com.regula.documentreader.api.results.rfid.Extension;
|
|
61
|
-
import com.regula.documentreader.api.results.rfid.File;
|
|
62
|
-
import com.regula.documentreader.api.results.rfid.FileData;
|
|
63
|
-
import com.regula.documentreader.api.results.rfid.RFIDSessionData;
|
|
64
|
-
import com.regula.documentreader.api.results.rfid.SecurityObject;
|
|
65
|
-
import com.regula.documentreader.api.results.rfid.SecurityObjectCertificates;
|
|
66
|
-
import com.regula.documentreader.api.results.rfid.SignerInfo;
|
|
67
|
-
import com.regula.documentreader.api.results.rfid.Validity;
|
|
68
|
-
import com.regula.documentreader.api.results.rfid.Value;
|
|
10
|
+
import com.regula.common.exception.RegulaException;
|
|
11
|
+
import com.regula.documentreader.api.config.RecognizeConfig;
|
|
12
|
+
import com.regula.documentreader.api.config.ScannerConfig;
|
|
13
|
+
import com.regula.documentreader.api.enums.*;
|
|
14
|
+
import com.regula.documentreader.api.params.*;
|
|
15
|
+
import com.regula.documentreader.api.params.rfid.*;
|
|
16
|
+
import com.regula.documentreader.api.params.rfid.authorization.*;
|
|
17
|
+
import com.regula.documentreader.api.results.*;
|
|
18
|
+
import com.regula.documentreader.api.results.authenticity.*;
|
|
19
|
+
import com.regula.documentreader.api.results.rfid.*;
|
|
69
20
|
|
|
70
21
|
import org.json.JSONArray;
|
|
71
22
|
import org.json.JSONException;
|
|
72
23
|
import org.json.JSONObject;
|
|
73
24
|
|
|
74
|
-
import java.util.
|
|
75
|
-
import java.util.Map;
|
|
25
|
+
import java.util.Arrays;
|
|
76
26
|
|
|
27
|
+
@SuppressWarnings("deprecation")
|
|
77
28
|
class JSONConstructor {
|
|
78
|
-
interface JSONObjectGeneratorWithContext<T> {
|
|
79
|
-
JSONObject generateJSONObject(T param, Context context) throws JSONException;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
interface JSONObjectGenerator<T> {
|
|
83
|
-
JSONObject generateJSONObject(T param) throws JSONException;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
static <T> JSONArray generateList(List<T> list) {
|
|
87
|
-
JSONArray result = new JSONArray();
|
|
88
|
-
if (list == null) return result;
|
|
89
|
-
for (T t : list)
|
|
90
|
-
if (t != null)
|
|
91
|
-
result.put(t);
|
|
92
|
-
|
|
93
|
-
return result;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
static <T> JSONArray generateList(List<T> list, JSONObjectGenerator<T> generator) throws JSONException {
|
|
97
|
-
JSONArray result = new JSONArray();
|
|
98
|
-
if (list == null) return result;
|
|
99
|
-
for (T t : list)
|
|
100
|
-
if (t != null)
|
|
101
|
-
result.put(generator.generateJSONObject(t));
|
|
102
|
-
|
|
103
|
-
return result;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
static <T> JSONArray generateList(List<T> list, JSONObjectGeneratorWithContext<T> generator, Context context) throws JSONException {
|
|
107
|
-
JSONArray result = new JSONArray();
|
|
108
|
-
if (list == null) return result;
|
|
109
|
-
for (T t : list)
|
|
110
|
-
if (t != null)
|
|
111
|
-
result.put(generator.generateJSONObject(t, context));
|
|
112
|
-
|
|
113
|
-
return result;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
static <T> JSONArray generateArray(T[] array) throws JSONException {
|
|
117
|
-
JSONArray result = new JSONArray();
|
|
118
|
-
if (array == null) return result;
|
|
119
|
-
for (int i = 0; i < array.length; i++)
|
|
120
|
-
result.put(i, array[i]);
|
|
121
|
-
|
|
122
|
-
return result;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
static <T> JSONArray generateArray(T[] array, JSONObjectGenerator<T> generator) throws JSONException {
|
|
126
|
-
JSONArray result = new JSONArray();
|
|
127
|
-
if (array == null) return result;
|
|
128
|
-
for (int i = 0; i < array.length; i++)
|
|
129
|
-
result.put(i, generator.generateJSONObject(array[i]));
|
|
130
|
-
|
|
131
|
-
return result;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
static <T, V> JSONObject generateMap(Map<T, V> map) throws JSONException {
|
|
135
|
-
JSONObject result = new JSONObject();
|
|
136
|
-
if (map == null) return result;
|
|
137
|
-
for (Map.Entry<T, V> entry : map.entrySet())
|
|
138
|
-
if (entry != null)
|
|
139
|
-
result.put(entry.getKey().toString(), entry.getValue());
|
|
140
|
-
return result;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
static JSONArray generateIntArray(int[] array) throws JSONException {
|
|
144
|
-
JSONArray result = new JSONArray();
|
|
145
|
-
if (array == null) return result;
|
|
146
|
-
for (int i = 0; i < array.length; i++)
|
|
147
|
-
result.put(i, array[i]);
|
|
148
|
-
|
|
149
|
-
return result;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
static int[] intArrayFromJSON(JSONArray input) throws JSONException {
|
|
153
|
-
int[] result = new int[input.length()];
|
|
154
|
-
for (int i = 0; i < input.length(); i++)
|
|
155
|
-
result[i] = input.getInt(i);
|
|
156
|
-
|
|
157
|
-
return result;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
static JSONArray generateByteArray(byte[] array) throws JSONException {
|
|
161
|
-
JSONArray result = new JSONArray();
|
|
162
|
-
if (array == null) return result;
|
|
163
|
-
for (int i = 0; i < array.length; i++)
|
|
164
|
-
result.put(i, array[i]);
|
|
165
|
-
|
|
166
|
-
return result;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
static JSONArray generateLongArray(long[] array) throws JSONException {
|
|
170
|
-
JSONArray result = new JSONArray();
|
|
171
|
-
if (array == null) return result;
|
|
172
|
-
for (int i = 0; i < array.length; i++)
|
|
173
|
-
result.put(i, array[i]);
|
|
174
|
-
|
|
175
|
-
return result;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
29
|
static JSONObject generateVideoEncoderCompletion(String sessionId, java.io.File file) {
|
|
179
30
|
JSONObject result = new JSONObject();
|
|
180
31
|
|
|
@@ -189,41 +40,33 @@ class JSONConstructor {
|
|
|
189
40
|
return result;
|
|
190
41
|
}
|
|
191
42
|
|
|
192
|
-
static JSONObject generateCompletion(int action, DocumentReaderResults results,
|
|
43
|
+
static JSONObject generateCompletion(int action, DocumentReaderResults results, RegulaException error, Context context) {
|
|
193
44
|
JSONObject result = new JSONObject();
|
|
194
45
|
try {
|
|
46
|
+
if (Arrays.asList(
|
|
47
|
+
DocReaderAction.COMPLETE,
|
|
48
|
+
DocReaderAction.MORE_PAGES_AVAILABLE,
|
|
49
|
+
DocReaderAction.CANCEL,
|
|
50
|
+
DocReaderAction.ERROR,
|
|
51
|
+
DocReaderAction.TIMEOUT
|
|
52
|
+
).contains(action))
|
|
53
|
+
result.put("results", generateDocumentReaderResults(results, context));
|
|
195
54
|
result.put("action", action);
|
|
196
|
-
|
|
197
|
-
case DocReaderAction.COMPLETE:
|
|
198
|
-
case DocReaderAction.MORE_PAGES_AVAILABLE:
|
|
199
|
-
case DocReaderAction.CANCEL:
|
|
200
|
-
case DocReaderAction.ERROR:
|
|
201
|
-
case DocReaderAction.TIMEOUT:
|
|
202
|
-
result.put("results", generateDocumentReaderResults(results, context));
|
|
203
|
-
break;
|
|
204
|
-
case DocReaderAction.NOTIFICATION:
|
|
205
|
-
result.put("results", generateDocumentReaderResultsNotification(results));
|
|
206
|
-
break;
|
|
207
|
-
default:
|
|
208
|
-
break;
|
|
209
|
-
}
|
|
210
|
-
if (error != null)
|
|
211
|
-
result.put("error", generateDocumentReaderException(error));
|
|
55
|
+
result.put("error", generateRegulaException(error));
|
|
212
56
|
} catch (JSONException ignored) {
|
|
213
57
|
}
|
|
214
|
-
|
|
215
58
|
return result;
|
|
216
59
|
}
|
|
217
60
|
|
|
218
|
-
static JSONObject
|
|
61
|
+
static JSONObject generateRegulaException(RegulaException input) {
|
|
219
62
|
JSONObject result = new JSONObject();
|
|
63
|
+
if (input == null) return null;
|
|
220
64
|
try {
|
|
221
|
-
result.put("
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
65
|
+
result.put("errorCode", input.getErrorCode());
|
|
66
|
+
result.put("message", input.getMessage());
|
|
67
|
+
} catch (JSONException e) {
|
|
68
|
+
e.printStackTrace();
|
|
225
69
|
}
|
|
226
|
-
|
|
227
70
|
return result;
|
|
228
71
|
}
|
|
229
72
|
|
|
@@ -238,12 +81,6 @@ class JSONConstructor {
|
|
|
238
81
|
return result;
|
|
239
82
|
}
|
|
240
83
|
|
|
241
|
-
static JSONObject generateDocumentReaderResultsNotification(DocumentReaderResults results) throws JSONException {
|
|
242
|
-
if (results != null && results.documentReaderNotification != null)
|
|
243
|
-
return new JSONObject().put("documentReaderNotification", generateDocumentReaderNotification(results.documentReaderNotification));
|
|
244
|
-
return new JSONObject();
|
|
245
|
-
}
|
|
246
|
-
|
|
247
84
|
static TccParams TCCParamsFromJSON(JSONObject input) {
|
|
248
85
|
TccParams result = new TccParams();
|
|
249
86
|
try {
|
|
@@ -263,6 +100,28 @@ class JSONConstructor {
|
|
|
263
100
|
return result;
|
|
264
101
|
}
|
|
265
102
|
|
|
103
|
+
static ImageInputData ImageInputDataFromJSON(JSONObject input) {
|
|
104
|
+
if (input == null) return null;
|
|
105
|
+
try {
|
|
106
|
+
Bitmap image;
|
|
107
|
+
int light = 6;
|
|
108
|
+
int pageIndex = 0;
|
|
109
|
+
|
|
110
|
+
if (input.has("image"))
|
|
111
|
+
image = bitmapFromBase64(input.getString("image"));
|
|
112
|
+
else return null;
|
|
113
|
+
if (input.has("light"))
|
|
114
|
+
pageIndex = input.getInt("light");
|
|
115
|
+
if (input.has("pageIndex"))
|
|
116
|
+
pageIndex = input.getInt("pageIndex");
|
|
117
|
+
return new ImageInputData(image, light, pageIndex);
|
|
118
|
+
} catch (JSONException e) {
|
|
119
|
+
e.printStackTrace();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
|
|
266
125
|
static DocReaderConfig DocReaderConfigFromJSON(JSONObject input) {
|
|
267
126
|
DocReaderConfig result;
|
|
268
127
|
byte[] license;
|
|
@@ -287,34 +146,89 @@ class JSONConstructor {
|
|
|
287
146
|
return null;
|
|
288
147
|
}
|
|
289
148
|
|
|
290
|
-
static
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
149
|
+
static ScannerConfig ScannerConfigFromJSON(JSONObject input) {
|
|
150
|
+
if (!input.has("scenario") && !input.has("onlineProcessingConfig")) return null;
|
|
151
|
+
try {
|
|
152
|
+
ScannerConfig.Builder builder;
|
|
153
|
+
if (input.has("scenario"))
|
|
154
|
+
builder = new ScannerConfig.Builder(input.getString("scenario"));
|
|
155
|
+
else
|
|
156
|
+
builder = new ScannerConfig.Builder(RegulaConfig.OnlineProcessingConfigFromJSON(input.getJSONObject("onlineProcessingConfig")));
|
|
157
|
+
if (input.has("onlineProcessingConfig"))
|
|
158
|
+
builder.setOnlineProcessingConfig(RegulaConfig.OnlineProcessingConfigFromJSON(input.getJSONObject("onlineProcessingConfig")));
|
|
159
|
+
if (input.has("livePortrait"))
|
|
160
|
+
builder.setLivePortrait(bitmapFromBase64(input.getString("livePortrait")));
|
|
161
|
+
if (input.has("extPortrait"))
|
|
162
|
+
builder.setExtPortrait(bitmapFromBase64(input.getString("extPortrait")));
|
|
163
|
+
if (input.has("cameraId"))
|
|
164
|
+
builder.setCameraId(input.getInt("cameraId"));
|
|
165
|
+
return builder.build();
|
|
166
|
+
} catch (JSONException e) {
|
|
167
|
+
e.printStackTrace();
|
|
168
|
+
}
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
298
171
|
|
|
172
|
+
static RecognizeConfig RecognizeConfigFromJSON(JSONObject input) {
|
|
173
|
+
if (!input.has("scenario") && !input.has("onlineProcessingConfig")) return null;
|
|
174
|
+
if (!input.has("image") && !input.has("images") && !input.has("imageInputData")) return null;
|
|
299
175
|
try {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
176
|
+
RecognizeConfig.Builder builder;
|
|
177
|
+
if (input.has("scenario"))
|
|
178
|
+
builder = new RecognizeConfig.Builder(input.getString("scenario"));
|
|
179
|
+
else
|
|
180
|
+
builder = new RecognizeConfig.Builder(RegulaConfig.OnlineProcessingConfigFromJSON(input.getJSONObject("onlineProcessingConfig")));
|
|
181
|
+
if (input.has("livePortrait"))
|
|
182
|
+
builder.setLivePortrait(bitmapFromBase64(input.getString("livePortrait")));
|
|
183
|
+
if (input.has("extPortrait"))
|
|
184
|
+
builder.setExtPortrait(bitmapFromBase64(input.getString("extPortrait")));
|
|
185
|
+
if (input.has("image"))
|
|
186
|
+
builder.setBitmap(bitmapFromBase64(input.getString("image")));
|
|
187
|
+
if (input.has("oneShotIdentification"))
|
|
188
|
+
builder.setOneShotIdentification(input.getBoolean("oneShotIdentification"));
|
|
189
|
+
if (input.has("images")) {
|
|
190
|
+
JSONArray base64Images = input.getJSONArray("images");
|
|
191
|
+
Bitmap[] images = new Bitmap[base64Images.length()];
|
|
192
|
+
for (int i = 0; i < images.length; i++)
|
|
193
|
+
images[i] = bitmapFromBase64(base64Images.getString(i));
|
|
194
|
+
builder.setBitmaps(images);
|
|
309
195
|
}
|
|
310
|
-
if (input.has("
|
|
311
|
-
JSONArray
|
|
312
|
-
|
|
313
|
-
for (int i = 0; i <
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
result = new ImageInputData(imgBytes, width, height, light, pageIndex);
|
|
196
|
+
if (input.has("imageInputData")) {
|
|
197
|
+
JSONArray base64InputData = input.getJSONArray("imageInputData");
|
|
198
|
+
ImageInputData[] inputData = new ImageInputData[base64InputData.length()];
|
|
199
|
+
for (int i = 0; i < inputData.length; i++)
|
|
200
|
+
inputData[i] = ImageInputDataFromJSON(base64InputData.getJSONObject(i));
|
|
201
|
+
builder.setImageInputData(inputData);
|
|
317
202
|
}
|
|
203
|
+
return builder.build();
|
|
204
|
+
} catch (JSONException e) {
|
|
205
|
+
e.printStackTrace();
|
|
206
|
+
}
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
static ImageQA ImageQAFromJSON(JSONObject input) {
|
|
211
|
+
if (input == null) return null;
|
|
212
|
+
ImageQA result = new ImageQA();
|
|
213
|
+
try {
|
|
214
|
+
if (input.has("dpiThreshold"))
|
|
215
|
+
result.dpiThreshold = input.getInt("dpiThreshold");
|
|
216
|
+
if (input.has("angleThreshold"))
|
|
217
|
+
result.angleThreshold = input.getInt("angleThreshold");
|
|
218
|
+
if (input.has("focusCheck"))
|
|
219
|
+
result.focusCheck = input.getBoolean("focusCheck");
|
|
220
|
+
if (input.has("glaresCheck"))
|
|
221
|
+
result.glaresCheck = input.getBoolean("glaresCheck");
|
|
222
|
+
if (input.has("colornessCheck"))
|
|
223
|
+
result.colornessCheck = input.getBoolean("colornessCheck");
|
|
224
|
+
if (input.has("moireCheck"))
|
|
225
|
+
result.moireCheck = input.getBoolean("moireCheck");
|
|
226
|
+
if (input.has("expectedPass"))
|
|
227
|
+
result.expectedPass = intArrayFromJSON(input.getJSONArray("expectedPass"));
|
|
228
|
+
if (input.has("documentPositionIndent"))
|
|
229
|
+
result.documentPositionIndent = input.getInt("documentPositionIndent");
|
|
230
|
+
if (input.has("glaresCheckParams"))
|
|
231
|
+
result.glaresCheckParams = GlaresCheckParamsFromJSON(input.getJSONObject("glaresCheckParams"));
|
|
318
232
|
} catch (JSONException e) {
|
|
319
233
|
e.printStackTrace();
|
|
320
234
|
}
|
|
@@ -322,65 +236,71 @@ class JSONConstructor {
|
|
|
322
236
|
return result;
|
|
323
237
|
}
|
|
324
238
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
static JSONObject generateDocumentReaderScenario(DocumentReaderScenario input) {
|
|
328
|
-
JSONObject result = new JSONObject();
|
|
239
|
+
static ImageQA.GlaresCheckParams GlaresCheckParamsFromJSON(JSONObject input) {
|
|
329
240
|
if (input == null) return null;
|
|
241
|
+
ImageQA.GlaresCheckParams result = new ImageQA.GlaresCheckParams();
|
|
330
242
|
try {
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
243
|
+
if (input.has("imgMarginPart"))
|
|
244
|
+
result.imgMarginPart = input.getDouble("imgMarginPart");
|
|
245
|
+
if (input.has("maxGlaringPart"))
|
|
246
|
+
result.maxGlaringPart = input.getDouble("maxGlaringPart");
|
|
334
247
|
} catch (JSONException e) {
|
|
335
248
|
e.printStackTrace();
|
|
336
249
|
}
|
|
250
|
+
|
|
337
251
|
return result;
|
|
338
252
|
}
|
|
339
253
|
|
|
340
|
-
static JSONObject
|
|
254
|
+
static JSONObject generateImageQA(ImageQA input) {
|
|
341
255
|
JSONObject result = new JSONObject();
|
|
342
256
|
if (input == null) return null;
|
|
343
257
|
try {
|
|
344
|
-
result.put("
|
|
345
|
-
result.put("
|
|
346
|
-
result.put("
|
|
347
|
-
result.put("
|
|
348
|
-
result.put("
|
|
349
|
-
result.put("
|
|
350
|
-
result.put("
|
|
351
|
-
result.put("
|
|
352
|
-
result.put("
|
|
353
|
-
result.put("name", input.name);
|
|
354
|
-
result.put("caption", input.caption);
|
|
355
|
-
result.put("description", input.description);
|
|
356
|
-
result.put("manualCrop", input.manualCrop);
|
|
258
|
+
result.put("dpiThreshold", input.dpiThreshold);
|
|
259
|
+
result.put("angleThreshold", input.angleThreshold);
|
|
260
|
+
result.put("focusCheck", input.focusCheck);
|
|
261
|
+
result.put("glaresCheck", input.glaresCheck);
|
|
262
|
+
result.put("colornessCheck", input.colornessCheck);
|
|
263
|
+
result.put("moireCheck", input.moireCheck);
|
|
264
|
+
result.put("documentPositionIndent", input.documentPositionIndent);
|
|
265
|
+
result.put("expectedPass", generateIntArray(input.expectedPass));
|
|
266
|
+
result.put("glaresCheckParams", generateGlaresCheckParams(input.glaresCheckParams));
|
|
357
267
|
} catch (JSONException e) {
|
|
358
268
|
e.printStackTrace();
|
|
359
269
|
}
|
|
360
270
|
return result;
|
|
361
271
|
}
|
|
362
272
|
|
|
363
|
-
static JSONObject
|
|
273
|
+
static JSONObject generateGlaresCheckParams(ImageQA.GlaresCheckParams input) {
|
|
364
274
|
JSONObject result = new JSONObject();
|
|
365
275
|
if (input == null) return null;
|
|
366
276
|
try {
|
|
367
|
-
result.put("
|
|
368
|
-
result.put("
|
|
369
|
-
result.put("bounds", generateBounds(input.bounds));
|
|
277
|
+
result.put("imgMarginPart", input.imgMarginPart);
|
|
278
|
+
result.put("maxGlaringPart", input.maxGlaringPart);
|
|
370
279
|
} catch (JSONException e) {
|
|
371
280
|
e.printStackTrace();
|
|
372
281
|
}
|
|
373
282
|
return result;
|
|
374
283
|
}
|
|
375
284
|
|
|
376
|
-
|
|
285
|
+
// To JSON
|
|
286
|
+
|
|
287
|
+
static JSONObject generateDocumentReaderScenario(DocumentReaderScenario input) {
|
|
377
288
|
JSONObject result = new JSONObject();
|
|
378
289
|
if (input == null) return null;
|
|
379
290
|
try {
|
|
380
|
-
result.put("
|
|
381
|
-
result.put("
|
|
382
|
-
result.put("
|
|
383
|
-
result.put("
|
|
291
|
+
result.put("name", input.name);
|
|
292
|
+
result.put("caption", input.caption);
|
|
293
|
+
result.put("description", input.description);
|
|
294
|
+
result.put("multiPageOff", input.multiPageOff);
|
|
295
|
+
result.put("frameKWHLandscape", input.frameKWHLandscape);
|
|
296
|
+
result.put("frameKWHPortrait", input.frameKWHPortrait);
|
|
297
|
+
result.put("frameKWHDoublePageSpreadPortrait", input.frameKWHDoublePageSpreadPortrait);
|
|
298
|
+
result.put("frameKWHDoublePageSpreadLandscape", input.frameKWHDoublePageSpreadLandscape);
|
|
299
|
+
result.put("frameOrientation", input.frameOrientation);
|
|
300
|
+
result.put("uvTorch", input.uvTorch);
|
|
301
|
+
result.put("faceExt", input.faceExt);
|
|
302
|
+
result.put("seriesProcessMode", input.seriesProcessMode);
|
|
303
|
+
result.put("manualCrop", input.manualCrop);
|
|
384
304
|
} catch (JSONException e) {
|
|
385
305
|
e.printStackTrace();
|
|
386
306
|
}
|
|
@@ -421,7 +341,7 @@ class JSONConstructor {
|
|
|
421
341
|
try {
|
|
422
342
|
result.put("sourceType", input.sourceType);
|
|
423
343
|
result.put("fieldType", input.fieldType);
|
|
424
|
-
result.put("
|
|
344
|
+
result.put("light", input.light);
|
|
425
345
|
result.put("pageIndex", input.pageIndex);
|
|
426
346
|
result.put("originalPageIndex", input.originalPageIndex);
|
|
427
347
|
result.put("fieldName", eGraphicFieldType.getTranslation(context, input.fieldType));
|
|
@@ -593,8 +513,6 @@ class JSONConstructor {
|
|
|
593
513
|
JSONObject result = new JSONObject();
|
|
594
514
|
if (input == null) return null;
|
|
595
515
|
try {
|
|
596
|
-
result.put("code", input.code);
|
|
597
|
-
result.put("value", input.value);
|
|
598
516
|
result.put("notificationCode", input.getNotificationCode());
|
|
599
517
|
result.put("dataFileType", input.getDataFileType());
|
|
600
518
|
result.put("progress", input.getProgress());
|
|
@@ -854,6 +772,20 @@ class JSONConstructor {
|
|
|
854
772
|
result.put("accessControls", generateList(input.accessControls, JSONConstructor::generateAccessControlProcedureType));
|
|
855
773
|
result.put("applications", generateList(input.applications, JSONConstructor::generateApplication));
|
|
856
774
|
result.put("securityObjects", generateList(input.securityObjects, JSONConstructor::generateSecurityObject));
|
|
775
|
+
result.put("dataGroups", generateIntArray(input.dataGroups));
|
|
776
|
+
result.put("dataFields", generateList(input.dataFields, JSONConstructor::generateDataField));
|
|
777
|
+
} catch (JSONException e) {
|
|
778
|
+
e.printStackTrace();
|
|
779
|
+
}
|
|
780
|
+
return result;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
static JSONObject generateDataField(DataField input) {
|
|
784
|
+
JSONObject result = new JSONObject();
|
|
785
|
+
if (input == null) return null;
|
|
786
|
+
try {
|
|
787
|
+
result.put("data", input.getData());
|
|
788
|
+
result.put("fieldType", input.getFieldType());
|
|
857
789
|
} catch (JSONException e) {
|
|
858
790
|
e.printStackTrace();
|
|
859
791
|
}
|
|
@@ -941,18 +873,6 @@ class JSONConstructor {
|
|
|
941
873
|
return result;
|
|
942
874
|
}
|
|
943
875
|
|
|
944
|
-
static JSONObject generateDocumentReaderException(DocumentReaderException input) {
|
|
945
|
-
JSONObject result = new JSONObject();
|
|
946
|
-
if (input == null) return null;
|
|
947
|
-
try {
|
|
948
|
-
result.put("errorCode", input.getErrorCode());
|
|
949
|
-
result.put("message", input.getMessage());
|
|
950
|
-
} catch (JSONException e) {
|
|
951
|
-
e.printStackTrace();
|
|
952
|
-
}
|
|
953
|
-
return result;
|
|
954
|
-
}
|
|
955
|
-
|
|
956
876
|
static JSONObject generatePAResourcesIssuer(PAResourcesIssuer input) {
|
|
957
877
|
JSONObject result = new JSONObject();
|
|
958
878
|
if (input == null) return null;
|
|
@@ -1089,6 +1009,7 @@ class JSONConstructor {
|
|
|
1089
1009
|
result.put("databaseDescription", input.databaseDescription);
|
|
1090
1010
|
result.put("countriesNumber", input.countriesNumber);
|
|
1091
1011
|
result.put("documentsNumber", input.documentsNumber);
|
|
1012
|
+
result.put("size", input.size);
|
|
1092
1013
|
} catch (JSONException e) {
|
|
1093
1014
|
e.printStackTrace();
|
|
1094
1015
|
}
|