dynamsoft-capture-vision-react-native 3.2.5001 → 3.4.1000-beta.1
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/android/build.gradle +1 -1
- package/android/src/main/cpp/JsiCore.cpp +19 -7
- package/android/src/main/cpp/JsiCvr.cpp +19 -14
- package/android/src/main/cpp/JsiDbr.cpp +62 -2
- package/android/src/main/dysJniLibs/debug/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibs/debug/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibs/debug/x86/librn_dys.so +0 -0
- package/android/src/main/dysJniLibs/debug/x86_64/librn_dys.so +0 -0
- package/android/src/main/dysJniLibs/release/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibs/release/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibs/release/x86/librn_dys.so +0 -0
- package/android/src/main/dysJniLibs/release/x86_64/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor81/debug/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor81/debug/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor81/debug/x86/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor81/debug/x86_64/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor81/release/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor81/release/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor81/release/x86/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor81/release/x86_64/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor82/debug/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor82/debug/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor82/debug/x86/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor82/debug/x86_64/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor82/release/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor82/release/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor82/release/x86/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor82/release/x86_64/librn_dys.so +0 -0
- package/android/src/main/java/com/dynamsoft/reactnativelib/MultiCrossFilterModule.kt +11 -0
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForDBR.kt +15 -0
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/CameraEnhancerModuleImpl.kt +4 -1
- package/android/src/main/java/com/dynamsoft/reactnativelib/utility/MultiCrossFilterModuleImpl.kt +28 -2
- package/dynamsoft-capture-vision-react-native.podspec +1 -1
- package/ios/CPP/ImageDataHostObject.cpp +1 -1
- package/ios/CPP/RNDynamsoft+JSI.mm +34 -1
- package/ios/CPP/RNDynamsoft+Json.m +25 -0
- package/ios/RNDynamsoftCaptureVisionRouter.mm +11 -5
- package/ios/RNDynamsoftImageEditorViewManager.mm +11 -5
- package/ios/RNDynamsoftImageManager.h +2 -1
- package/ios/RNDynamsoftImageManager.mm +11 -5
- package/ios/RNDynamsoftImageSourceAdapter.h +2 -1
- package/ios/RNDynamsoftImageSourceAdapter.mm +12 -6
- package/ios/RNDynamsoftMultiCrossFilter.m +39 -0
- package/package.json +1 -1
- package/src/core/ImageData.tsx +4 -1
- package/src/core/ImageSourceAdapter.tsx +6 -0
- package/src/cvr/CaptureVisionRouter.tsx +26 -10
- package/src/dbr/BarcodeResultItem.tsx +9 -0
- package/src/dbr/ECISegment.tsx +24 -0
- package/src/dbr/index.tsx +1 -0
- package/src/dce/EnumResolution.tsx +1 -0
- package/src/dce/ImageEditorView.tsx +3 -0
- package/src/utility/CrossVerificationCriteria.tsx +12 -0
- package/src/utility/ImageManager.tsx +39 -0
- package/src/utility/MultiFrameResultCrossFilter.tsx +23 -0
- package/src/utility/index.tsx +1 -0
package/android/build.gradle
CHANGED
|
@@ -159,5 +159,5 @@ dependencies {
|
|
|
159
159
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
|
|
160
160
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3"
|
|
161
161
|
|
|
162
|
-
implementation "com.dynamsoft:capturevisionbundle:3.
|
|
162
|
+
implementation "com.dynamsoft:capturevisionbundle:3.4.1000"
|
|
163
163
|
}
|
|
@@ -38,6 +38,8 @@ void jQuadToJsObject(Runtime &rt, JNIEnv *env, jobject jQuad, Object &jsQuad) {
|
|
|
38
38
|
auto jPoints = (jobjectArray) env->GetObjectField(jQuad, points);
|
|
39
39
|
if (!jPoints) {
|
|
40
40
|
jsQuad.setProperty(rt, "points", Value::undefined());
|
|
41
|
+
env->DeleteLocalRef(jclsQuad);
|
|
42
|
+
return;
|
|
41
43
|
}
|
|
42
44
|
int count = env->GetArrayLength(jPoints);
|
|
43
45
|
Array pointArr(rt, count);
|
|
@@ -50,6 +52,7 @@ void jQuadToJsObject(Runtime &rt, JNIEnv *env, jobject jQuad, Object &jsQuad) {
|
|
|
50
52
|
}
|
|
51
53
|
jsQuad.setProperty(rt, "points", std::move(pointArr));
|
|
52
54
|
env->DeleteLocalRef(jclsQuad);
|
|
55
|
+
env->DeleteLocalRef(jPoints);
|
|
53
56
|
}
|
|
54
57
|
|
|
55
58
|
void jCapturedItemToJsObject(Runtime &rt, JNIEnv *env, jobject jItem, int &outType, Object &jsItem) {
|
|
@@ -71,7 +74,11 @@ void jCapturedItemToJsObject(Runtime &rt, JNIEnv *env, jobject jItem, int &outTy
|
|
|
71
74
|
jsItem.setProperty(rt, "targetROIDefName", pTargetROIDefName);
|
|
72
75
|
if (jTaskName) {
|
|
73
76
|
env->ReleaseStringUTFChars(jTaskName, pTaskName);
|
|
77
|
+
env->DeleteLocalRef(jTaskName);
|
|
78
|
+
}
|
|
79
|
+
if (jTargetROIDefName) {
|
|
74
80
|
env->ReleaseStringUTFChars(jTargetROIDefName, pTargetROIDefName);
|
|
81
|
+
env->DeleteLocalRef(jTargetROIDefName);
|
|
75
82
|
}
|
|
76
83
|
env->DeleteLocalRef(clsCapturedResultItem);
|
|
77
84
|
|
|
@@ -98,12 +105,12 @@ void jCapturedItemArrayToJsArray(Runtime &rt, JNIEnv *env, jobjectArray jItemArr
|
|
|
98
105
|
}
|
|
99
106
|
|
|
100
107
|
jobject getJImageDataFromHO(JNIEnv *env, const ImageDataHostObject &imageDataHO) {
|
|
108
|
+
env->PushLocalFrame(8);
|
|
101
109
|
jbyteArray jByteArr = nullptr;
|
|
102
110
|
if (imageDataHO.buffer != nullptr) {
|
|
103
111
|
jByteArr = env->NewByteArray((int) imageDataHO.bufferSize);
|
|
104
112
|
env->SetByteArrayRegion(jByteArr, 0, (int) imageDataHO.bufferSize, (jbyte *) imageDataHO.buffer);
|
|
105
113
|
}
|
|
106
|
-
env->PushLocalFrame(4);
|
|
107
114
|
jclass jclsImageData = env->FindClass("com/dynamsoft/core/basic_structures/ImageData");
|
|
108
115
|
jmethodID initImageData = env->GetMethodID(jclsImageData, "<init>", "([BIIIIILcom/dynamsoft/core/basic_structures/ImageTag;)V");
|
|
109
116
|
return env->PopLocalFrame(
|
|
@@ -162,14 +169,19 @@ Value imageDataHOToBase64(ImageDataHostObject &imageDataHO, Runtime &rt) {
|
|
|
162
169
|
|
|
163
170
|
auto jImageData = jsiConversion::core::getJImageDataFromHO(env, imageDataHO);
|
|
164
171
|
auto jBase64 = (jstring) env->CallStaticObjectMethod(cls, imageData2base64, jImageData);
|
|
165
|
-
|
|
172
|
+
std::string base64Str = "";
|
|
173
|
+
if (jBase64 != nullptr) {
|
|
174
|
+
auto pBase64 = env->GetStringUTFChars(jBase64, nullptr);
|
|
175
|
+
base64Str = std::string(pBase64);
|
|
176
|
+
env->ReleaseStringUTFChars(jBase64, pBase64);
|
|
177
|
+
env->DeleteLocalRef(jBase64);
|
|
178
|
+
}
|
|
179
|
+
|
|
166
180
|
env->DeleteLocalRef(cls);
|
|
167
181
|
env->DeleteLocalRef(jImageData);
|
|
168
|
-
if (jBase64 != nullptr)
|
|
169
|
-
env->ReleaseStringUTFChars(jBase64, pBase64);
|
|
170
182
|
if (needDetach)
|
|
171
183
|
gJvm->DetachCurrentThread();
|
|
172
|
-
return String::createFromUtf8(rt,
|
|
184
|
+
return String::createFromUtf8(rt, base64Str);
|
|
173
185
|
}
|
|
174
186
|
|
|
175
187
|
void addImageToBuffer(ImageDataHostObject &imageDataHO, string &nativeIsaId) {
|
|
@@ -181,7 +193,7 @@ void addImageToBuffer(ImageDataHostObject &imageDataHO, string &nativeIsaId) {
|
|
|
181
193
|
needDetach = true;
|
|
182
194
|
}
|
|
183
195
|
|
|
184
|
-
env->PushLocalFrame(
|
|
196
|
+
env->PushLocalFrame(8);
|
|
185
197
|
jclass clsIsaModuleImpl = env->FindClass("com/dynamsoft/reactnativelib/core/ImageSourceAdapterModuleImpl");
|
|
186
198
|
jmethodID getISA =env->GetStaticMethodID(clsIsaModuleImpl, "getISA", "(Ljava/lang/String;)Lcom/dynamsoft/core/basic_structures/ImageSourceAdapter;");
|
|
187
199
|
jobject jISA = env->CallStaticObjectMethod(clsIsaModuleImpl, getISA, env->NewStringUTF(nativeIsaId.c_str()));
|
|
@@ -207,7 +219,7 @@ ImageDataHostObject getImage(string &nativeIsaId) {
|
|
|
207
219
|
needDetach = true;
|
|
208
220
|
}
|
|
209
221
|
|
|
210
|
-
env->PushLocalFrame(
|
|
222
|
+
env->PushLocalFrame(8);
|
|
211
223
|
jclass clsIsaModuleImpl = env->FindClass("com/dynamsoft/reactnativelib/core/ImageSourceAdapterModuleImpl");
|
|
212
224
|
jmethodID getISA =env->GetStaticMethodID(clsIsaModuleImpl, "getISA", "(Ljava/lang/String;)Lcom/dynamsoft/core/basic_structures/ImageSourceAdapter;");
|
|
213
225
|
jobject jISA = env->CallStaticObjectMethod(clsIsaModuleImpl, getISA, env->NewStringUTF(nativeIsaId.c_str()));
|
|
@@ -23,6 +23,9 @@ extern "C"
|
|
|
23
23
|
JNIEXPORT void JNICALL
|
|
24
24
|
Java_com_dynamsoft_reactnativelib_cvr_CaptureVisionRouterModuleImpl_nativeInstall(JNIEnv *env, jobject thiz, jlong jsiPtr) {
|
|
25
25
|
if (!env->IsSameObject(jCvrModule, thiz)) {
|
|
26
|
+
if (jCvrModule) {
|
|
27
|
+
env->DeleteWeakGlobalRef(jCvrModule);
|
|
28
|
+
}
|
|
26
29
|
jCvrModule = env->NewWeakGlobalRef(thiz);
|
|
27
30
|
}
|
|
28
31
|
auto runtime = reinterpret_cast<Runtime *>(jsiPtr);
|
|
@@ -33,7 +36,7 @@ Java_com_dynamsoft_reactnativelib_cvr_CaptureVisionRouterModuleImpl_nativeInstal
|
|
|
33
36
|
|
|
34
37
|
namespace jsiConversion::cvr {
|
|
35
38
|
void jCapturedResultToJsiObject(Runtime &rt, JNIEnv *env, jobject jCapturedResult, Object &jsCapturedResult) {
|
|
36
|
-
env->PushLocalFrame(
|
|
39
|
+
env->PushLocalFrame(16);
|
|
37
40
|
jclass jclsCapturedResult = env->FindClass("com/dynamsoft/cvr/CapturedResult");
|
|
38
41
|
SET_STRING_PROPERTY_BY_FIELD(jclsCapturedResult, jCapturedResult, jsCapturedResult, originalImageHashId)
|
|
39
42
|
SET_STRING_PROPERTY_BY_FIELD(jclsCapturedResult, jCapturedResult, jsCapturedResult, errorMessage)
|
|
@@ -56,13 +59,14 @@ void jCapturedResultToJsiObject(Runtime &rt, JNIEnv *env, jobject jCapturedResul
|
|
|
56
59
|
}
|
|
57
60
|
env->DeleteLocalRef(clsMatrix);
|
|
58
61
|
env->DeleteLocalRef(jValues);
|
|
62
|
+
env->DeleteLocalRef(jMatrix);
|
|
59
63
|
jsCapturedResult.setProperty(rt, "rotationTransformMatrix", jsMatrix);
|
|
60
64
|
}
|
|
61
65
|
|
|
62
66
|
jfieldID items = env->GetFieldID(jclsCapturedResult, "items", "[Lcom/dynamsoft/core/basic_structures/CapturedResultItem;");
|
|
63
67
|
jobjectArray jItems = (jobjectArray) env->GetObjectField(jCapturedResult, items);
|
|
64
68
|
Array jsItemArray(rt, 0);
|
|
65
|
-
int *types;
|
|
69
|
+
int *types = nullptr;
|
|
66
70
|
|
|
67
71
|
jsiConversion::core::jCapturedItemArrayToJsArray(rt, env, jItems, types, jsItemArray);
|
|
68
72
|
for (int i = 0; i < jsItemArray.size(rt); ++i) {
|
|
@@ -84,7 +88,9 @@ void jCapturedResultToJsiObject(Runtime &rt, JNIEnv *env, jobject jCapturedResul
|
|
|
84
88
|
}
|
|
85
89
|
env->DeleteLocalRef(jItem);
|
|
86
90
|
}
|
|
87
|
-
|
|
91
|
+
if(types) {
|
|
92
|
+
delete[] types;
|
|
93
|
+
}
|
|
88
94
|
jsCapturedResult.setProperty(rt, "items", jsItemArray);
|
|
89
95
|
env->PopLocalFrame(nullptr);
|
|
90
96
|
}
|
|
@@ -174,6 +180,7 @@ Object captureImageDataHO(ImageDataHostObject &imageDataHO, Runtime &rt, string
|
|
|
174
180
|
gJvm->AttachCurrentThread(&env, nullptr);
|
|
175
181
|
needDetach = true;
|
|
176
182
|
}
|
|
183
|
+
env->PushLocalFrame(16);
|
|
177
184
|
auto clzCvrModule = env->GetObjectClass(jCvrModule);
|
|
178
185
|
auto captureMeth = env->GetMethodID(clzCvrModule, "captureImageDataCalledInJSI",
|
|
179
186
|
"(Lcom/dynamsoft/core/basic_structures/ImageData;Ljava/lang/String;)Lcom/dynamsoft/cvr/CapturedResult;");
|
|
@@ -181,8 +188,7 @@ Object captureImageDataHO(ImageDataHostObject &imageDataHO, Runtime &rt, string
|
|
|
181
188
|
auto jResult = env->CallObjectMethod(jCvrModule, captureMeth, imageData, env->NewStringUTF(templateName.c_str()));
|
|
182
189
|
Object jsResult(rt);
|
|
183
190
|
jsiConversion::cvr::jCapturedResultToJsiObject(rt, env, jResult, jsResult);
|
|
184
|
-
env->
|
|
185
|
-
env->DeleteLocalRef(imageData);
|
|
191
|
+
env->PopLocalFrame(nullptr);
|
|
186
192
|
if (needDetach) {
|
|
187
193
|
gJvm->DetachCurrentThread();
|
|
188
194
|
}
|
|
@@ -197,13 +203,14 @@ Object captureFile(string filePath, Runtime &rt, string templateName) {
|
|
|
197
203
|
gJvm->AttachCurrentThread(&env, nullptr);
|
|
198
204
|
needDetach = true;
|
|
199
205
|
}
|
|
206
|
+
env->PushLocalFrame(8);
|
|
200
207
|
auto clzCvrModule = env->GetObjectClass(jCvrModule);
|
|
201
208
|
auto captureMeth = env->GetMethodID(clzCvrModule, "captureFileCalledInJSI",
|
|
202
209
|
"(Ljava/lang/String;Ljava/lang/String;)Lcom/dynamsoft/cvr/CapturedResult;");
|
|
203
210
|
auto jResult = env->CallObjectMethod(jCvrModule, captureMeth, env->NewStringUTF(filePath.c_str()), env->NewStringUTF(templateName.c_str()));
|
|
204
211
|
Object jsResult(rt);
|
|
205
212
|
jsiConversion::cvr::jCapturedResultToJsiObject(rt, env, jResult, jsResult);
|
|
206
|
-
env->
|
|
213
|
+
env->PopLocalFrame(nullptr);
|
|
207
214
|
if (needDetach) {
|
|
208
215
|
gJvm->DetachCurrentThread();
|
|
209
216
|
}
|
|
@@ -217,6 +224,7 @@ Object captureFileBytes(ArrayBuffer &fileBytes, Runtime &rt, string templateName
|
|
|
217
224
|
gJvm->AttachCurrentThread(&env, nullptr);
|
|
218
225
|
needDetach = true;
|
|
219
226
|
}
|
|
227
|
+
env->PushLocalFrame(8);
|
|
220
228
|
auto clzCvrModule = env->GetObjectClass(jCvrModule);
|
|
221
229
|
auto captureMeth = env->GetMethodID(clzCvrModule, "captureFileBytesCalledInJSI",
|
|
222
230
|
"([BLjava/lang/String;)Lcom/dynamsoft/cvr/CapturedResult;");
|
|
@@ -227,8 +235,7 @@ Object captureFileBytes(ArrayBuffer &fileBytes, Runtime &rt, string templateName
|
|
|
227
235
|
auto jResult = env->CallObjectMethod(jCvrModule, captureMeth, jBytes, env->NewStringUTF(templateName.c_str()));
|
|
228
236
|
Object jsResult(rt);
|
|
229
237
|
jsiConversion::cvr::jCapturedResultToJsiObject(rt, env, jResult, jsResult);
|
|
230
|
-
env->
|
|
231
|
-
env->DeleteLocalRef(jBytes);
|
|
238
|
+
env->PopLocalFrame(nullptr);
|
|
232
239
|
if (needDetach) {
|
|
233
240
|
gJvm->DetachCurrentThread();
|
|
234
241
|
}
|
|
@@ -260,8 +267,7 @@ Array getCurrentDeskewedImages(Runtime &runtime) {
|
|
|
260
267
|
if (jCurrentImages) {
|
|
261
268
|
env->DeleteLocalRef(jCurrentImages);
|
|
262
269
|
}
|
|
263
|
-
|
|
264
|
-
env->SetObjectField(jCvrModule, fiCurrentImages, jCurrentImages);
|
|
270
|
+
env->SetObjectField(jCvrModule, fiCurrentImages, nullptr);
|
|
265
271
|
if (needDetach) {
|
|
266
272
|
gJvm->DetachCurrentThread();
|
|
267
273
|
}
|
|
@@ -293,8 +299,7 @@ Array getCurrentEnhancedImages(Runtime &runtime) {
|
|
|
293
299
|
if (jCurrentImages) {
|
|
294
300
|
env->DeleteLocalRef(jCurrentImages);
|
|
295
301
|
}
|
|
296
|
-
|
|
297
|
-
env->SetObjectField(jCvrModule, fiCurrentImages, jCurrentImages);
|
|
302
|
+
env->SetObjectField(jCvrModule, fiCurrentImages, nullptr);
|
|
298
303
|
if (needDetach) {
|
|
299
304
|
gJvm->DetachCurrentThread();
|
|
300
305
|
}
|
|
@@ -309,6 +314,7 @@ ImageDataHostObject getOriginalImage(Runtime &runtime, string imageHashId) {
|
|
|
309
314
|
gJvm->AttachCurrentThread(&env, nullptr);
|
|
310
315
|
needDetach = true;
|
|
311
316
|
}
|
|
317
|
+
env->PushLocalFrame(8);
|
|
312
318
|
auto clzCvrModule = env->GetObjectClass(jCvrModule);
|
|
313
319
|
auto getOriginalImageCalledInJSI =
|
|
314
320
|
env->GetMethodID(clzCvrModule, "getOriginalImageCalledInJSI", "(Ljava/lang/String;)Lcom/dynamsoft/core/basic_structures/ImageData;");
|
|
@@ -316,9 +322,8 @@ ImageDataHostObject getOriginalImage(Runtime &runtime, string imageHashId) {
|
|
|
316
322
|
ImageDataHostObject imgHO;
|
|
317
323
|
if (jImageData != nullptr) {
|
|
318
324
|
jsiConversion::core::getHOFromJImageData(env, jImageData, imgHO);
|
|
319
|
-
env->DeleteLocalRef(jImageData);
|
|
320
325
|
}
|
|
321
|
-
env->
|
|
326
|
+
env->PopLocalFrame(nullptr);
|
|
322
327
|
if (needDetach) {
|
|
323
328
|
gJvm->DetachCurrentThread();
|
|
324
329
|
}
|
|
@@ -27,13 +27,27 @@ namespace jsiConversion::dbr {
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
void jBarcodeResultItemToJsObject(Runtime &rt, JNIEnv *env, jobject jItem, Object &jsItem) {
|
|
30
|
-
env->PushLocalFrame(
|
|
30
|
+
env->PushLocalFrame(128);
|
|
31
31
|
jclass clsItem = env->FindClass("com/dynamsoft/dbr/BarcodeResultItem");
|
|
32
32
|
jmethodID getFormat = env->GetMethodID(clsItem, "getFormat", "()J");
|
|
33
33
|
jsItem.setProperty(rt, "format", BigInt::fromInt64(rt, env->CallLongMethod(jItem, getFormat)));
|
|
34
34
|
|
|
35
35
|
SET_STRING_PROPERTY_BY_METHOD(clsItem, jItem, jsItem, formatString, getFormatString)
|
|
36
|
-
|
|
36
|
+
|
|
37
|
+
jmethodID getText = env->GetMethodID(clsItem, "getText", "()Ljava/lang/String;");
|
|
38
|
+
jstring jtext = (jstring) env->CallObjectMethod(jItem, getText);
|
|
39
|
+
if (jtext != nullptr) {
|
|
40
|
+
const jchar *ptext = env->GetStringChars(jtext, nullptr);
|
|
41
|
+
if (ptext != nullptr) {
|
|
42
|
+
jsize textLength = env->GetStringLength(jtext);
|
|
43
|
+
jsItem.setProperty(rt, "text", facebook::jsi::String::createFromUtf16(rt, reinterpret_cast<const char16_t *>(ptext), static_cast<size_t>(textLength)));
|
|
44
|
+
env->ReleaseStringChars(jtext, ptext);
|
|
45
|
+
} else {
|
|
46
|
+
jsItem.setProperty(rt, "text", "");
|
|
47
|
+
}
|
|
48
|
+
} else {
|
|
49
|
+
jsItem.setProperty(rt, "text", "");
|
|
50
|
+
}
|
|
37
51
|
|
|
38
52
|
jmethodID getLocation = env->GetMethodID(clsItem, "getLocation", "()Lcom/dynamsoft/core/basic_structures/Quadrilateral;");
|
|
39
53
|
Object jsQuad(rt);
|
|
@@ -55,6 +69,52 @@ namespace jsiConversion::dbr {
|
|
|
55
69
|
jmethodID isDPM = env->GetMethodID(clsItem, "isDPM", "()Z");
|
|
56
70
|
jsItem.setProperty(rt, "isDPM", (bool) env->CallBooleanMethod(jItem, isDPM));
|
|
57
71
|
|
|
72
|
+
jmethodID getBytes = env->GetMethodID(clsItem, "getBytes", "()[B");
|
|
73
|
+
jbyteArray jBytes = (jbyteArray) env->CallObjectMethod(jItem, getBytes);
|
|
74
|
+
if (jBytes != nullptr) {
|
|
75
|
+
jclass clsBase64 = env->FindClass("android/util/Base64");
|
|
76
|
+
jmethodID encodeMethod = env->GetStaticMethodID(clsBase64, "encodeToString", "([BI)Ljava/lang/String;");
|
|
77
|
+
jstring base64Str = (jstring) env->CallStaticObjectMethod(clsBase64, encodeMethod, jBytes, 2);
|
|
78
|
+
if (base64Str) {
|
|
79
|
+
const char *b64 = env->GetStringUTFChars(base64Str, nullptr);
|
|
80
|
+
if (b64) {
|
|
81
|
+
jsItem.setProperty(rt, "bytes", String::createFromUtf8(rt, b64));
|
|
82
|
+
env->ReleaseStringUTFChars(base64Str, b64);
|
|
83
|
+
}
|
|
84
|
+
env->DeleteLocalRef(base64Str);
|
|
85
|
+
}
|
|
86
|
+
env->DeleteLocalRef(clsBase64);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
jmethodID getECISegments = env->GetMethodID(clsItem, "getECISegments", "()[Lcom/dynamsoft/dbr/ECISegment;");
|
|
90
|
+
jobjectArray jEciSegments = (jobjectArray) env->CallObjectMethod(jItem, getECISegments);
|
|
91
|
+
if (jEciSegments != nullptr) {
|
|
92
|
+
int eciSegments_len = env->GetArrayLength(jEciSegments);
|
|
93
|
+
Array jsEciSegments(rt, eciSegments_len);
|
|
94
|
+
jclass clsEciSegment = env->FindClass("com/dynamsoft/dbr/ECISegment");
|
|
95
|
+
jfieldID fi_eciValue = env->GetFieldID(clsEciSegment, "eciValue", "I");
|
|
96
|
+
jfieldID fi_startIndex = env->GetFieldID(clsEciSegment, "startIndex", "I");
|
|
97
|
+
jfieldID fi_length = env->GetFieldID(clsEciSegment, "length", "I");
|
|
98
|
+
jfieldID fi_charsetEncoding = env->GetFieldID(clsEciSegment, "charsetEncoding", "Ljava/lang/String;");
|
|
99
|
+
for (int i = 0; i < eciSegments_len; ++i) {
|
|
100
|
+
Object jsEciSegment(rt);
|
|
101
|
+
jobject jEciSegment = env->GetObjectArrayElement(jEciSegments, i);
|
|
102
|
+
jsEciSegment.setProperty(rt, "eciValue", env->GetIntField(jEciSegment, fi_eciValue));
|
|
103
|
+
jsEciSegment.setProperty(rt, "startIndex", env->GetIntField(jEciSegment, fi_startIndex));
|
|
104
|
+
jsEciSegment.setProperty(rt, "length", env->GetIntField(jEciSegment, fi_length));
|
|
105
|
+
auto jCharsetEncoding = (jstring) env->GetObjectField(jEciSegment, fi_charsetEncoding);
|
|
106
|
+
auto pCharsetEncoding = jCharsetEncoding ? env->GetStringUTFChars(jCharsetEncoding, nullptr) : "";
|
|
107
|
+
jsEciSegment.setProperty(rt, "charsetEncoding", pCharsetEncoding);
|
|
108
|
+
if (jCharsetEncoding) {
|
|
109
|
+
env->ReleaseStringUTFChars(jCharsetEncoding, pCharsetEncoding);
|
|
110
|
+
env->DeleteLocalRef(jCharsetEncoding);
|
|
111
|
+
}
|
|
112
|
+
jsEciSegments.setValueAtIndex(rt, i, std::move(jsEciSegment));
|
|
113
|
+
env->DeleteLocalRef(jEciSegment);
|
|
114
|
+
}
|
|
115
|
+
jsItem.setProperty(rt, "eciSegments", jsEciSegments);
|
|
116
|
+
}
|
|
117
|
+
|
|
58
118
|
jmethodID getDetails = env->GetMethodID(clsItem, "getDetails", "()Lcom/dynamsoft/dbr/BarcodeDetails;");
|
|
59
119
|
jobject jDetails = env->CallObjectMethod(jItem, getDetails);
|
|
60
120
|
if (jDetails != nullptr) {
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -5,6 +5,7 @@ import com.facebook.react.bridge.Promise
|
|
|
5
5
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
6
|
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
7
7
|
import com.facebook.react.bridge.ReactMethod
|
|
8
|
+
import com.facebook.react.bridge.ReadableMap
|
|
8
9
|
|
|
9
10
|
class MultiCrossFilterModule(reactApplicationContext: ReactApplicationContext) :
|
|
10
11
|
ReactContextBaseJavaModule(reactApplicationContext) {
|
|
@@ -69,4 +70,14 @@ class MultiCrossFilterModule(reactApplicationContext: ReactApplicationContext) :
|
|
|
69
70
|
impl.getMaxOverlappingFrames(filterId, type.toInt(), promise)
|
|
70
71
|
}
|
|
71
72
|
|
|
73
|
+
@ReactMethod
|
|
74
|
+
fun setResultCrossVerificationCriteria(filterId: String, types: Int, criteria: ReadableMap) {
|
|
75
|
+
impl.setResultCrossVerificationCriteria(filterId, types, criteria)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@ReactMethod
|
|
79
|
+
fun getResultCrossVerificationCriteria(filterId: String, types: Int, promise: Promise) {
|
|
80
|
+
impl.getResultCrossVerificationCriteria(filterId, types, promise)
|
|
81
|
+
}
|
|
82
|
+
|
|
72
83
|
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
package com.dynamsoft.reactnativelib.basicutils
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
import android.util.Base64
|
|
4
5
|
import com.dynamsoft.core.basic_structures.CapturedResultItem
|
|
5
6
|
import com.dynamsoft.dbr.AztecDetails
|
|
6
7
|
import com.dynamsoft.dbr.BarcodeDetails
|
|
7
8
|
import com.dynamsoft.dbr.BarcodeResultItem
|
|
8
9
|
import com.dynamsoft.dbr.DataMatrixDetails
|
|
9
10
|
import com.dynamsoft.dbr.DecodedBarcodesResult
|
|
11
|
+
import com.dynamsoft.dbr.ECISegment
|
|
10
12
|
import com.dynamsoft.dbr.OneDCodeDetails
|
|
11
13
|
import com.dynamsoft.dbr.PDF417Details
|
|
12
14
|
import com.dynamsoft.dbr.QRCodeDetails
|
|
@@ -23,6 +25,7 @@ fun BarcodeResultItem.toWritableMap(): WritableMap = Arguments.createMap().apply
|
|
|
23
25
|
putString("_formatNumberString", format.toULong().toString())
|
|
24
26
|
putString("formatString", formatString)
|
|
25
27
|
putString("text", text)
|
|
28
|
+
putString("bytes", Base64.encodeToString(bytes ?: byteArrayOf(), Base64.NO_WRAP))
|
|
26
29
|
putMap("location", location.toWritableMap())
|
|
27
30
|
putInt("confidence", confidence)
|
|
28
31
|
putInt("angle", angle)
|
|
@@ -37,6 +40,7 @@ fun BarcodeResultItem.toWritableMap(): WritableMap = Arguments.createMap().apply
|
|
|
37
40
|
is PDF417Details -> putMap("pdf417Details", details.toWritableMap())
|
|
38
41
|
else -> Unit
|
|
39
42
|
}
|
|
43
|
+
putArray("eciSegments", eciSegments?.toWritableArray())
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
fun Array<out BarcodeResultItem>.toWritableArray(): WritableArray = Arguments.createArray().apply {
|
|
@@ -140,3 +144,14 @@ fun BarcodeDetails.toWritableMap(): WritableMap = Arguments.createMap().apply {
|
|
|
140
144
|
else -> Unit
|
|
141
145
|
}
|
|
142
146
|
}
|
|
147
|
+
|
|
148
|
+
fun Array<out ECISegment>.toWritableArray(): WritableArray = Arguments.createArray().apply {
|
|
149
|
+
forEach { pushMap(it.toWritableMap()) }
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
fun ECISegment.toWritableMap(): WritableMap = Arguments.createMap().apply {
|
|
153
|
+
putInt("eciValue", eciValue)
|
|
154
|
+
putString("charsetEncoding", charsetEncoding)
|
|
155
|
+
putInt("startIndex", startIndex)
|
|
156
|
+
putInt("length", length)
|
|
157
|
+
}
|
|
@@ -64,7 +64,8 @@ class CameraEnhancerModuleImpl(private val reactContext: ReactApplicationContext
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
override fun onHostDestroy() {
|
|
67
|
-
|
|
67
|
+
//Don't handle ON_DESTROY, which can cause problems on some devices when some apps that have started background services return to the foreground
|
|
68
|
+
//cameraLifecycleOwner.lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_DESTROY)
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
@ReactMethod
|
|
@@ -169,6 +170,8 @@ class CameraEnhancerModuleImpl(private val reactContext: ReactApplicationContext
|
|
|
169
170
|
fun setResolution(resolution: Int) {
|
|
170
171
|
if(resolution == 4) {
|
|
171
172
|
camera.setResolution(EnumResolution.RESOLUTION_4K)
|
|
173
|
+
} else if(resolution == 5) {
|
|
174
|
+
camera.setResolution(EnumResolution.RESOLUTION_MAX)
|
|
172
175
|
} else {
|
|
173
176
|
camera.setResolution(resolution)
|
|
174
177
|
}
|
package/android/src/main/java/com/dynamsoft/reactnativelib/utility/MultiCrossFilterModuleImpl.kt
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
package com.dynamsoft.reactnativelib.utility
|
|
2
2
|
|
|
3
3
|
import com.dynamsoft.reactnativelib.cvr.filterMap
|
|
4
|
+
import com.dynamsoft.utility.CrossVerificationCriteria
|
|
4
5
|
import com.dynamsoft.utility.MultiFrameResultCrossFilter
|
|
6
|
+
import com.facebook.react.bridge.Arguments
|
|
5
7
|
import com.facebook.react.bridge.Promise
|
|
6
8
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
7
9
|
import com.facebook.react.bridge.ReactMethod
|
|
10
|
+
import com.facebook.react.bridge.ReadableMap
|
|
8
11
|
|
|
9
12
|
class MultiCrossFilterModuleImpl(context: ReactApplicationContext) {
|
|
10
13
|
companion object {
|
|
@@ -13,8 +16,8 @@ class MultiCrossFilterModuleImpl(context: ReactApplicationContext) {
|
|
|
13
16
|
|
|
14
17
|
fun getName() = NAME
|
|
15
18
|
|
|
16
|
-
private fun getMultiCrossFilterById(filterId: String)
|
|
17
|
-
return if(filterMap[filterId] is MultiFrameResultCrossFilter) {
|
|
19
|
+
private fun getMultiCrossFilterById(filterId: String): MultiFrameResultCrossFilter? {
|
|
20
|
+
return if (filterMap[filterId] is MultiFrameResultCrossFilter) {
|
|
18
21
|
filterMap[filterId] as MultiFrameResultCrossFilter
|
|
19
22
|
} else {
|
|
20
23
|
null
|
|
@@ -82,4 +85,27 @@ class MultiCrossFilterModuleImpl(context: ReactApplicationContext) {
|
|
|
82
85
|
fun setMaxOverlappingFrames(filterId: String, resultItemTypes: Int, maxFrameToCheck: Int) {
|
|
83
86
|
getMultiCrossFilterById(filterId)?.setMaxOverlappingFrames(resultItemTypes, maxFrameToCheck)
|
|
84
87
|
}
|
|
88
|
+
|
|
89
|
+
@ReactMethod
|
|
90
|
+
fun setResultCrossVerificationCriteria(filterId: String, resultItemTypes: Int, criteria: ReadableMap) {
|
|
91
|
+
getMultiCrossFilterById(filterId)?.setResultCrossVerificationCriteria(resultItemTypes, criteria.run {
|
|
92
|
+
CrossVerificationCriteria(
|
|
93
|
+
criteria.getInt("frameWindow"),
|
|
94
|
+
criteria.getInt("minConsistentFrames"),
|
|
95
|
+
)
|
|
96
|
+
})
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
@ReactMethod
|
|
100
|
+
fun getResultCrossVerificationCriteria(filterId: String, resultItemType: Int, promise: Promise) {
|
|
101
|
+
val criteria = getMultiCrossFilterById(filterId)?.getResultCrossVerificationCriteria(resultItemType)
|
|
102
|
+
if (criteria != null) {
|
|
103
|
+
promise.resolve(Arguments.createMap().apply {
|
|
104
|
+
putInt("frameWindow", criteria.frameWindow)
|
|
105
|
+
putInt("minConsistentFrames", criteria.minConsistentFrames)
|
|
106
|
+
})
|
|
107
|
+
} else {
|
|
108
|
+
promise.resolve(null)
|
|
109
|
+
}
|
|
110
|
+
}
|
|
85
111
|
}
|
|
@@ -17,7 +17,7 @@ Pod::Spec.new do |s|
|
|
|
17
17
|
s.private_header_files = "ios/**/*.h"
|
|
18
18
|
s.requires_arc = true
|
|
19
19
|
|
|
20
|
-
s.dependency "DynamsoftCaptureVisionBundle", ">= 3.
|
|
20
|
+
s.dependency "DynamsoftCaptureVisionBundle", ">= 3.4.1000", "< 4.0"
|
|
21
21
|
|
|
22
22
|
install_modules_dependencies(s)
|
|
23
23
|
end
|
|
@@ -47,7 +47,7 @@ Value ImageDataHostObject::get(Runtime &runtime, const PropNameID &propName) {
|
|
|
47
47
|
return arrayBuffer;
|
|
48
48
|
}
|
|
49
49
|
if (name == "release") {
|
|
50
|
-
auto release = [
|
|
50
|
+
auto release = [=, this](Runtime & runtime, const Value& thisValue, const Value* arguments, size_t count) -> Value {
|
|
51
51
|
if(buffer != nullptr) {
|
|
52
52
|
delete[] buffer;
|
|
53
53
|
buffer = nullptr;
|
|
@@ -30,6 +30,20 @@ NSArray<NSNumber *> *CGAffineTransformToArray(CGAffineTransform transform) {
|
|
|
30
30
|
|
|
31
31
|
@end
|
|
32
32
|
|
|
33
|
+
@implementation DSECISegment (JSI)
|
|
34
|
+
|
|
35
|
+
- (nullable NSDictionary *)toJson {
|
|
36
|
+
if (!self) return nil;
|
|
37
|
+
return @{
|
|
38
|
+
@"eciValue" : @(self.eciValue),
|
|
39
|
+
@"charsetEncoding" : self.charsetEncoding,
|
|
40
|
+
@"startIndex" : @(self.startIndex),
|
|
41
|
+
@"length" : @(self.length)
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@end
|
|
46
|
+
|
|
33
47
|
@implementation DSCapturedResultItem (JSI)
|
|
34
48
|
|
|
35
49
|
- (Object)convertToJSIObject:(Runtime& )runtime {
|
|
@@ -50,6 +64,7 @@ NSArray<NSNumber *> *CGAffineTransformToArray(CGAffineTransform transform) {
|
|
|
50
64
|
obj.setProperty(runtime, "_formatNumberString", convertNSStringToJSIString(runtime, [NSNumber numberWithUnsignedInteger:item.format].stringValue));
|
|
51
65
|
obj.setProperty(runtime, "formatString", convertNSStringToJSIString(runtime, item.formatString));
|
|
52
66
|
obj.setProperty(runtime, "text", convertNSStringToJSIString(runtime, item.text));
|
|
67
|
+
obj.setProperty(runtime, "bytes", convertNSStringToJSIString(runtime, [item.bytes base64EncodedStringWithOptions:0]));
|
|
53
68
|
obj.setProperty(runtime, "location", convertNSDictionaryToJSIObject(runtime, [item.location toJson]));
|
|
54
69
|
obj.setProperty(runtime, "confidence", convertNSNumberToJSINumber(runtime, @(item.confidence)));
|
|
55
70
|
obj.setProperty(runtime, "angle", convertNSNumberToJSINumber(runtime, @(item.angle)));
|
|
@@ -133,6 +148,16 @@ NSArray<NSNumber *> *CGAffineTransformToArray(CGAffineTransform transform) {
|
|
|
133
148
|
obj.setProperty(runtime, "pdf417Details", convertNSDictionaryToJSIObject(runtime, [pdf417Dict copy]));
|
|
134
149
|
}
|
|
135
150
|
}
|
|
151
|
+
NSArray<DSECISegment *> *eciSegments = item.eciSegments;
|
|
152
|
+
if (eciSegments && eciSegments.count > 0) {
|
|
153
|
+
NSMutableArray<NSDictionary *> *mutableArray = [NSMutableArray arrayWithCapacity:eciSegments.count];
|
|
154
|
+
for (DSECISegment *eci in eciSegments) {
|
|
155
|
+
[mutableArray addObject:[eci toJson]];
|
|
156
|
+
}
|
|
157
|
+
obj.setProperty(runtime, "eciSegments", convertNSArrayToJSIArray(runtime, [mutableArray copy]));
|
|
158
|
+
} else {
|
|
159
|
+
obj.setProperty(runtime, "eciSegments", jsi::Value::null());
|
|
160
|
+
}
|
|
136
161
|
}
|
|
137
162
|
break;
|
|
138
163
|
case DSCapturedResultItemTypeTextLine:
|
|
@@ -142,13 +167,15 @@ NSArray<NSNumber *> *CGAffineTransformToArray(CGAffineTransform transform) {
|
|
|
142
167
|
obj.setProperty(runtime, "rawText", convertNSStringToJSIString(runtime, item.rawText));
|
|
143
168
|
obj.setProperty(runtime, "location", convertNSDictionaryToJSIObject(runtime, [item.location toJson]));
|
|
144
169
|
obj.setProperty(runtime, "confidence",convertNSNumberToJSINumber(runtime, @(item.confidence)));
|
|
145
|
-
|
|
170
|
+
NSUInteger count = item.charResult.count;
|
|
146
171
|
if (count > 0) {
|
|
147
172
|
jsi::Array array = jsi::Array(runtime, count);
|
|
148
173
|
for (size_t i = 0; i < count; i++) {
|
|
149
174
|
array.setValueAtIndex(runtime, i, convertNSDictionaryToJSIObject(runtime, [[item.charResult objectAtIndex:i] toJson]));
|
|
150
175
|
}
|
|
151
176
|
obj.setProperty(runtime, "characterResults", array);
|
|
177
|
+
} else {
|
|
178
|
+
obj.setProperty(runtime, "characterResults", jsi::Value::null());
|
|
152
179
|
}
|
|
153
180
|
obj.setProperty(runtime, "specificationName", convertNSStringToJSIString(runtime, item.specificationName));
|
|
154
181
|
}
|
|
@@ -167,6 +194,8 @@ NSArray<NSNumber *> *CGAffineTransformToArray(CGAffineTransform transform) {
|
|
|
167
194
|
ImageDataHostObject hostObject = [item.imageData hostObject];
|
|
168
195
|
Object object = Object::createFromHostObject(runtime, std::make_shared<ImageDataHostObject>(hostObject));
|
|
169
196
|
obj.setProperty(runtime, "imageData", object);
|
|
197
|
+
} else {
|
|
198
|
+
obj.setProperty(runtime, "imageData", jsi::Value::null());
|
|
170
199
|
}
|
|
171
200
|
obj.setProperty(runtime, "sourceDeskewQuad", convertNSDictionaryToJSIObject(runtime, [item.sourceDeskewQuad toJson]));
|
|
172
201
|
obj.setProperty(runtime, "crossVerificationStatus", convertNSNumberToJSINumber(runtime, @(item.crossVerificationStatus)));
|
|
@@ -180,6 +209,8 @@ NSArray<NSNumber *> *CGAffineTransformToArray(CGAffineTransform transform) {
|
|
|
180
209
|
ImageDataHostObject hostObject = [item.imageData hostObject];
|
|
181
210
|
Object object = Object::createFromHostObject(runtime, std::make_shared<ImageDataHostObject>(hostObject));
|
|
182
211
|
obj.setProperty(runtime, "imageData", object);
|
|
212
|
+
} else {
|
|
213
|
+
obj.setProperty(runtime, "imageData", jsi::Value::null());
|
|
183
214
|
}
|
|
184
215
|
obj.setProperty(runtime, "originalToLocalMatrix", convertNSArrayToJSIArray(runtime, CGAffineTransformToArray(item.originalToLocalMatrix)));
|
|
185
216
|
break;
|
|
@@ -220,6 +251,8 @@ NSArray<NSNumber *> *CGAffineTransformToArray(CGAffineTransform transform) {
|
|
|
220
251
|
array.setValueAtIndex(runtime, i, [[self.items objectAtIndex:i] convertToJSIObject:runtime]);
|
|
221
252
|
}
|
|
222
253
|
obj.setProperty(runtime, "items", array);
|
|
254
|
+
} else {
|
|
255
|
+
obj.setProperty(runtime, "items", jsi::Value::null());
|
|
223
256
|
}
|
|
224
257
|
return obj;
|
|
225
258
|
}
|