dynamsoft-capture-vision-react-native 2.6.1016 → 3.0.3100

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.
Files changed (112) hide show
  1. package/LICENSE +2 -2
  2. package/README.md +7 -9
  3. package/android/build.gradle +29 -42
  4. package/android/src/{oldarch → main/java}/com/dynamsoft/reactnativelib/CVRModule.kt +4 -4
  5. package/android/src/main/java/com/dynamsoft/reactnativelib/ReactNativeDcvPackage.kt +13 -85
  6. package/android/src/{oldarch → main/java}/com/dynamsoft/reactnativelib/VersionsModule.kt +2 -2
  7. package/android/src/main/java/com/dynamsoft/reactnativelib/cvr/CaptureVisionRouterModuleImpl.kt +23 -25
  8. package/android/src/main/java/com/dynamsoft/reactnativelib/dce/CameraEnhancerModuleImpl.kt +2 -2
  9. package/android/src/main/java/com/dynamsoft/reactnativelib/license/LicenseModuleImpl.kt +1 -1
  10. package/android/src/main/java/com/dynamsoft/reactnativelib/utility/ImageManagerModuleImpl.kt +19 -4
  11. package/android/src/main/java/com/dynamsoft/reactnativelib/utils/ForCore.kt +14 -0
  12. package/android/src/main/java/com/dynamsoft/reactnativelib/utils/ForCvr.kt +12 -7
  13. package/android/src/main/java/com/dynamsoft/reactnativelib/utils/ForDBR.kt +1 -7
  14. package/android/src/main/java/com/dynamsoft/reactnativelib/utils/ForDCE.kt +2 -2
  15. package/android/src/main/java/com/dynamsoft/reactnativelib/utils/ForDDN.kt +27 -19
  16. package/android/src/main/jniLibs/debug/arm64-v8a/librn_dys.so +0 -0
  17. package/android/src/main/jniLibs/debug/armeabi-v7a/librn_dys.so +0 -0
  18. package/android/src/main/jniLibs/debug/x86/librn_dys.so +0 -0
  19. package/android/src/main/jniLibs/debug/x86_64/librn_dys.so +0 -0
  20. package/android/src/main/jniLibs/release/arm64-v8a/librn_dys.so +0 -0
  21. package/android/src/main/jniLibs/release/armeabi-v7a/librn_dys.so +0 -0
  22. package/android/src/main/jniLibs/release/x86/librn_dys.so +0 -0
  23. package/android/src/main/jniLibs/release/x86_64/librn_dys.so +0 -0
  24. package/dynamsoft-capture-vision-react-native.podspec +9 -7
  25. package/ios/CPP/DSImageData+HostObject.h +1 -1
  26. package/ios/CPP/RNDynamsoft+JSI.h +2 -2
  27. package/ios/CPP/RNDynamsoft+JSI.mm +18 -10
  28. package/ios/CPP/RNDynamsoft+Json.h +2 -13
  29. package/ios/CPP/RNDynamsoft+Json.m +48 -39
  30. package/ios/CPP/YeetJSIUtils.h +3 -1
  31. package/ios/CPP/YeetJSIUtils.mm +5 -0
  32. package/ios/RNDynamsoftCameraView.m +1 -1
  33. package/ios/RNDynamsoftCameraViewManager.m +18 -6
  34. package/ios/RNDynamsoftCaptureVisionRouter.mm +76 -45
  35. package/ios/RNDynamsoftImageEditorView.m +1 -1
  36. package/ios/RNDynamsoftImageEditorViewManager.mm +36 -13
  37. package/ios/RNDynamsoftImageManager.mm +33 -4
  38. package/ios/RNDynamsoftImageSourceAdapter.mm +1 -1
  39. package/ios/RNDynamsoftLicense.m +1 -1
  40. package/ios/RNDynamsoftMultiCrossFilter.m +9 -9
  41. package/ios/RNDynamsoftVersions.m +1 -13
  42. package/package.json +3 -11
  43. package/src/core/CapturedResultBase.tsx +18 -0
  44. package/src/core/EnumCaptureResultItemType.tsx +12 -6
  45. package/src/core/EnumCrossVerificationStatus.tsx +6 -6
  46. package/src/core/ImageData.tsx +1 -1
  47. package/src/core/index.tsx +1 -0
  48. package/src/cvr/CaptureVisionRouter.tsx +47 -51
  49. package/src/cvr/CapturedResult.tsx +24 -46
  50. package/src/cvr/CapturedResultReceiver.tsx +12 -19
  51. package/src/cvr/NativeDynamsoftCaptureVisionRouterModule.tsx +2 -2
  52. package/src/cvr/SimplifiedCaptureVisionSettings.tsx +4 -4
  53. package/src/dbr/DecodedBarcodesResult.tsx +3 -17
  54. package/src/dce/DynamsoftCameraViewNativeComponent.ts +2 -2
  55. package/src/dcp/ParsedResult.tsx +3 -14
  56. package/src/ddn/DeskewedImageResultItem.tsx +40 -0
  57. package/src/ddn/DetectedQuadResultItem.tsx +3 -1
  58. package/src/ddn/EnhancedImageResultItem.tsx +20 -0
  59. package/src/ddn/ProcessedDocumentResult.tsx +27 -0
  60. package/src/ddn/SimplifiedDocumentNormalizerSettings.tsx +18 -3
  61. package/src/ddn/index.tsx +3 -3
  62. package/src/dlr/RecognizedTextLinesResult.tsx +2 -16
  63. package/src/index.tsx +0 -1
  64. package/src/utility/ImageManager.tsx +66 -45
  65. package/android/src/main/java/com/dynamsoft/reactnativelib/rtu/BarcodeScannerModuleImpl.kt +0 -80
  66. package/android/src/main/java/com/dynamsoft/reactnativelib/rtu/MRZScannerModuleImpl.kt +0 -77
  67. package/android/src/main/java/com/dynamsoft/reactnativelib/rtu/ScannerInterface.kt +0 -47
  68. package/android/src/main/jniLibs/arm64-v8a/librn_dys.so +0 -0
  69. package/android/src/main/jniLibs/armeabi-v7a/librn_dys.so +0 -0
  70. package/android/src/main/jniLibs/x86/librn_dys.so +0 -0
  71. package/android/src/main/jniLibs/x86_64/librn_dys.so +0 -0
  72. package/android/src/newarch/com/dynamsoft/reactnativelib/BarcodeScannerModule.kt +0 -22
  73. package/android/src/newarch/com/dynamsoft/reactnativelib/CVRModule.kt +0 -91
  74. package/android/src/newarch/com/dynamsoft/reactnativelib/CameraViewManager.kt +0 -52
  75. package/android/src/newarch/com/dynamsoft/reactnativelib/DCEModule.kt +0 -91
  76. package/android/src/newarch/com/dynamsoft/reactnativelib/ISAModule.kt +0 -60
  77. package/android/src/newarch/com/dynamsoft/reactnativelib/ImageEditorViewManager.kt +0 -16
  78. package/android/src/newarch/com/dynamsoft/reactnativelib/ImageEditorViewModule.kt +0 -24
  79. package/android/src/newarch/com/dynamsoft/reactnativelib/ImageManagerModule.kt +0 -12
  80. package/android/src/newarch/com/dynamsoft/reactnativelib/LicenseModule.kt +0 -14
  81. package/android/src/newarch/com/dynamsoft/reactnativelib/MRZScannerModule.kt +0 -22
  82. package/android/src/newarch/com/dynamsoft/reactnativelib/MultiCrossFilterModule.kt +0 -58
  83. package/android/src/newarch/com/dynamsoft/reactnativelib/VersionsModule.kt +0 -41
  84. package/android/src/oldarch/com/dynamsoft/reactnativelib/BarcodeScannerModule.kt +0 -24
  85. package/android/src/oldarch/com/dynamsoft/reactnativelib/MRZScannerModule.kt +0 -24
  86. package/ios/RNDynamsoftBarcodeScanner.h +0 -14
  87. package/ios/RNDynamsoftBarcodeScanner.m +0 -169
  88. package/ios/RNDynamsoftMRZScanner.h +0 -14
  89. package/ios/RNDynamsoftMRZScanner.m +0 -140
  90. package/src/ddn/DetectedQuadsResult.tsx +0 -31
  91. package/src/ddn/NormalizedImageResultItem.tsx +0 -32
  92. package/src/ddn/NormalizedImagesResult.tsx +0 -27
  93. package/src/rtu/BarcodeScanConfig.tsx +0 -104
  94. package/src/rtu/BarcodeScanResult.tsx +0 -31
  95. package/src/rtu/BarcodeScanner.tsx +0 -112
  96. package/src/rtu/EnumResultState.tsx +0 -21
  97. package/src/rtu/MRZScanConfig.tsx +0 -67
  98. package/src/rtu/MRZScanResult.tsx +0 -84
  99. package/src/rtu/MRZScanner.tsx +0 -90
  100. package/src/rtu/NativeDynamsoftBarcodeScannerModule.tsx +0 -6
  101. package/src/rtu/NativeDynamsoftMRZScannerModule.tsx +0 -6
  102. package/src/rtu/index.tsx +0 -7
  103. /package/android/src/main/{withNamespace/AndroidManifest.xml → AndroidManifest.xml} +0 -0
  104. /package/android/src/main/{withoutNamespace/AndroidManifest.xml → AndroidManifest_noPackage.xml} +0 -0
  105. /package/android/src/{oldarch → main/java}/com/dynamsoft/reactnativelib/CameraViewManager.kt +0 -0
  106. /package/android/src/{oldarch → main/java}/com/dynamsoft/reactnativelib/DCEModule.kt +0 -0
  107. /package/android/src/{oldarch → main/java}/com/dynamsoft/reactnativelib/ISAModule.kt +0 -0
  108. /package/android/src/{oldarch → main/java}/com/dynamsoft/reactnativelib/ImageEditorViewManager.kt +0 -0
  109. /package/android/src/{oldarch → main/java}/com/dynamsoft/reactnativelib/ImageEditorViewModule.kt +0 -0
  110. /package/android/src/{oldarch → main/java}/com/dynamsoft/reactnativelib/ImageManagerModule.kt +0 -0
  111. /package/android/src/{oldarch → main/java}/com/dynamsoft/reactnativelib/LicenseModule.kt +0 -0
  112. /package/android/src/{oldarch → main/java}/com/dynamsoft/reactnativelib/MultiCrossFilterModule.kt +0 -0
@@ -3,11 +3,7 @@
3
3
  */
4
4
 
5
5
  #import "RNDynamsoftCaptureVisionRouter.h"
6
- #import <DynamsoftCaptureVisionRouter/DynamsoftCaptureVisionRouter.h>
7
- #import <DynamsoftBarcodeReader/DynamsoftBarcodeReader.h>
8
- #import <DynamsoftLabelRecognizer/DynamsoftLabelRecognizer.h>
9
- #import <DynamsoftDocumentNormalizer/DynamsoftDocumentNormalizer.h>
10
- #import <DynamsoftUtility/DynamsoftUtility.h>
6
+ #import <DynamsoftCaptureVisionBundle/DynamsoftCaptureVisionBundle.h>
11
7
  #import <React/RCTUIManager.h>
12
8
  #import "RNDynamsoftImageSourceAdapter.h"
13
9
  #import "RNDynamsoft+Json.h"
@@ -25,7 +21,9 @@ using namespace std;
25
21
 
26
22
  @property (nonatomic, strong) DSCaptureVisionRouter *cvr;
27
23
 
28
- @property (nonatomic, strong) NSMutableArray<DSImageData *> *imageDataArray;
24
+ @property (nonatomic, strong) NSMutableArray<DSImageData *> *deskewedImageDataArray;
25
+
26
+ @property (nonatomic, strong) NSMutableArray<DSImageData *> *enhancedImageDataArray;
29
27
 
30
28
  @property (nonatomic, strong) NSMutableDictionary<NSString *, NSNumber *> *receiveDictionary;
31
29
 
@@ -55,7 +53,7 @@ RCT_EXPORT_MODULE(DynamsoftCaptureVisionRouterModule)
55
53
 
56
54
  RCT_EXPORT_METHOD(startCapturing:(NSString *)templateName
57
55
  resolve:(RCTPromiseResolveBlock)resolve
58
- rejecter: (RCTPromiseRejectBlock)reject)
56
+ rejecter: (RCTPromiseRejectBlock)reject)
59
57
  {
60
58
  [self.cvr startCapturing:templateName completionHandler:^(BOOL isSuccess, NSError * _Nullable error) {
61
59
  if (!isSuccess && error) {
@@ -88,7 +86,7 @@ RCT_EXPORT_METHOD(setInput:(NSString *)key) {
88
86
  }
89
87
  }
90
88
 
91
- RCT_EXPORT_METHOD(getSettings:(NSString *)name
89
+ RCT_EXPORT_METHOD(getSimplifiedSettings:(NSString *)name
92
90
  resolve:(RCTPromiseResolveBlock)resolve
93
91
  rejecter: (RCTPromiseRejectBlock)reject)
94
92
  {
@@ -105,7 +103,7 @@ RCT_EXPORT_METHOD(getSettings:(NSString *)name
105
103
  RCT_EXPORT_METHOD(updateSettings:(NSDictionary *)dictionary
106
104
  templateName:(NSString *)templateName
107
105
  resolve:(RCTPromiseResolveBlock)resolve
108
- rejecter: (RCTPromiseRejectBlock)reject)
106
+ rejecter: (RCTPromiseRejectBlock)reject)
109
107
  {
110
108
  NSError *error;
111
109
  DSSimplifiedCaptureVisionSettings *settings = [self.cvr getSimplifiedSettings:templateName error:nil];
@@ -120,7 +118,7 @@ RCT_EXPORT_METHOD(updateSettings:(NSDictionary *)dictionary
120
118
  }
121
119
 
122
120
  RCT_EXPORT_METHOD(resetSettings:(RCTPromiseResolveBlock)resolve
123
- rejecter: (RCTPromiseRejectBlock)reject)
121
+ rejecter: (RCTPromiseRejectBlock)reject)
124
122
  {
125
123
  NSError *error;
126
124
  BOOL isSuccess = [self.cvr resetSettings:&error];
@@ -159,11 +157,12 @@ RCT_EXPORT_METHOD(initSettingsFromFile:(NSString *)path
159
157
  }
160
158
 
161
159
  RCT_EXPORT_METHOD(outputSettings:(NSString *)name
160
+ includeDefaultValues:(BOOL)includeDefaultValues
162
161
  resolve:(RCTPromiseResolveBlock)resolve
163
162
  rejecter: (RCTPromiseRejectBlock)reject)
164
163
  {
165
164
  NSError *error;
166
- NSString *setting = [self.cvr outputSettings:name error:&error];
165
+ NSString *setting = [self.cvr outputSettings:name includeDefaultValues:includeDefaultValues error:&error];
167
166
  if (error) {
168
167
  NSString *code = [NSString stringWithFormat:@"%ld",(long)error.code];
169
168
  reject(code, error.localizedDescription, error);
@@ -172,13 +171,14 @@ RCT_EXPORT_METHOD(outputSettings:(NSString *)name
172
171
  }
173
172
  }
174
173
 
175
- RCT_EXPORT_METHOD(outputSettingsToFile:(NSString *)name
174
+ RCT_EXPORT_METHOD(outputSettingsToFile:(NSString *)name
176
175
  file:(NSString *)path
176
+ includeDefaultValues:(BOOL)includeDefaultValues
177
177
  resolve:(RCTPromiseResolveBlock)resolve
178
- rejecter: (RCTPromiseRejectBlock)reject)
178
+ rejecter: (RCTPromiseRejectBlock)reject)
179
179
  {
180
180
  NSError *error;
181
- BOOL isSuccess = [self.cvr outputSettingsToFile:name file:path error:&error];
181
+ BOOL isSuccess = [self.cvr outputSettingsToFile:name filePath:path includeDefaultValues:includeDefaultValues error:&error];
182
182
  if (!isSuccess && error) {
183
183
  NSString *code = [NSString stringWithFormat:@"%ld",(long)error.code];
184
184
  reject(code, error.localizedDescription, error);
@@ -216,8 +216,7 @@ RCT_EXPORT_METHOD(removeFilter:(NSString *)key) {
216
216
  {
217
217
  return @[@"onCapturedResultReceived",
218
218
  @"onDecodedBarcodesReceived",
219
- @"onDetectedQuadsReceived",
220
- @"onNormalizedImagesReceived",
219
+ @"onProcessedDocumentResultReceived",
221
220
  @"onRecognizedTextLinesReceived",
222
221
  @"onParsedResultsReceived"];
223
222
  }
@@ -234,12 +233,19 @@ RCT_EXPORT_METHOD(removeFilter:(NSString *)key) {
234
233
 
235
234
  - (void)onCapturedResultReceived:(DSCapturedResult *)result {
236
235
  if (hasListeners && [self.receiveDictionary valueForKey:@"onCapturedResultReceived"].boolValue) {
237
- [self.imageDataArray removeAllObjects];
238
- DSNormalizedImagesResult *imageResult = result.normalizedImagesResult;
239
- for (DSNormalizedImageResultItem *item in imageResult.items) {
236
+ DSProcessedDocumentResult *imageResult = result.processedDocumentResult;
237
+ [self.deskewedImageDataArray removeAllObjects];
238
+ for (DSDeskewedImageResultItem *item in imageResult.deskewedImageResultItems) {
239
+ DSImageData *data = item.imageData;
240
+ if (data) {
241
+ [self.deskewedImageDataArray addObject:data];
242
+ }
243
+ }
244
+ [self.enhancedImageDataArray removeAllObjects];
245
+ for (DSEnhancedImageResultItem *item in imageResult.enhancedImageResultItems) {
240
246
  DSImageData *data = item.imageData;
241
247
  if (data) {
242
- [self.imageDataArray addObject:data];
248
+ [self.enhancedImageDataArray addObject:data];
243
249
  }
244
250
  }
245
251
  [self sendEventWithName:@"onCapturedResultReceived" body:[result toJson]];
@@ -256,24 +262,23 @@ RCT_EXPORT_METHOD(removeFilter:(NSString *)key) {
256
262
  }
257
263
  }
258
264
 
259
- - (void)onDetectedQuadsReceived:(DSDetectedQuadsResult *)result {
260
- if (hasListeners && [self.receiveDictionary valueForKey:@"onDetectedQuadsReceived"].boolValue) {
261
- [self sendEventWithName:@"onDetectedQuadsReceived" body:[result toJson]];
262
- dispatch_time_t timeout = dispatch_time(DISPATCH_TIME_NOW, 10 * NSEC_PER_SEC);
263
- __unused long result = dispatch_semaphore_wait(semaphore, timeout);
264
- }
265
- }
266
-
267
- - (void)onNormalizedImagesReceived:(DSNormalizedImagesResult *)result {
268
- if (hasListeners && [self.receiveDictionary valueForKey:@"onNormalizedImagesReceived"].boolValue) {
269
- [self.imageDataArray removeAllObjects];
270
- for (DSNormalizedImageResultItem *item in result.items) {
265
+ - (void)onProcessedDocumentResultReceived:(DSProcessedDocumentResult *)result {
266
+ if (hasListeners && [self.receiveDictionary valueForKey:@"onProcessedDocumentResultReceived"].boolValue) {
267
+ [self.deskewedImageDataArray removeAllObjects];
268
+ for (DSDeskewedImageResultItem *item in result.deskewedImageResultItems) {
269
+ DSImageData *data = item.imageData;
270
+ if (data) {
271
+ [self.deskewedImageDataArray addObject:data];
272
+ }
273
+ }
274
+ [self.enhancedImageDataArray removeAllObjects];
275
+ for (DSEnhancedImageResultItem *item in result.enhancedImageResultItems) {
271
276
  DSImageData *data = item.imageData;
272
277
  if (data) {
273
- [self.imageDataArray addObject:data];
278
+ [self.enhancedImageDataArray addObject:data];
274
279
  }
275
280
  }
276
- [self sendEventWithName:@"onNormalizedImagesReceived" body:[result toJson]];
281
+ [self sendEventWithName:@"onProcessedDocumentResultReceived" body:[result toJson]];
277
282
  dispatch_time_t timeout = dispatch_time(DISPATCH_TIME_NOW, 10 * NSEC_PER_SEC);
278
283
  __unused long result = dispatch_semaphore_wait(semaphore, timeout);
279
284
  }
@@ -296,11 +301,18 @@ RCT_EXPORT_METHOD(removeFilter:(NSString *)key) {
296
301
  }
297
302
 
298
303
  #pragma mark - Private
299
- - (NSMutableArray<DSImageData *> *)imageDataArray {
300
- if (!_imageDataArray) {
301
- _imageDataArray = [NSMutableArray array];
304
+ - (NSMutableArray<DSImageData *> *)deskewedImageDataArray {
305
+ if (!_deskewedImageDataArray) {
306
+ _deskewedImageDataArray = [NSMutableArray array];
302
307
  }
303
- return _imageDataArray;
308
+ return _deskewedImageDataArray;
309
+ }
310
+
311
+ - (NSMutableArray<DSImageData *> *)enhancedImageDataArray {
312
+ if (!_enhancedImageDataArray) {
313
+ _enhancedImageDataArray = [NSMutableArray array];
314
+ }
315
+ return _enhancedImageDataArray;
304
316
  }
305
317
 
306
318
  - (NSMutableDictionary<NSString *,DSMultiFrameResultCrossFilter *> *)filterDictionary {
@@ -382,23 +394,42 @@ static void install(jsi::Runtime &jsiRuntime, RNDynamsoftCaptureVisionRouter *rn
382
394
  const Value &thisValue,
383
395
  const Value *arguments,
384
396
  size_t count) -> Value {
385
- NSString *bytes = convertJSIStringToNSString(runtime, arguments[0].getString(runtime));
397
+ ArrayBuffer buffer = arguments[0].asObject(runtime).getArrayBuffer(runtime);
398
+ NSData *data = convertArrayBufferToNSData(runtime, buffer);
386
399
  NSString *name = convertJSIStringToNSString(runtime, arguments[1].getString(runtime));
387
- NSData *data = [[NSData alloc] initWithBase64EncodedString:bytes options:(NSDataBase64DecodingIgnoreUnknownCharacters)];
388
400
  DSCapturedResult *result = [rnCapture.cvr captureFromFileBytes:data templateName:name];
389
401
  return [result convertToJSIObject:runtime];
390
402
  });
391
403
  jsiRuntime.global().setProperty(jsiRuntime, captureFileBytes, std::move(captureFileBytesFunc));
392
404
 
393
- const char* getCurrentNormalizedImages = "getCurrentNormalizedImages";
394
- auto getCurrentNormalizedImagesFunc = Function::createFromHostFunction(jsiRuntime,
395
- PropNameID::forAscii(jsiRuntime, getCurrentNormalizedImages),
405
+ const char* getCurrentDeskewedImages = "getCurrentDeskewedImages";
406
+ auto getCurrentDeskewedImagesFunc = Function::createFromHostFunction(jsiRuntime,
407
+ PropNameID::forAscii(jsiRuntime, getCurrentDeskewedImages),
408
+ 0,
409
+ [rnCapture](Runtime &runtime,
410
+ const Value &thisValue,
411
+ const Value *arguments,
412
+ size_t count) -> Value {
413
+ NSMutableArray<DSImageData *> *imageDataArray = rnCapture.deskewedImageDataArray;
414
+ Array array(runtime, imageDataArray.count);
415
+ for (int i = 0; i < imageDataArray.count; i++) {
416
+ ImageDataHostObject hostObject = [[imageDataArray objectAtIndex:i] hostObject];
417
+ Object obj = Object::createFromHostObject(runtime, std::make_shared<ImageDataHostObject>(hostObject));
418
+ array.setValueAtIndex(runtime, i, obj);
419
+ }
420
+ return array;
421
+ });
422
+ jsiRuntime.global().setProperty(jsiRuntime, getCurrentDeskewedImages, std::move(getCurrentDeskewedImagesFunc));
423
+
424
+ const char* getCurrentEnhancedImages = "getCurrentEnhancedImages";
425
+ auto getCurrentEnhancedImagesFunc = Function::createFromHostFunction(jsiRuntime,
426
+ PropNameID::forAscii(jsiRuntime, getCurrentEnhancedImages),
396
427
  0,
397
428
  [rnCapture](Runtime &runtime,
398
429
  const Value &thisValue,
399
430
  const Value *arguments,
400
431
  size_t count) -> Value {
401
- NSMutableArray<DSImageData *> *imageDataArray = rnCapture.imageDataArray;
432
+ NSMutableArray<DSImageData *> *imageDataArray = rnCapture.enhancedImageDataArray;
402
433
  Array array(runtime, imageDataArray.count);
403
434
  for (int i = 0; i < imageDataArray.count; i++) {
404
435
  ImageDataHostObject hostObject = [[imageDataArray objectAtIndex:i] hostObject];
@@ -407,7 +438,7 @@ static void install(jsi::Runtime &jsiRuntime, RNDynamsoftCaptureVisionRouter *rn
407
438
  }
408
439
  return array;
409
440
  });
410
- jsiRuntime.global().setProperty(jsiRuntime, getCurrentNormalizedImages, std::move(getCurrentNormalizedImagesFunc));
441
+ jsiRuntime.global().setProperty(jsiRuntime, getCurrentEnhancedImages, std::move(getCurrentEnhancedImagesFunc));
411
442
 
412
443
  const char* getOriginalImage = "cvr_getOriginalImage";
413
444
  auto getOriginalImageFunc = Function::createFromHostFunction(jsiRuntime,
@@ -3,7 +3,7 @@
3
3
  */
4
4
 
5
5
  #import "RNDynamsoftImageEditorView.h"
6
- #import <DynamsoftCameraEnhancer/DynamsoftCameraEnhancer.h>
6
+ #import <DynamsoftCaptureVisionBundle/DynamsoftCaptureVisionBundle.h>
7
7
 
8
8
  @implementation RNDynamsoftImageEditorView
9
9
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  #import "RNDynamsoftImageEditorViewManager.h"
6
6
  #import "RNDynamsoftImageEditorView.h"
7
- #import <DynamsoftCameraEnhancer/DynamsoftCameraEnhancer.h>
7
+ #import <DynamsoftCaptureVisionBundle/DynamsoftCaptureVisionBundle.h>
8
8
  #import <React/RCTBridge+Private.h>
9
9
  #import "DSImageData+HostObject.h"
10
10
  #import <React/RCTUIManager.h>
@@ -23,11 +23,24 @@ RCT_EXPORT_MODULE(DynamsoftImageEditorView)
23
23
  }
24
24
 
25
25
  RCT_EXPORT_METHOD(setQuads:(nonnull NSNumber *)tag quadArray:(NSArray *)array layerId:(NSInteger)layerId) {
26
+ [self trySetQuadsWithTag:tag quadArray:array layerId:layerId attempt:1];
27
+ }
28
+
29
+ - (void)trySetQuadsWithTag:(nonnull NSNumber *)tag quadArray:(NSArray *)array layerId:(NSInteger)layerId attempt:(NSInteger)attempt {
30
+ const NSInteger maxAttempts = 10;
31
+ const NSTimeInterval retryDelay = 0.1; // 100ms
32
+
26
33
  [self.bridge.uiManager addUIBlock:
27
34
  ^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
28
35
  id view = viewRegistry[tag];
29
36
  if (!view || ![view isKindOfClass:[RNDynamsoftImageEditorView class]]) {
30
- RCTLogError(@"Cannot find RNDynamsoftImageEditorView with tag #%@", tag);
37
+ if (attempt < maxAttempts) {
38
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(retryDelay * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
39
+ [self trySetQuadsWithTag:tag quadArray:array layerId:layerId attempt:attempt + 1];
40
+ });
41
+ } else {
42
+ RCTLogError(@"Cannot find RNDynamsoftImageEditorView with tag #%@ after %ld attempts", tag, (long)attempt);
43
+ }
31
44
  } else {
32
45
  if (array && array.count > 0) {
33
46
  NSMutableArray<DSQuadDrawingItem *> *items = [NSMutableArray array];
@@ -46,7 +59,7 @@ RCT_EXPORT_METHOD(setQuads:(nonnull NSNumber *)tag quadArray:(NSArray *)array la
46
59
 
47
60
  RCT_EXPORT_METHOD(getSelectedQuad:(nonnull NSNumber *)tag
48
61
  resolver:(RCTPromiseResolveBlock)resolve
49
- rejecter:(RCTPromiseRejectBlock)reject)
62
+ rejecter:(RCTPromiseRejectBlock)reject)
50
63
  {
51
64
  [self.bridge.uiManager addUIBlock:
52
65
  ^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
@@ -100,7 +113,7 @@ static void install(jsi::Runtime &jsiRuntime, RNDynamsoftImageEditorViewManager
100
113
  if (obj.isHostObject<ImageDataHostObject>(runtime)) {
101
114
  ImageDataHostObject hostObject = ImageDataHostObject::getHOFromObject(runtime, std::move(obj));
102
115
  DSImageData *data = [DSImageData imageDataFromHostObject:hostObject];
103
- [rnEditorViewManager setImageData:data toView:@(tag)];
116
+ [rnEditorViewManager trySetImageDataWithTag:@(tag) data:data attempt:1];
104
117
  return Value(true);
105
118
  }
106
119
  return Value(false);
@@ -109,15 +122,25 @@ static void install(jsi::Runtime &jsiRuntime, RNDynamsoftImageEditorViewManager
109
122
  jsiRuntime.global().setProperty(jsiRuntime, setOriginalImage, std::move(setOriginalImageFunc));
110
123
  }
111
124
 
112
- - (void)setImageData:(DSImageData *)data toView:(nonnull NSNumber *)tag {
113
- dispatch_async(dispatch_get_main_queue(), ^{
114
- UIView *view = [self.bridge.uiManager viewForReactTag:tag];
115
- if (!view || ![view isKindOfClass:[RNDynamsoftImageEditorView class]]) {
116
- RCTLogError(@"Cannot find RNDynamsoftImageEditorView with tag #%@", tag);
117
- } else {
118
- ((RNDynamsoftImageEditorView *)view).editorView.imageData = data;
119
- }
120
- });
125
+ - (void)trySetImageDataWithTag:(nonnull NSNumber *)tag data:(DSImageData *)data attempt:(NSInteger)attempt {
126
+ const NSInteger maxAttempts = 10;
127
+ const NSTimeInterval retryDelay = 0.1; // 100ms
128
+
129
+ [self.bridge.uiManager addUIBlock:
130
+ ^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
131
+ id view = viewRegistry[tag];
132
+ if (!view || ![view isKindOfClass:[RNDynamsoftImageEditorView class]]) {
133
+ if (attempt < maxAttempts) {
134
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(retryDelay * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
135
+ [self trySetImageDataWithTag:tag data:data attempt:1];
136
+ });
137
+ } else {
138
+ RCTLogError(@"Cannot find RNDynamsoftImageEditorView with tag #%@ after %ld attempts", tag, (long)attempt);
139
+ }
140
+ } else {
141
+ ((RNDynamsoftImageEditorView *)view).editorView.imageData = data;
142
+ }
143
+ }];
121
144
  }
122
145
 
123
146
  @end
@@ -3,7 +3,7 @@
3
3
  */
4
4
 
5
5
  #import "RNDynamsoftImageManager.h"
6
- #import <DynamsoftUtility/DynamsoftUtility.h>
6
+ #import <DynamsoftCaptureVisionBundle/DynamsoftCaptureVisionBundle.h>
7
7
  #import <React/RCTBridge+Private.h>
8
8
  #import <React/RCTUtils.h>
9
9
  #import <jsi/jsi.h>
@@ -19,7 +19,9 @@ using namespace std;
19
19
 
20
20
  @interface RNDynamsoftImageManager ()
21
21
 
22
- @property (nonatomic, strong) DSImageManager *manager;
22
+ @property (nonatomic, strong) DSImageIO *manager;
23
+ @property (nonatomic, strong) DSImageDrawer *drawer;
24
+ @property (nonatomic, strong) DSImageProcessor *processor;
23
25
 
24
26
  @end
25
27
 
@@ -29,7 +31,9 @@ using namespace std;
29
31
  {
30
32
  self = [super init];
31
33
  if (self) {
32
- _manager = [[DSImageManager alloc] init];
34
+ _manager = [[DSImageIO alloc] init];
35
+ _drawer = [[DSImageDrawer alloc] init];
36
+ _processor = [[DSImageProcessor alloc] init];
33
37
  }
34
38
  return self;
35
39
  }
@@ -107,7 +111,7 @@ static void install(jsi::Runtime &jsiRuntime, RNDynamsoftImageManager *rnManager
107
111
  green:((hexColor >> 8) & 0xFF) / 255.0
108
112
  blue:(hexColor & 0xFF) / 255.0
109
113
  alpha:((hexColor >> 24) & 0xFF) / 255.0];
110
- DSImageData *imageData = [rnManager.manager drawOnImage:data quads:[mutableArray copy] colour:color thickness:thickness];
114
+ DSImageData *imageData = [rnManager.drawer drawOnImage:data quads:[mutableArray copy] colour:color thickness:thickness];
111
115
  ImageDataHostObject outImageData = [imageData hostObject];
112
116
  Object outObj = Object::createFromHostObject(runtime, std::make_shared<ImageDataHostObject>(outImageData));
113
117
  return outObj;
@@ -115,6 +119,31 @@ static void install(jsi::Runtime &jsiRuntime, RNDynamsoftImageManager *rnManager
115
119
  return Value(false);
116
120
  });
117
121
  jsiRuntime.global().setProperty(jsiRuntime, drawOnImageName, std::move(drawOnImageFunc));
122
+
123
+ const char* cropImageName = "imageManager_cropImage";
124
+ auto cropImageFunc = Function::createFromHostFunction(jsiRuntime,
125
+ PropNameID::forAscii(jsiRuntime,
126
+ cropImageName),
127
+ 2,
128
+ [rnManager](Runtime &runtime,
129
+ const Value& /*thisValue*/,
130
+ const Value* arguments,
131
+ size_t count) -> Value {
132
+ Object obj = arguments[0].getObject(runtime);
133
+ if (obj.isHostObject<ImageDataHostObject>(runtime)) {
134
+ ImageDataHostObject hostObject = ImageDataHostObject::getHOFromObject(runtime, std::move(obj));
135
+ DSImageData *data = [DSImageData imageDataFromHostObject:hostObject];
136
+ Object obj = arguments[1].getObject(runtime);
137
+ DSQuadrilateral *quad = convertJSIValueToDSQuadrilateral(runtime, obj);
138
+ NSError *error;
139
+ DSImageData *imageData = [rnManager.processor cropImage:data quad:quad error:&error];
140
+ ImageDataHostObject outImageData = [imageData hostObject];
141
+ Object outObj = Object::createFromHostObject(runtime, std::make_shared<ImageDataHostObject>(outImageData));
142
+ return outObj;
143
+ }
144
+ return Value(false);
145
+ });
146
+ jsiRuntime.global().setProperty(jsiRuntime, cropImageName, std::move(cropImageFunc));
118
147
  }
119
148
 
120
149
  @end
@@ -8,7 +8,7 @@
8
8
  #import <jsi/jsi.h>
9
9
  #import <sys/utsname.h>
10
10
  #import "YeetJSIUtils.h"
11
- #import <DynamsoftCore/DynamsoftCore.h>
11
+ #import <DynamsoftCaptureVisionBundle/DynamsoftCaptureVisionBundle.h>
12
12
  #import "DSImageData+HostObject.h"
13
13
 
14
14
  using namespace facebook::jsi;
@@ -3,7 +3,7 @@
3
3
  */
4
4
 
5
5
  #import "RNDynamsoftLicense.h"
6
- #import <DynamsoftLicense/DynamsoftLicense.h>
6
+ #import <DynamsoftCaptureVisionBundle/DynamsoftCaptureVisionBundle.h>
7
7
 
8
8
  @interface RNDynamsoftLicense () <DSLicenseVerificationListener>
9
9
 
@@ -3,7 +3,7 @@
3
3
  */
4
4
 
5
5
  #import "RNDynamsoftMultiCrossFilter.h"
6
- #import <DynamsoftUtility/DynamsoftUtility.h>
6
+ #import <DynamsoftCaptureVisionBundle/DynamsoftCaptureVisionBundle.h>
7
7
  #import "RNDynamsoftCaptureVisionRouter.h"
8
8
 
9
9
  @implementation RNDynamsoftMultiCrossFilter
@@ -29,10 +29,10 @@ RCT_EXPORT_METHOD(enableResultCrossVerification:(NSString *)key type:(NSInteger)
29
29
  [filter enableResultCrossVerification:type isEnabled:isEnabled];
30
30
  }
31
31
 
32
- RCT_EXPORT_METHOD(isResultCrossVerificationEnabled:(NSString *)key
32
+ RCT_EXPORT_METHOD(isResultCrossVerificationEnabled:(NSString *)key
33
33
  type:(NSInteger)type
34
34
  resolver:(RCTPromiseResolveBlock)resolve
35
- rejecter:(RCTPromiseRejectBlock)reject)
35
+ rejecter:(RCTPromiseRejectBlock)reject)
36
36
  {
37
37
  RNDynamsoftCaptureVisionRouter *router = [self.bridge moduleForClass:[RNDynamsoftCaptureVisionRouter class]];
38
38
  DSMultiFrameResultCrossFilter *filter = [router.filterDictionary objectForKey:key];
@@ -61,10 +61,10 @@ RCT_EXPORT_METHOD(setDuplicateForgetTime:(NSString *)key type:(NSInteger)type ti
61
61
  [filter setDuplicateForgetTime:type duplicateForgetTime:time];
62
62
  }
63
63
 
64
- RCT_EXPORT_METHOD(getDuplicateForgetTime:(NSString *)key
64
+ RCT_EXPORT_METHOD(getDuplicateForgetTime:(NSString *)key
65
65
  type:(NSInteger)type
66
66
  resolver:(RCTPromiseResolveBlock)resolve
67
- rejecter:(RCTPromiseRejectBlock)reject)
67
+ rejecter:(RCTPromiseRejectBlock)reject)
68
68
  {
69
69
  RNDynamsoftCaptureVisionRouter *router = [self.bridge moduleForClass:[RNDynamsoftCaptureVisionRouter class]];
70
70
  DSMultiFrameResultCrossFilter *filter = [router.filterDictionary objectForKey:key];
@@ -77,10 +77,10 @@ RCT_EXPORT_METHOD(enableLatestOverlapping:(NSString *)key type:(NSInteger)type i
77
77
  [filter enableLatestOverlapping:type isEnabled:isEnabled];
78
78
  }
79
79
 
80
- RCT_EXPORT_METHOD(isLatestOverlappingEnabled:(NSString *)key
80
+ RCT_EXPORT_METHOD(isLatestOverlappingEnabled:(NSString *)key
81
81
  type:(NSInteger)type
82
82
  resolver:(RCTPromiseResolveBlock)resolve
83
- rejecter:(RCTPromiseRejectBlock)reject)
83
+ rejecter:(RCTPromiseRejectBlock)reject)
84
84
  {
85
85
  RNDynamsoftCaptureVisionRouter *router = [self.bridge moduleForClass:[RNDynamsoftCaptureVisionRouter class]];
86
86
  DSMultiFrameResultCrossFilter *filter = [router.filterDictionary objectForKey:key];
@@ -93,10 +93,10 @@ RCT_EXPORT_METHOD(setMaxOverlappingFrames:(NSString *)key type:(NSInteger)type m
93
93
  [filter setMaxOverlappingFrames:type maxOverlappingFrames:maxOverlappingFrames];
94
94
  }
95
95
 
96
- RCT_EXPORT_METHOD(getMaxOverlappingFrames:(NSString *)key
96
+ RCT_EXPORT_METHOD(getMaxOverlappingFrames:(NSString *)key
97
97
  type:(NSInteger)type
98
98
  resolver:(RCTPromiseResolveBlock)resolve
99
- rejecter:(RCTPromiseRejectBlock)reject)
99
+ rejecter:(RCTPromiseRejectBlock)reject)
100
100
  {
101
101
  RNDynamsoftCaptureVisionRouter *router = [self.bridge moduleForClass:[RNDynamsoftCaptureVisionRouter class]];
102
102
  DSMultiFrameResultCrossFilter *filter = [router.filterDictionary objectForKey:key];
@@ -3,19 +3,7 @@
3
3
  */
4
4
 
5
5
  #import "RNDynamsoftVersions.h"
6
- #import <DynamsoftCore/DynamsoftCore.h>
7
- #import <DynamsoftLicense/DynamsoftLicense.h>
8
- #import <DynamsoftImageProcessing/DynamsoftImageProcessing.h>
9
- #import <DynamsoftCaptureVisionRouter/DynamsoftCaptureVisionRouter.h>
10
- #import <DynamsoftBarcodeReader/DynamsoftBarcodeReader.h>
11
- #import <DynamsoftLabelRecognizer/DynamsoftLabelRecognizer.h>
12
- #import <DynamsoftDocumentNormalizer/DynamsoftDocumentNormalizer.h>
13
- #import <DynamsoftCameraEnhancer/DynamsoftCameraEnhancer.h>
14
- #import <DynamsoftNeuralNetwork/DynamsoftNeuralNetwork.h>
15
- #import <DynamsoftUtility/DynamsoftUtility.h>
16
- #import <DynamsoftCodeParser/DynamsoftCodeParser.h>
17
- #import <DynamsoftCodeParserDedicator/DynamsoftCodeParserDedicator.h>
18
- #import <DynamsoftImageProcessing/DynamsoftImageProcessing.h>
6
+ #import <DynamsoftCaptureVisionBundle/DynamsoftCaptureVisionBundle.h>
19
7
 
20
8
  @implementation RNDynamsoftVersions
21
9
 
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "dynamsoft-capture-vision-react-native",
3
3
  "title": "Dynamsoft Capture Vision React Native",
4
- "version": "2.6.1016",
5
- "description": "Dynamsoft Capture Vision React Native SDK. The SDK supports barcode decoding, document scanning and MRZ reading.",
4
+ "version": "3.0.3100",
5
+ "description": "The Dynamsoft Capture Vision React Native SDK provides a wrapper for building barcode scanning, document scanning and MRZ scanning applications with React Native.",
6
6
  "homepage": "https://github.com/Dynamsoft/capture-vision-react-native-samples",
7
7
  "main": "src/index.tsx",
8
8
  "files": [
@@ -37,7 +37,7 @@
37
37
  "url": "https://www.dynamsoft.com",
38
38
  "email": "support@dynamsoft.com"
39
39
  },
40
- "license": "MIT",
40
+ "license": "Apache-2.0",
41
41
  "licenseFilename": "LICENSE",
42
42
  "readmeFilename": "README.md",
43
43
  "peerDependencies": {
@@ -58,13 +58,5 @@
58
58
  "react-native": "0.75.2",
59
59
  "typedoc": "^0.27.7",
60
60
  "typescript": "5.2.2"
61
- },
62
- "codegenConfig": {
63
- "name": "DynamsoftSpecs",
64
- "type": "all",
65
- "jsSrcsDir": "src",
66
- "android": {
67
- "javaPackageName": "com.dynamsoft.reactnativelib"
68
- }
69
61
  }
70
62
  }
@@ -0,0 +1,18 @@
1
+ import {IntermediateResultManager} from "../cvr";
2
+
3
+ export interface CapturedResultBase {
4
+ /**
5
+ * The hash ID of the original image.
6
+ * @see {@link IntermediateResultManager.getOriginalImage}
7
+ * */
8
+ originalImageHashId: string;
9
+
10
+ /**Error code associated with the capture result.*/
11
+ errorCode: number;
12
+
13
+ /**Error string providing details about the error.*/
14
+ errorMessage: string;
15
+
16
+ /**the rotation transformation matrix of the original image relative to the rotated image.*/
17
+ rotationTransformMatrix: Array<number>;
18
+ }
@@ -1,9 +1,9 @@
1
1
  import type {BarcodeResultItem} from "../dbr";
2
2
  import type {TextLineResultItem} from "../dlr";
3
- import type {DetectedQuadResultItem, NormalizedImageResultItem} from "../ddn";
3
+ import type {DetectedQuadResultItem, EnhancedImageResultItem, DeskewedImageResultItem} from "../ddn";
4
4
  import type {ParsedResultItem} from "../dcp";
5
5
 
6
- /**{@link BarcodeResultItem} {@link TextLineResultItem} {@link DetectedQuadResultItem} {@link NormalizedImageResultItem} {@link ParsedResultItem}* */
6
+ /**{@link BarcodeResultItem} {@link TextLineResultItem} {@link DetectedQuadResultItem} {@link DeskewedImageResultItem} {@link ParsedResultItem} {@link EnhancedImageResultItem}* */
7
7
 
8
8
  /**
9
9
  * Defines the various categories of items that can be recognized and captured.
@@ -33,14 +33,20 @@ export enum EnumCapturedResultItemType {
33
33
  CRIT_DETECTED_QUAD = 0x8,
34
34
 
35
35
  /**
36
- * The type of the CapturedResultItem is "normalized image".
37
- * @see {@link NormalizedImageResultItem}
36
+ * The type of the CapturedResultItem is "deskewed image".
37
+ * @see {@link DeskewedImageResultItem}
38
38
  * */
39
- CRIT_NORMALIZED_IMAGE = 0x10,
39
+ CRIT_DESKEWED_IMAGE = 0x10,
40
40
 
41
41
  /**
42
42
  * The type of the CapturedResultItem is "parsed result".
43
43
  * @see {@link ParsedResultItem}
44
44
  * */
45
- CRIT_PARSED_RESULT = 0x20
45
+ CRIT_PARSED_RESULT = 0x20,
46
+
47
+ /**
48
+ * The type of the CapturedResultItem is "enhanced image".
49
+ * @see {@link EnhancedImageResultItem}
50
+ * */
51
+ CRIT_ENHANCED_IMAGE = 0x40,
46
52
  }
@@ -1,4 +1,4 @@
1
- import type {DetectedQuadResultItem, NormalizedImageResultItem} from "../ddn";
1
+ import {type DetectedQuadResultItem, type DeskewedImageResultItem} from "../ddn";
2
2
  import {CaptureVisionRouter} from "../cvr";
3
3
  import {MultiFrameResultCrossFilter} from "../utility";
4
4
  /**
@@ -12,11 +12,11 @@ import {MultiFrameResultCrossFilter} from "../utility";
12
12
  * router.addFilter(filter)
13
13
  *
14
14
  * router.addResultReceiver({
15
- * onDetectedQuadsReceived: result => {
16
- * if(result.items && result.items.length > 0) {
15
+ * onProcessedDocumentResultReceived: result => {
16
+ * if(result.detectedQuadResultItems && result.detectedQuadResultItems.length > 0) {
17
17
  * //Because result cross verification of DETECT_QUAD is enabled,
18
18
  * //crossVerificationStatus of item will be CVS_PASSED or CVS_FAILED.
19
- * let crossVerificationStatus = result.items[0].crossVerificationStatus
19
+ * let crossVerificationStatus = result.detectedQuadResultItems[0].crossVerificationStatus
20
20
  * }
21
21
  * },
22
22
  * })
@@ -28,11 +28,11 @@ import {MultiFrameResultCrossFilter} from "../utility";
28
28
  * or added {@link MultiFrameResultCrossFilter} doesn't enable verification for the corresponding type,
29
29
  * the crossVerificationStatus property of the item for that type will always remain {@link CVS_NOT_VERIFIED}.
30
30
  * <p>
31
- * Currently, only {@link DetectedQuadResultItem} and {@link NormalizedImageResultItem} have the crossVerificationStatus property.
31
+ * Currently, only {@link DetectedQuadResultItem} and {@link DeskewedImageResultItem} have the crossVerificationStatus property.
32
32
  *
33
33
  * @see {@link MultiFrameResultCrossFilter.enableResultCrossVerification}
34
34
  * @see {@link DetectedQuadResultItem.crossVerificationStatus}
35
- * @see {@link NormalizedImageResultItem.crossVerificationStatus}
35
+ * @see {@link DeskewedImageResultItem.crossVerificationStatus}
36
36
  * */
37
37
  export enum EnumCrossVerificationStatus {
38
38
  /** The cross verification has not been performed yet. */
@@ -20,7 +20,7 @@ declare global {
20
20
  * */
21
21
  export interface ImageData {
22
22
  /**
23
- * The raw bytes of the image, of type {@link ArrayBuffer}.
23
+ * The raw bytes of the image, of type {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer ArrayBuffer}.
24
24
  * */
25
25
  buffer: ArrayBuffer;
26
26