dynamsoft-capture-vision-react-native 2.4.2000-alpha.2 → 2.6.1002

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 (99) hide show
  1. package/LICENSE +5 -0
  2. package/README.md +32 -4
  3. package/android/build.gradle +1 -5
  4. package/android/src/main/java/com/dynamsoft/reactnativelib/dce/CameraEnhancerModuleImpl.kt +73 -64
  5. package/android/src/main/java/com/dynamsoft/reactnativelib/dce/ImageEditorViewManagerImpl.kt +2 -18
  6. package/android/src/main/java/com/dynamsoft/reactnativelib/dce/ImageEditorViewModuleImpl.kt +49 -51
  7. package/android/src/main/java/com/dynamsoft/reactnativelib/dce/RNImageEditorView.kt +19 -0
  8. package/android/src/main/java/com/dynamsoft/reactnativelib/utils/ForDDN.kt +2 -0
  9. package/android/src/newarch/com/dynamsoft/reactnativelib/CameraViewManager.kt +6 -0
  10. package/dynamsoft-capture-vision-react-native.podspec +3 -5
  11. package/ios/CPP/RNDynamsoft+JSI.h +19 -0
  12. package/ios/CPP/RNDynamsoft+JSI.mm +145 -0
  13. package/ios/{RNDynamsoftCaptureVision/CPP → CPP}/RNDynamsoft+Json.h +12 -5
  14. package/ios/{RNDynamsoftCaptureVision/CPP/RNDynamsoft+Json.mm → CPP/RNDynamsoft+Json.m} +6 -124
  15. package/ios/{RNDynamsoftCaptureVision/RNDynamsoftCaptureVisionRouter.mm → RNDynamsoftCaptureVisionRouter.mm} +1 -0
  16. package/ios/{RNDynamsoftCaptureVision/RNDynamsoftImageEditorViewManager.mm → RNDynamsoftImageEditorViewManager.mm} +5 -1
  17. package/ios/{RNDynamsoftCaptureVision/RNDynamsoftImageManager.mm → RNDynamsoftImageManager.mm} +6 -2
  18. package/package.json +2 -2
  19. package/src/core/CapturedResultItem.tsx +18 -2
  20. package/src/core/CompletionListener.tsx +4 -3
  21. package/src/core/CoreModule.tsx +3 -3
  22. package/src/core/DSRect.tsx +28 -21
  23. package/src/core/EnumCaptureResultItemType.tsx +38 -7
  24. package/src/core/EnumColourChannelUsageType.tsx +25 -7
  25. package/src/core/EnumCrossVerificationStatus.tsx +43 -0
  26. package/src/core/EnumGrayscaleEnhancementMode.tsx +40 -7
  27. package/src/core/EnumGrayscaleTransformationMode.tsx +29 -5
  28. package/src/core/EnumPixelFormat.tsx +37 -32
  29. package/src/core/ImageData.tsx +51 -4
  30. package/src/core/ImageSourceAdapter.tsx +132 -72
  31. package/src/core/NativeDynamsoftImageSourceAdapterModule.tsx +24 -13
  32. package/src/core/Point.tsx +12 -9
  33. package/src/core/Quadrilateral.tsx +9 -5
  34. package/src/core/Rect.tsx +19 -16
  35. package/src/cvr/CaptureVisionRouter.tsx +571 -279
  36. package/src/cvr/CapturedResult.tsx +117 -76
  37. package/src/cvr/CapturedResultFilter.tsx +7 -0
  38. package/src/cvr/CapturedResultReceiver.tsx +59 -3
  39. package/src/cvr/EnumPresetTemplate.tsx +66 -1
  40. package/src/cvr/SimplifiedCaptureVisionSettings.tsx +45 -0
  41. package/src/dbr/BarcodeResultItem.tsx +31 -1
  42. package/src/dbr/DecodedBarcodesResult.tsx +18 -0
  43. package/src/dbr/EnumBarcodeFormat.tsx +61 -50
  44. package/src/dbr/EnumDeblurMode.tsx +28 -12
  45. package/src/dbr/EnumLocalizationMode.tsx +15 -1
  46. package/src/dbr/SimplifiedBarcodeReaderSettings.tsx +72 -12
  47. package/src/dce/CameraEnhancer.tsx +211 -89
  48. package/src/dce/CameraView.tsx +18 -1
  49. package/src/dce/DynamsoftCameraViewNativeComponent.ts +43 -0
  50. package/src/dce/EnumCameraPosition.tsx +3 -0
  51. package/src/dce/EnumDrawingLayerId.tsx +11 -0
  52. package/src/dce/EnumEnhancedFeatures.tsx +23 -7
  53. package/src/dce/EnumFocusMode.tsx +2 -0
  54. package/src/dce/FeedBack.tsx +9 -0
  55. package/src/dce/ImageEditorView.tsx +35 -2
  56. package/src/dcp/EnumMappingStatus.tsx +12 -3
  57. package/src/dcp/EnumValidationStatus.tsx +12 -3
  58. package/src/dcp/ParsedResult.tsx +16 -0
  59. package/src/dcp/ParsedResultItem.tsx +35 -0
  60. package/src/ddn/DetectedQuadResultItem.tsx +23 -0
  61. package/src/ddn/DetectedQuadsResult.tsx +20 -1
  62. package/src/ddn/EnumImageColourMode.tsx +9 -0
  63. package/src/ddn/NormalizedImageResultItem.tsx +25 -0
  64. package/src/ddn/NormalizedImagesResult.tsx +17 -1
  65. package/src/ddn/SimplifiedDocumentNormalizerSettings.tsx +38 -2
  66. package/src/dlr/CharacterResult.tsx +17 -0
  67. package/src/dlr/RecognizedTextLinesResult.tsx +23 -1
  68. package/src/dlr/SimplifiedLabelRecognizerSettings.tsx +21 -0
  69. package/src/dlr/TextLineResultItem.tsx +26 -0
  70. package/src/license/LicenseManager.tsx +19 -0
  71. package/src/utility/ImageManager.tsx +23 -0
  72. package/src/utility/MultiFrameResultCrossFilter.tsx +99 -6
  73. package/android/.gitignore +0 -4
  74. package/ios/ReactNativeDcv.xcodeproj/project.pbxproj +0 -390
  75. /package/ios/{RNDynamsoftCaptureVision/CPP → CPP}/DSImageData+HostObject.h +0 -0
  76. /package/ios/{RNDynamsoftCaptureVision/CPP → CPP}/DSImageData+HostObject.mm +0 -0
  77. /package/ios/{RNDynamsoftCaptureVision/CPP → CPP}/ImageDataHostObject.cpp +0 -0
  78. /package/ios/{RNDynamsoftCaptureVision/CPP → CPP}/ImageDataHostObject.hpp +0 -0
  79. /package/ios/{RNDynamsoftCaptureVision/CPP → CPP}/MutableRawBuffer.cpp +0 -0
  80. /package/ios/{RNDynamsoftCaptureVision/CPP → CPP}/MutableRawBuffer.hpp +0 -0
  81. /package/ios/{RNDynamsoftCaptureVision/CPP → CPP}/YeetJSIUtils.h +0 -0
  82. /package/ios/{RNDynamsoftCaptureVision/CPP → CPP}/YeetJSIUtils.mm +0 -0
  83. /package/ios/{RNDynamsoftCaptureVision/RNDynamsoftCameraView.h → RNDynamsoftCameraView.h} +0 -0
  84. /package/ios/{RNDynamsoftCaptureVision/RNDynamsoftCameraView.m → RNDynamsoftCameraView.m} +0 -0
  85. /package/ios/{RNDynamsoftCaptureVision/RNDynamsoftCameraViewManager.h → RNDynamsoftCameraViewManager.h} +0 -0
  86. /package/ios/{RNDynamsoftCaptureVision/RNDynamsoftCameraViewManager.m → RNDynamsoftCameraViewManager.m} +0 -0
  87. /package/ios/{RNDynamsoftCaptureVision/RNDynamsoftCaptureVisionRouter.h → RNDynamsoftCaptureVisionRouter.h} +0 -0
  88. /package/ios/{RNDynamsoftCaptureVision/RNDynamsoftImageEditorView.h → RNDynamsoftImageEditorView.h} +0 -0
  89. /package/ios/{RNDynamsoftCaptureVision/RNDynamsoftImageEditorView.m → RNDynamsoftImageEditorView.m} +0 -0
  90. /package/ios/{RNDynamsoftCaptureVision/RNDynamsoftImageEditorViewManager.h → RNDynamsoftImageEditorViewManager.h} +0 -0
  91. /package/ios/{RNDynamsoftCaptureVision/RNDynamsoftImageManager.h → RNDynamsoftImageManager.h} +0 -0
  92. /package/ios/{RNDynamsoftCaptureVision/RNDynamsoftImageSourceAdapter.h → RNDynamsoftImageSourceAdapter.h} +0 -0
  93. /package/ios/{RNDynamsoftCaptureVision/RNDynamsoftImageSourceAdapter.mm → RNDynamsoftImageSourceAdapter.mm} +0 -0
  94. /package/ios/{RNDynamsoftCaptureVision/RNDynamsoftLicense.h → RNDynamsoftLicense.h} +0 -0
  95. /package/ios/{RNDynamsoftCaptureVision/RNDynamsoftLicense.m → RNDynamsoftLicense.m} +0 -0
  96. /package/ios/{RNDynamsoftCaptureVision/RNDynamsoftMultiCrossFilter.h → RNDynamsoftMultiCrossFilter.h} +0 -0
  97. /package/ios/{RNDynamsoftCaptureVision/RNDynamsoftMultiCrossFilter.m → RNDynamsoftMultiCrossFilter.m} +0 -0
  98. /package/ios/{RNDynamsoftCaptureVision/RNDynamsoftVersions.h → RNDynamsoftVersions.h} +0 -0
  99. /package/ios/{RNDynamsoftCaptureVision/RNDynamsoftVersions.m → RNDynamsoftVersions.m} +0 -0
@@ -0,0 +1,145 @@
1
+ /*
2
+ * Copyright © Dynamsoft Corporation. All rights reserved.
3
+ */
4
+
5
+ #import "RNDynamsoft+JSI.h"
6
+ #import "RNDynamsoft+Json.h"
7
+ #import "DSImageData+HostObject.h"
8
+ #import "YeetJSIUtils.h"
9
+ #import <DynamsoftCore/DynamsoftCore.h>
10
+ #import <DynamsoftCaptureVisionRouter/DynamsoftCaptureVisionRouter.h>
11
+ #import <DynamsoftBarcodeReader/DynamsoftBarcodeReader.h>
12
+ #import <DynamsoftLabelRecognizer/DynamsoftLabelRecognizer.h>
13
+ #import <DynamsoftDocumentNormalizer/DynamsoftDocumentNormalizer.h>
14
+ #import <DynamsoftCodeParser/DynamsoftCodeParser.h>
15
+
16
+ NSArray<NSNumber *> *CGAffineTransformToArray(CGAffineTransform transform) {
17
+ return @[@(transform.a), @(transform.b), @(transform.c), @(transform.d), @(transform.tx), @(transform.ty)];
18
+ }
19
+
20
+ @implementation DSCapturedResultItem (JSI)
21
+
22
+ - (Object)convertToJSIObject:(Runtime& )runtime {
23
+ Object obj = Object(runtime);
24
+ obj.setProperty(runtime, "type", convertNSNumberToJSINumber(runtime, @(self.type)));
25
+ obj.setProperty(runtime, "targetROIDefName", convertNSStringToJSIString(runtime, self.targetROIDefName));
26
+ obj.setProperty(runtime, "taskName", convertNSStringToJSIString(runtime, self.taskName));
27
+ switch (self.type) {
28
+ case DSCapturedResultItemTypeOriginalImage:
29
+ {
30
+
31
+ }
32
+ break;
33
+ case DSCapturedResultItemTypeBarcode:
34
+ {
35
+ DSBarcodeResultItem *item = (DSBarcodeResultItem *)self;
36
+ obj.setProperty(runtime, "format", convertNSNumberToJSINumber(runtime, @(item.format)));
37
+ obj.setProperty(runtime, "formatString", convertNSStringToJSIString(runtime, item.formatString));
38
+ obj.setProperty(runtime, "text", convertNSStringToJSIString(runtime, item.text));
39
+ obj.setProperty(runtime, "location", convertNSDictionaryToJSIObject(runtime, [item.location toJson]));
40
+ obj.setProperty(runtime, "confidence", convertNSNumberToJSINumber(runtime, @(item.confidence)));
41
+ obj.setProperty(runtime, "angle", convertNSNumberToJSINumber(runtime, @(item.angle)));
42
+ obj.setProperty(runtime, "moduleSize", convertNSNumberToJSINumber(runtime, @(item.moduleSize)));
43
+ obj.setProperty(runtime, "isDPM", convertNSNumberToJSIBoolean(runtime, @(item.isDPM)));
44
+ obj.setProperty(runtime, "isMirrored", convertNSNumberToJSIBoolean(runtime, @(item.isMirrored)));
45
+ }
46
+ break;
47
+ case DSCapturedResultItemTypeTextLine:
48
+ {
49
+ DSTextLineResultItem *item = (DSTextLineResultItem *)self;
50
+ obj.setProperty(runtime, "text", convertNSStringToJSIString(runtime, item.text));
51
+ obj.setProperty(runtime, "location", convertNSDictionaryToJSIObject(runtime, [item.location toJson]));
52
+ obj.setProperty(runtime, "confidence",convertNSNumberToJSINumber(runtime, @(item.confidence)));
53
+ int count = item.charResult.count;
54
+ if (count > 0) {
55
+ jsi::Array array = jsi::Array(runtime, count);
56
+ for (size_t i = 0; i < count; i++) {
57
+ array.setValueAtIndex(runtime, i, convertNSDictionaryToJSIObject(runtime, [[item.charResult objectAtIndex:i] toJson]));
58
+ }
59
+ obj.setProperty(runtime, "charResult", array);
60
+ }
61
+ }
62
+ break;
63
+ case DSCapturedResultItemTypeDetectedQuad:
64
+ {
65
+ DSDetectedQuadResultItem *item = (DSDetectedQuadResultItem *)self;
66
+ obj.setProperty(runtime, "location", convertNSDictionaryToJSIObject(runtime, [item.location toJson]));
67
+ obj.setProperty(runtime, "confidenceAsDocumentBoundary",convertNSNumberToJSINumber(runtime, @(item.confidenceAsDocumentBoundary)));
68
+ }
69
+ break;
70
+ case DSCapturedResultItemTypeNormalizedImage:
71
+ {
72
+ DSNormalizedImageResultItem *item = (DSNormalizedImageResultItem *)self;
73
+ if (item.imageData) {
74
+ ImageDataHostObject hostObject = [item.imageData hostObject];
75
+ Object object = Object::createFromHostObject(runtime, std::make_shared<ImageDataHostObject>(hostObject));
76
+ obj.setProperty(runtime, "imageData", object);
77
+ }
78
+ obj.setProperty(runtime, "location", convertNSDictionaryToJSIObject(runtime, [item.location toJson]));
79
+ }
80
+ break;
81
+ case DSCapturedResultItemTypeParsedResult:
82
+ {
83
+ DSParsedResultItem *item = (DSParsedResultItem *)self;
84
+ NSDictionary<NSString *, NSString *> *parsedFields = item.parsedFields;
85
+ NSMutableDictionary *mutableDictionary = [NSMutableDictionary dictionaryWithDictionary:parsedFields];
86
+ for (NSString *key in [parsedFields allKeys]) {
87
+ [mutableDictionary setValue:@{ @"value":[parsedFields valueForKey:key],
88
+ @"mappingStatus":@([item getFieldMappingStatus:key]),
89
+ @"validationStatus":@([item getFieldValidationStatus:key]) } forKey:key];
90
+ }
91
+ obj.setProperty(runtime, "", convertNSDictionaryToJSIObject(runtime, [mutableDictionary copy]));
92
+ obj.setProperty(runtime, "jsonString", convertNSStringToJSIString(runtime, item.jsonString));
93
+ obj.setProperty(runtime, "codeType", convertNSStringToJSIString(runtime, item.codeType));
94
+ }
95
+ break;
96
+ }
97
+ return obj;
98
+ }
99
+
100
+ @end
101
+
102
+ @implementation DSCapturedResult (JSI)
103
+
104
+ - (Object)convertToJSIObject:(Runtime& )runtime {
105
+ Object obj = Object(runtime);
106
+ obj.setProperty(runtime, "originalImageHashId", convertNSStringToJSIString(runtime, self.originalImageHashId));
107
+ obj.setProperty(runtime, "errorMessage", convertNSStringToJSIString(runtime, self.errorMessage));
108
+ obj.setProperty(runtime, "errorCode", convertNSNumberToJSINumber(runtime, @(self.errorCode)));
109
+ obj.setProperty(runtime, "rotationTransformMatrix", convertNSArrayToJSIArray(runtime, CGAffineTransformToArray(self.rotationTransformMatrix)));
110
+ int count = (int)self.items.count;
111
+ if (count > 0) {
112
+ jsi::Array array = jsi::Array(runtime, count);
113
+ for (size_t i = 0; i < count; i++) {
114
+ array.setValueAtIndex(runtime, i, [[self.items objectAtIndex:i] convertToJSIObject:runtime]);
115
+ }
116
+ obj.setProperty(runtime, "items", array);
117
+ }
118
+ return obj;
119
+ }
120
+
121
+ @end
122
+
123
+ DSQuadrilateral * convertJSIValueToDSQuadrilateral(
124
+ jsi::Runtime &runtime,
125
+ const jsi::Object &value)
126
+ {
127
+ if (value.hasProperty(runtime, "points") && value.getProperty(runtime, "points").isObject() && value.getProperty(runtime, "points").getObject(runtime).isArray(runtime)) {
128
+ auto jsiPoints = value.getProperty(runtime, "points").getObject(runtime).getArray(runtime);
129
+ size_t size = jsiPoints.size(runtime);
130
+ NSMutableArray *points = [NSMutableArray array];
131
+ for (size_t i = 0; i < size; i++) {
132
+ auto jsiPoint = jsiPoints.getValueAtIndex(runtime, i).getObject(runtime);
133
+ if (jsiPoint.hasProperty(runtime, "x") && jsiPoint.hasProperty(runtime, "y")) {
134
+ double x = jsiPoint.getProperty(runtime, "x").getNumber();
135
+ double y = jsiPoint.getProperty(runtime, "y").getNumber();
136
+ CGPoint point = CGPointMake(x, y);
137
+ [points addObject:[NSValue valueWithCGPoint:point]];
138
+ }
139
+ }
140
+ if (points.count == 4) {
141
+ return [[DSQuadrilateral alloc] initWithPointArray:[points copy]];
142
+ }
143
+ }
144
+ return nil;
145
+ }
@@ -8,7 +8,6 @@
8
8
  #import <DynamsoftLabelRecognizer/DynamsoftLabelRecognizer.h>
9
9
  #import <DynamsoftDocumentNormalizer/DynamsoftDocumentNormalizer.h>
10
10
  #import <DynamsoftCodeParser/DynamsoftCodeParser.h>
11
- #import "YeetJSIUtils.h"
12
11
 
13
12
  NS_ASSUME_NONNULL_BEGIN
14
13
 
@@ -20,6 +19,12 @@ NS_ASSUME_NONNULL_BEGIN
20
19
 
21
20
  @end
22
21
 
22
+ @interface DSCharacterResult (Json)
23
+
24
+ - (NSDictionary *)toJson;
25
+
26
+ @end
27
+
23
28
  @interface DSSimplifiedCaptureVisionSettings (Json)
24
29
 
25
30
  - (void)updateWithDicitionary:(NSDictionary *)dictionary;
@@ -52,12 +57,16 @@ NS_ASSUME_NONNULL_BEGIN
52
57
 
53
58
  @end
54
59
 
60
+ @interface DSCapturedResultItem (Json)
61
+
62
+ - (nullable NSDictionary *)toJson;
63
+
64
+ @end
65
+
55
66
  @interface DSCapturedResult (Json)
56
67
 
57
68
  - (NSObject *)toJson;
58
69
 
59
- - (Object)convertToJSIObject:(Runtime& )runtime;
60
-
61
70
  @end
62
71
 
63
72
  @interface DSDecodedBarcodesResult (Json)
@@ -91,5 +100,3 @@ NS_ASSUME_NONNULL_BEGIN
91
100
  @end
92
101
 
93
102
  NS_ASSUME_NONNULL_END
94
-
95
- DSQuadrilateral * _Nullable convertJSIValueToDSQuadrilateral(jsi::Runtime &runtime, const jsi::Object &value);
@@ -3,7 +3,6 @@
3
3
  */
4
4
 
5
5
  #import "RNDynamsoft+Json.h"
6
- #import "DSImageData+HostObject.h"
7
6
 
8
7
  NSArray<NSNumber *> *CGAffineTransformToArray(CGAffineTransform transform) {
9
8
  return @[@(transform.a), @(transform.b), @(transform.c), @(transform.d), @(transform.tx), @(transform.ty)];
@@ -228,7 +227,7 @@ NSArray<NSNumber *> *CGAffineTransformToArray(CGAffineTransform transform) {
228
227
  @"characterModelName":self.characterModelName ? self.characterModelName : [NSNull null],
229
228
  @"lineStringRegExPattern":self.lineStringRegExPattern ? self.lineStringRegExPattern : [NSNull null],
230
229
  @"maxThreadsInOneTask":@(self.maxThreadsInOneTask),
231
- @"scaleDownThreshold":@(self.scaleDownThreshold)
230
+ @"scaleDownThreshold":@(self.scaleDownThreshold)
232
231
  };
233
232
  return dictionary;
234
233
  } else {
@@ -364,7 +363,8 @@ NSArray<NSNumber *> *CGAffineTransformToArray(CGAffineTransform transform) {
364
363
  @"targetROIDefName":item.targetROIDefName,
365
364
  @"taskName":item.taskName,
366
365
  @"location":[item.location toJson],
367
- @"confidenceAsDocumentBoundary":@(item.confidenceAsDocumentBoundary)
366
+ @"confidenceAsDocumentBoundary":@(item.confidenceAsDocumentBoundary),
367
+ @"crossVerificationStatus":@(item.crossVerificationStatus)
368
368
  };
369
369
  }
370
370
  break;
@@ -374,7 +374,9 @@ NSArray<NSNumber *> *CGAffineTransformToArray(CGAffineTransform transform) {
374
374
  dictionary = @{ @"type":@(item.type),
375
375
  @"targetROIDefName":item.targetROIDefName,
376
376
  @"taskName":item.taskName,
377
- @"location":[item.location toJson] };
377
+ @"location":[item.location toJson],
378
+ @"crossVerificationStatus":@(item.crossVerificationStatus)
379
+ };
378
380
  }
379
381
  break;
380
382
  case DSCapturedResultItemTypeParsedResult:
@@ -400,84 +402,6 @@ NSArray<NSNumber *> *CGAffineTransformToArray(CGAffineTransform transform) {
400
402
  return dictionary;
401
403
  }
402
404
 
403
- - (Object)convertToJSIObject:(Runtime& )runtime {
404
- Object obj = Object(runtime);
405
- obj.setProperty(runtime, "type", convertNSNumberToJSINumber(runtime, @(self.type)));
406
- obj.setProperty(runtime, "targetROIDefName", convertNSStringToJSIString(runtime, self.targetROIDefName));
407
- obj.setProperty(runtime, "taskName", convertNSStringToJSIString(runtime, self.taskName));
408
- switch (self.type) {
409
- case DSCapturedResultItemTypeOriginalImage:
410
- {
411
-
412
- }
413
- break;
414
- case DSCapturedResultItemTypeBarcode:
415
- {
416
- DSBarcodeResultItem *item = (DSBarcodeResultItem *)self;
417
- obj.setProperty(runtime, "format", convertNSNumberToJSINumber(runtime, @(item.format)));
418
- obj.setProperty(runtime, "formatString", convertNSStringToJSIString(runtime, item.formatString));
419
- obj.setProperty(runtime, "text", convertNSStringToJSIString(runtime, item.text));
420
- obj.setProperty(runtime, "location", convertNSDictionaryToJSIObject(runtime, [item.location toJson]));
421
- obj.setProperty(runtime, "confidence", convertNSNumberToJSINumber(runtime, @(item.confidence)));
422
- obj.setProperty(runtime, "angle", convertNSNumberToJSINumber(runtime, @(item.angle)));
423
- obj.setProperty(runtime, "moduleSize", convertNSNumberToJSINumber(runtime, @(item.moduleSize)));
424
- obj.setProperty(runtime, "isDPM", convertNSNumberToJSIBoolean(runtime, @(item.isDPM)));
425
- obj.setProperty(runtime, "isMirrored", convertNSNumberToJSIBoolean(runtime, @(item.isMirrored)));
426
- }
427
- break;
428
- case DSCapturedResultItemTypeTextLine:
429
- {
430
- DSTextLineResultItem *item = (DSTextLineResultItem *)self;
431
- obj.setProperty(runtime, "text", convertNSStringToJSIString(runtime, item.text));
432
- obj.setProperty(runtime, "location", convertNSDictionaryToJSIObject(runtime, [item.location toJson]));
433
- obj.setProperty(runtime, "confidence",convertNSNumberToJSINumber(runtime, @(item.confidence)));
434
- int count = item.charResult.count;
435
- if (count > 0) {
436
- jsi::Array array = jsi::Array(runtime, count);
437
- for (size_t i = 0; i < count; i++) {
438
- array.setValueAtIndex(runtime, i, convertNSDictionaryToJSIObject(runtime, [[item.charResult objectAtIndex:i] toJson]));
439
- }
440
- obj.setProperty(runtime, "charResult", array);
441
- }
442
- }
443
- break;
444
- case DSCapturedResultItemTypeDetectedQuad:
445
- {
446
- DSDetectedQuadResultItem *item = (DSDetectedQuadResultItem *)self;
447
- obj.setProperty(runtime, "location", convertNSDictionaryToJSIObject(runtime, [item.location toJson]));
448
- obj.setProperty(runtime, "confidenceAsDocumentBoundary",convertNSNumberToJSINumber(runtime, @(item.confidenceAsDocumentBoundary)));
449
- }
450
- break;
451
- case DSCapturedResultItemTypeNormalizedImage:
452
- {
453
- DSNormalizedImageResultItem *item = (DSNormalizedImageResultItem *)self;
454
- if (item.imageData) {
455
- ImageDataHostObject hostObject = [item.imageData hostObject];
456
- Object object = Object::createFromHostObject(runtime, std::make_shared<ImageDataHostObject>(hostObject));
457
- obj.setProperty(runtime, "imageData", object);
458
- }
459
- obj.setProperty(runtime, "location", convertNSDictionaryToJSIObject(runtime, [item.location toJson]));
460
- }
461
- break;
462
- case DSCapturedResultItemTypeParsedResult:
463
- {
464
- DSParsedResultItem *item = (DSParsedResultItem *)self;
465
- NSDictionary<NSString *, NSString *> *parsedFields = item.parsedFields;
466
- NSMutableDictionary *mutableDictionary = [NSMutableDictionary dictionaryWithDictionary:parsedFields];
467
- for (NSString *key in [parsedFields allKeys]) {
468
- [mutableDictionary setValue:@{ @"value":[parsedFields valueForKey:key],
469
- @"mappingStatus":@([item getFieldMappingStatus:key]),
470
- @"validationStatus":@([item getFieldValidationStatus:key]) } forKey:key];
471
- }
472
- obj.setProperty(runtime, "", convertNSDictionaryToJSIObject(runtime, [mutableDictionary copy]));
473
- obj.setProperty(runtime, "jsonString", convertNSStringToJSIString(runtime, item.jsonString));
474
- obj.setProperty(runtime, "codeType", convertNSStringToJSIString(runtime, item.codeType));
475
- }
476
- break;
477
- }
478
- return obj;
479
- }
480
-
481
405
  @end
482
406
 
483
407
  @implementation DSCapturedResult (Json)
@@ -509,23 +433,6 @@ NSArray<NSNumber *> *CGAffineTransformToArray(CGAffineTransform transform) {
509
433
  }
510
434
  }
511
435
 
512
- - (Object)convertToJSIObject:(Runtime& )runtime {
513
- Object obj = Object(runtime);
514
- obj.setProperty(runtime, "originalImageHashId", convertNSStringToJSIString(runtime, self.originalImageHashId));
515
- obj.setProperty(runtime, "errorMessage", convertNSStringToJSIString(runtime, self.errorMessage));
516
- obj.setProperty(runtime, "errorCode", convertNSNumberToJSINumber(runtime, @(self.errorCode)));
517
- obj.setProperty(runtime, "rotationTransformMatrix", convertNSArrayToJSIArray(runtime, CGAffineTransformToArray(self.rotationTransformMatrix)));
518
- int count = (int)self.items.count;
519
- if (count > 0) {
520
- jsi::Array array = jsi::Array(runtime, count);
521
- for (size_t i = 0; i < count; i++) {
522
- array.setValueAtIndex(runtime, i, [[self.items objectAtIndex:i] convertToJSIObject:runtime]);
523
- }
524
- obj.setProperty(runtime, "items", array);
525
- }
526
- return obj;
527
- }
528
-
529
436
  @end
530
437
 
531
438
  @implementation DSDecodedBarcodesResult (Json)
@@ -681,28 +588,3 @@ NSArray<NSNumber *> *CGAffineTransformToArray(CGAffineTransform transform) {
681
588
  }
682
589
 
683
590
  @end
684
-
685
-
686
- DSQuadrilateral * convertJSIValueToDSQuadrilateral(
687
- jsi::Runtime &runtime,
688
- const jsi::Object &value)
689
- {
690
- if (value.hasProperty(runtime, "points") && value.getProperty(runtime, "points").isObject() && value.getProperty(runtime, "points").getObject(runtime).isArray(runtime)) {
691
- auto jsiPoints = value.getProperty(runtime, "points").getObject(runtime).getArray(runtime);
692
- size_t size = jsiPoints.size(runtime);
693
- NSMutableArray *points = [NSMutableArray array];
694
- for (size_t i = 0; i < size; i++) {
695
- auto jsiPoint = jsiPoints.getValueAtIndex(runtime, i).getObject(runtime);
696
- if (jsiPoint.hasProperty(runtime, "x") && jsiPoint.hasProperty(runtime, "y")) {
697
- double x = jsiPoint.getProperty(runtime, "x").getNumber();
698
- double y = jsiPoint.getProperty(runtime, "y").getNumber();
699
- CGPoint point = CGPointMake(x, y);
700
- [points addObject:[NSValue valueWithCGPoint:point]];
701
- }
702
- }
703
- if (points.count == 4) {
704
- return [[DSQuadrilateral alloc] initWithPointArray:[points copy]];
705
- }
706
- }
707
- return nil;
708
- }
@@ -11,6 +11,7 @@
11
11
  #import <React/RCTUIManager.h>
12
12
  #import "RNDynamsoftImageSourceAdapter.h"
13
13
  #import "RNDynamsoft+Json.h"
14
+ #import "RNDynamsoft+JSI.h"
14
15
  #import <jsi/jsi.h>
15
16
  #import <React/RCTBridge+Private.h>
16
17
  #import "DSImageData+HostObject.h"
@@ -58,7 +58,11 @@ RCT_EXPORT_METHOD(getSelectedQuad:(nonnull NSNumber *)tag
58
58
  DSDrawingItem *item = [((RNDynamsoftImageEditorView *)view).editorView getSelectedDrawingItem];
59
59
  if (item && item.mediaType == DSDrawingItemMediaTypeQuadrilateral) {
60
60
  DSQuadDrawingItem *quadItem = (DSQuadDrawingItem *)item;
61
- resolve([quadItem.quad toJson]);
61
+ if (quadItem) {
62
+ resolve([quadItem.quad toJson]);
63
+ } else {
64
+ resolve(nil);
65
+ }
62
66
  }
63
67
  }
64
68
  }];
@@ -11,6 +11,7 @@
11
11
  #import "YeetJSIUtils.h"
12
12
  #import "DSImageData+HostObject.h"
13
13
  #import "RNDynamsoft+Json.h"
14
+ #import "RNDynamsoft+JSI.h"
14
15
 
15
16
  using namespace facebook::jsi;
16
17
  using namespace facebook;
@@ -100,13 +101,16 @@ static void install(jsi::Runtime &jsiRuntime, RNDynamsoftImageManager *rnManager
100
101
  [mutableArray addObject:quad];
101
102
  }
102
103
  }
103
- int hexColor = arguments[2].getNumber();
104
+ NSInteger hexColor = arguments[2].getNumber();
104
105
  int thickness = arguments[3].getNumber();
105
106
  UIColor *color = [UIColor colorWithRed:((hexColor >> 16) & 0xFF) / 255.0
106
107
  green:((hexColor >> 8) & 0xFF) / 255.0
107
108
  blue:(hexColor & 0xFF) / 255.0
108
109
  alpha:((hexColor >> 24) & 0xFF) / 255.0];
109
- [rnManager.manager drawOnImage:data quads:[mutableArray copy] colour:color thickness:thickness];
110
+ DSImageData *imageData = [rnManager.manager drawOnImage:data quads:[mutableArray copy] colour:color thickness:thickness];
111
+ ImageDataHostObject outImageData = [imageData hostObject];
112
+ Object outObj = Object::createFromHostObject(runtime, std::make_shared<ImageDataHostObject>(outImageData));
113
+ return outObj;
110
114
  }
111
115
  return Value(false);
112
116
  });
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "dynamsoft-capture-vision-react-native",
3
3
  "title": "Dynamsoft Capture Vision React Native",
4
- "version": "2.4.2000-alpha.2",
4
+ "version": "2.6.1002",
5
5
  "description": "Dynamsoft Capture Vision React Native SDK. The SDK supports barcode decoding, document scanning and MRZ reading.",
6
- "homepage": "https://www.dynamsoft.com/capture-vision/docs/mobile/programming/react-native/",
6
+ "homepage": "https://github.com/Dynamsoft/capture-vision-react-native-samples",
7
7
  "main": "src/index.tsx",
8
8
  "files": [
9
9
  "README.md",
@@ -1,7 +1,23 @@
1
- import type { EnumCapturedResultItemType } from "./EnumCaptureResultItemType";
1
+ import type {EnumCapturedResultItemType} from "./EnumCaptureResultItemType";
2
2
 
3
+ /**
4
+ * The CapturedResultItem class provides a common structure for representing different types of captured results.
5
+ * Each specific captured result item type will have its own implementation and additional properties specific to that type.
6
+ * */
3
7
  export interface CapturedResultItem {
4
- type: EnumCapturedResultItemType | number ;
8
+ /**
9
+ * The type of the captured result item.
10
+ * - {@link EnumCapturedResultItemType}: An enum representing the specific type of the captured result.
11
+ */
12
+ type: EnumCapturedResultItemType | number;
13
+
14
+ /**
15
+ * The name of the task that generated the result.
16
+ * */
5
17
  taskName?: string;
18
+
19
+ /**
20
+ * the name of the TargetROIDef object which includes a task that generated the result.
21
+ * */
6
22
  targetROIDefName?: string;
7
23
  }
@@ -1,4 +1,5 @@
1
1
  export interface CompletionListener {
2
- onSuccess(): void,
3
- onFailure(errorCode: number, errorMessage: string): void
4
- }
2
+ onSuccess(): void,
3
+
4
+ onFailure(errorCode: number, errorMessage: string): void
5
+ }
@@ -2,7 +2,7 @@ import {DynamsoftVersions} from '../VersionsModule'
2
2
  import {Platform} from "react-native";
3
3
 
4
4
  export class CoreModule {
5
- static getVersion(): string {
6
- return '['+Platform.OS+']: ' + DynamsoftVersions.core
7
- }
5
+ static getVersion(): string {
6
+ return '[' + Platform.OS + ']: ' + DynamsoftVersions.core
7
+ }
8
8
  }
@@ -1,23 +1,30 @@
1
+ /**
2
+ * The DSRect class represents a rectangle in 2D space,
3
+ * which contains four integer values that specify the top, left, right, and bottom edges of the rectangle.
4
+ * @see CameraEnhancer.setScanRegion
5
+ * */
1
6
  export interface DSRect {
2
- /**
3
- * Y coordinate of the buttom border of the region.
4
- */
5
- bottom: number;
6
- /**
7
- * X coordinate of the right border of the region.
8
- */
9
- right: number;
10
- /**
11
- * X coordinate of the left border of the region.
12
- */
13
- left: number;
14
- /**
15
- * Y coordinate of the top border of the region.
16
- */
17
- top: number;
18
- /**
19
- * 1/True: the coordinates are measured by percentage.
20
- * 0/False: the coordinates are measured by pixel distance.
21
- */
22
- measuredInPercentage: number | boolean;
7
+ /**
8
+ * The distance between the top of the rect and the x-axis.
9
+ * If {@link measuredInPercentage} = 1/true, the value specifies the percentage comparing with the height of the parent.
10
+ * If {@link measuredInPercentage} = 0/false, the value specifies a pixel length.
11
+ */
12
+ top: number;
13
+ /**
14
+ * Y coordinate of the buttom border of the region.
15
+ */
16
+ bottom: number;
17
+ /**
18
+ * X coordinate of the right border of the region.
19
+ */
20
+ right: number;
21
+ /**
22
+ * X coordinate of the left border of the region.
23
+ */
24
+ left: number;
25
+ /**
26
+ * 1/True: the coordinates are measured by percentage.
27
+ * 0/False: the coordinates are measured by pixel distance.
28
+ */
29
+ measuredInPercentage: number | boolean;
23
30
  }
@@ -1,8 +1,39 @@
1
+ /**
2
+ * Defines the various categories of items that can be recognized and captured.
3
+ * */
1
4
  export enum EnumCapturedResultItemType {
2
- CRIT_ORIGINAL_IMAGE = 0x1,
3
- CRIT_BARCODE = 0x2,
4
- CRIT_TEXT_LINE = 0x4,
5
- CRIT_DETECTED_QUAD = 0x8,
6
- CRIT_NORMALIZED_IMAGE = 0x10,
7
- CRIT_PARSED_RESULT = 0x20
8
- }
5
+ /**
6
+ * Not use for react-native edition
7
+ * */
8
+ CRIT_ORIGINAL_IMAGE = 0x1,
9
+
10
+ /**
11
+ * The type of the CapturedResultItem is "barcode".
12
+ * @see BarcodeResultItem
13
+ * */
14
+ CRIT_BARCODE = 0x2,
15
+
16
+ /**
17
+ * The type of the CapturedResultItem is "text line".
18
+ * @see TextLineResultItem
19
+ * */
20
+ CRIT_TEXT_LINE = 0x4,
21
+
22
+ /**
23
+ * The type of the CapturedResultItem is "detected quad".
24
+ * @see DetectedQuadResultItem
25
+ * */
26
+ CRIT_DETECTED_QUAD = 0x8,
27
+
28
+ /**
29
+ * The type of the CapturedResultItem is "normalized image".
30
+ * @see NormalizedImageResultItem
31
+ * */
32
+ CRIT_NORMALIZED_IMAGE = 0x10,
33
+
34
+ /**
35
+ * The type of the CapturedResultItem is "parsed result".
36
+ * @see ParsedResultItem
37
+ * */
38
+ CRIT_PARSED_RESULT = 0x20
39
+ }
@@ -1,8 +1,26 @@
1
+ /**
2
+ * Enumerates the different ways color channels can be utilized in image processing.
3
+ * This allows for flexible image analysis and manipulation by specifying how color data should be handled.
4
+ *
5
+ * @see ImageSourceAdapter.getColourChannelUsageType
6
+ * @see ImageSourceAdapter.setColourChannelUsageType
7
+ * */
1
8
  export enum EnumColourChannelUsageType {
2
- CCUT_AUTO = 0,
3
- CCUT_FULL_CHANNEL = 1,
4
- CCUT_Y_CHANNEL_ONLY = 2,
5
- CCUT_RGB_R_CHANNEL_ONLY = 3,
6
- CCUT_RGB_G_CHANNEL_ONLY = 4,
7
- CCUT_RGB_B_CHANNEL_ONLY = 5
8
- }
9
+ /** Automatic color channel usage determination based on image pixel format and scene. */
10
+ CCUT_AUTO = 0,
11
+
12
+ /** Automatic color channel usage determination based on image pixel format and scene. */
13
+ CCUT_FULL_CHANNEL = 1,
14
+
15
+ /** Use only the Y (luminance) channel for processing in images represented in the NV21 format. */
16
+ CCUT_Y_CHANNEL_ONLY = 2,
17
+
18
+ /** Use only the red channel for processing in RGB images.*/
19
+ CCUT_RGB_R_CHANNEL_ONLY = 3,
20
+
21
+ /** Use only the green channel for processing in RGB images.*/
22
+ CCUT_RGB_G_CHANNEL_ONLY = 4,
23
+
24
+ /** Use only the blue channel for processing in RGB images.*/
25
+ CCUT_RGB_B_CHANNEL_ONLY = 5
26
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * CrossVerificationStatus describes the status of the captured results.
3
+ * <p>
4
+ * Code Snippet:
5
+ * ```
6
+ * let router = CaptureVisionRouter.getInstance()
7
+ * let filter = new MultiFrameResultCrossFilter()
8
+ * filter.enableResultCrossVerification(EnumCapturedResultItemType.CRIT_DETECTED_QUAD, true)
9
+ * router.addFilter(filter)
10
+ *
11
+ * router.addResultReceiver({
12
+ * onDetectedQuadsReceived: result => {
13
+ * if(result.items && result.items.length > 0) {
14
+ * //Because result cross verification of DETECT_QUAD is enabled,
15
+ * //crossVerificationStatus of item will be CVS_PASSED or CVS_FAILED.
16
+ * let crossVerificationStatus = result.items[0].crossVerificationStatus
17
+ * }
18
+ * },
19
+ * })
20
+ * //...
21
+ * router.startCapturing(EnumPresetTemplate.PT_DETECT_DOCUMENT_BOUNDARIES)
22
+ * ```
23
+ *
24
+ * @remarks If {@link CaptureVisionRouter} doesn't add {@link MultiFrameResultCrossFilter} via {@link CaptureVisionRouter.addFilter}
25
+ * or added {@link MultiFrameResultCrossFilter} doesn't enable verification for the corresponding type,
26
+ * the crossVerificationStatus property of the item for that type will always remain {@link CVS_NOT_VERIFIED}.
27
+ * <p>
28
+ * Currently, only {@link DetectedQuadResultItem} and {@link NormalizedImageResultItem} have the crossVerificationStatus property.
29
+ *
30
+ * @see MultiFrameResultCrossFilter.enableResultCrossVerification
31
+ * @see DetectedQuadResultItem.crossVerificationStatus
32
+ * @see NormalizedImageResultItem.crossVerificationStatus
33
+ * */
34
+ export enum EnumCrossVerificationStatus {
35
+ /** The cross verification has not been performed yet. */
36
+ CVS_NOT_VERIFIED = 0,
37
+
38
+ /** The cross verification has been passed successfully. */
39
+ CVS_PASSED = 1,
40
+
41
+ /** The cross verification has failed. */
42
+ CVS_FAILED = 2
43
+ }