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.
Files changed (56) hide show
  1. package/android/build.gradle +1 -1
  2. package/android/src/main/cpp/JsiCore.cpp +19 -7
  3. package/android/src/main/cpp/JsiCvr.cpp +19 -14
  4. package/android/src/main/cpp/JsiDbr.cpp +62 -2
  5. package/android/src/main/dysJniLibs/debug/arm64-v8a/librn_dys.so +0 -0
  6. package/android/src/main/dysJniLibs/debug/armeabi-v7a/librn_dys.so +0 -0
  7. package/android/src/main/dysJniLibs/debug/x86/librn_dys.so +0 -0
  8. package/android/src/main/dysJniLibs/debug/x86_64/librn_dys.so +0 -0
  9. package/android/src/main/dysJniLibs/release/arm64-v8a/librn_dys.so +0 -0
  10. package/android/src/main/dysJniLibs/release/armeabi-v7a/librn_dys.so +0 -0
  11. package/android/src/main/dysJniLibs/release/x86/librn_dys.so +0 -0
  12. package/android/src/main/dysJniLibs/release/x86_64/librn_dys.so +0 -0
  13. package/android/src/main/dysJniLibsFor81/debug/arm64-v8a/librn_dys.so +0 -0
  14. package/android/src/main/dysJniLibsFor81/debug/armeabi-v7a/librn_dys.so +0 -0
  15. package/android/src/main/dysJniLibsFor81/debug/x86/librn_dys.so +0 -0
  16. package/android/src/main/dysJniLibsFor81/debug/x86_64/librn_dys.so +0 -0
  17. package/android/src/main/dysJniLibsFor81/release/arm64-v8a/librn_dys.so +0 -0
  18. package/android/src/main/dysJniLibsFor81/release/armeabi-v7a/librn_dys.so +0 -0
  19. package/android/src/main/dysJniLibsFor81/release/x86/librn_dys.so +0 -0
  20. package/android/src/main/dysJniLibsFor81/release/x86_64/librn_dys.so +0 -0
  21. package/android/src/main/dysJniLibsFor82/debug/arm64-v8a/librn_dys.so +0 -0
  22. package/android/src/main/dysJniLibsFor82/debug/armeabi-v7a/librn_dys.so +0 -0
  23. package/android/src/main/dysJniLibsFor82/debug/x86/librn_dys.so +0 -0
  24. package/android/src/main/dysJniLibsFor82/debug/x86_64/librn_dys.so +0 -0
  25. package/android/src/main/dysJniLibsFor82/release/arm64-v8a/librn_dys.so +0 -0
  26. package/android/src/main/dysJniLibsFor82/release/armeabi-v7a/librn_dys.so +0 -0
  27. package/android/src/main/dysJniLibsFor82/release/x86/librn_dys.so +0 -0
  28. package/android/src/main/dysJniLibsFor82/release/x86_64/librn_dys.so +0 -0
  29. package/android/src/main/java/com/dynamsoft/reactnativelib/MultiCrossFilterModule.kt +11 -0
  30. package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForDBR.kt +15 -0
  31. package/android/src/main/java/com/dynamsoft/reactnativelib/dce/CameraEnhancerModuleImpl.kt +4 -1
  32. package/android/src/main/java/com/dynamsoft/reactnativelib/utility/MultiCrossFilterModuleImpl.kt +28 -2
  33. package/dynamsoft-capture-vision-react-native.podspec +1 -1
  34. package/ios/CPP/ImageDataHostObject.cpp +1 -1
  35. package/ios/CPP/RNDynamsoft+JSI.mm +34 -1
  36. package/ios/CPP/RNDynamsoft+Json.m +25 -0
  37. package/ios/RNDynamsoftCaptureVisionRouter.mm +11 -5
  38. package/ios/RNDynamsoftImageEditorViewManager.mm +11 -5
  39. package/ios/RNDynamsoftImageManager.h +2 -1
  40. package/ios/RNDynamsoftImageManager.mm +11 -5
  41. package/ios/RNDynamsoftImageSourceAdapter.h +2 -1
  42. package/ios/RNDynamsoftImageSourceAdapter.mm +12 -6
  43. package/ios/RNDynamsoftMultiCrossFilter.m +39 -0
  44. package/package.json +1 -1
  45. package/src/core/ImageData.tsx +4 -1
  46. package/src/core/ImageSourceAdapter.tsx +6 -0
  47. package/src/cvr/CaptureVisionRouter.tsx +26 -10
  48. package/src/dbr/BarcodeResultItem.tsx +9 -0
  49. package/src/dbr/ECISegment.tsx +24 -0
  50. package/src/dbr/index.tsx +1 -0
  51. package/src/dce/EnumResolution.tsx +1 -0
  52. package/src/dce/ImageEditorView.tsx +3 -0
  53. package/src/utility/CrossVerificationCriteria.tsx +12 -0
  54. package/src/utility/ImageManager.tsx +39 -0
  55. package/src/utility/MultiFrameResultCrossFilter.tsx +23 -0
  56. package/src/utility/index.tsx +1 -0
@@ -334,6 +334,20 @@ void runOnMainThread(void (^block)(void))
334
334
 
335
335
  @end
336
336
 
337
+ @implementation DSECISegment (JSI)
338
+
339
+ - (nullable NSDictionary *)toJson {
340
+ if (!self) return nil;
341
+ return @{
342
+ @"eciValue" : @(self.eciValue),
343
+ @"charsetEncoding" : self.charsetEncoding,
344
+ @"startIndex" : @(self.startIndex),
345
+ @"length" : @(self.length)
346
+ };
347
+ }
348
+
349
+ @end
350
+
337
351
  @implementation DSCapturedResultItem (Json)
338
352
 
339
353
  - (nullable NSDictionary *)toJson {
@@ -352,6 +366,7 @@ void runOnMainThread(void (^block)(void))
352
366
  @"_formatNumberString": [NSNumber numberWithUnsignedInteger:item.format].stringValue,
353
367
  @"formatString":item.formatString,
354
368
  @"text":item.text,
369
+ @"bytes":[item.bytes base64EncodedStringWithOptions:0],
355
370
  @"location":[item.location toJson],
356
371
  @"confidence":@(item.confidence),
357
372
  @"angle":@(item.angle),
@@ -437,6 +452,16 @@ void runOnMainThread(void (^block)(void))
437
452
  mutableDictionary[@"pdf417Details"] = pdf417Dict;
438
453
  }
439
454
  }
455
+ NSArray<DSECISegment *> *eciSegments = item.eciSegments;
456
+ if (eciSegments && eciSegments.count > 0) {
457
+ NSMutableArray<NSDictionary *> *mutableArray = [NSMutableArray arrayWithCapacity:eciSegments.count];
458
+ for (DSECISegment *eci in eciSegments) {
459
+ [mutableArray addObject:[eci toJson]];
460
+ }
461
+ mutableDictionary[@"eciSegments"] = [mutableArray copy];
462
+ } else {
463
+ mutableDictionary[@"eciSegments"] = [NSNull null];
464
+ }
440
465
  dictionary = [mutableDictionary copy];
441
466
  }
442
467
  break;
@@ -359,17 +359,23 @@ RCT_EXPORT_METHOD(removeFilter:(NSString *)key) {
359
359
  // --- RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install) ---
360
360
  RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install)
361
361
  {
362
- RCTBridge* bridge = [RCTBridge currentBridge];
363
- RCTCxxBridge* cxxBridge = (RCTCxxBridge*)bridge;
364
- if (cxxBridge == nil) {
362
+ RCTBridge *bridge = self.bridge;
363
+
364
+ if ([bridge respondsToSelector:NSSelectorFromString(@"parentBridge")]) {
365
+ bridge = [bridge valueForKey:@"parentBridge"];
366
+ }
367
+
368
+ RCTCxxBridge *cxxBridge = (RCTCxxBridge *)bridge;
369
+ if (cxxBridge == nil || cxxBridge.runtime == nil) {
365
370
  return @false;
366
371
  }
372
+
367
373
  auto jsiRuntime = (jsi::Runtime*) cxxBridge.runtime;
368
374
  if (jsiRuntime == nil) {
369
375
  return @false;
370
376
  }
371
377
 
372
- install(*(facebook::jsi::Runtime *)jsiRuntime, self);
378
+ install(*(facebook::jsi::Runtime *)cxxBridge.runtime, self);
373
379
  return @true;
374
380
  }
375
381
 
@@ -377,7 +383,7 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install)
377
383
  static void installHostFunction(
378
384
  jsi::Runtime &jsiRuntime,
379
385
  const char* name,
380
- size_t argCount,
386
+ unsigned int argCount,
381
387
  HostFunctionType hostFunction) {
382
388
 
383
389
  auto func = Function::createFromHostFunction(
@@ -106,17 +106,23 @@ RCT_EXPORT_METHOD(getSelectedQuad:(nonnull NSNumber *)tag
106
106
  // --- RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install) ---
107
107
  RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install)
108
108
  {
109
- RCTBridge* bridge = [RCTBridge currentBridge];
110
- RCTCxxBridge* cxxBridge = (RCTCxxBridge*)bridge;
111
- if (cxxBridge == nil) {
109
+ RCTBridge *bridge = self.bridge;
110
+
111
+ if ([bridge respondsToSelector:NSSelectorFromString(@"parentBridge")]) {
112
+ bridge = [bridge valueForKey:@"parentBridge"];
113
+ }
114
+
115
+ RCTCxxBridge *cxxBridge = (RCTCxxBridge *)bridge;
116
+ if (cxxBridge == nil || cxxBridge.runtime == nil) {
112
117
  return @false;
113
118
  }
119
+
114
120
  auto jsiRuntime = (jsi::Runtime*) cxxBridge.runtime;
115
121
  if (jsiRuntime == nil) {
116
122
  return @false;
117
123
  }
118
124
 
119
- install(*(facebook::jsi::Runtime *)jsiRuntime, self);
125
+ install(*(facebook::jsi::Runtime *)cxxBridge.runtime, self);
120
126
  return @true;
121
127
  }
122
128
 
@@ -124,7 +130,7 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install)
124
130
  static void installHostFunction(
125
131
  jsi::Runtime &jsiRuntime,
126
132
  const char* name,
127
- size_t argCount,
133
+ unsigned int argCount,
128
134
  HostFunctionType hostFunction) {
129
135
 
130
136
  auto func = Function::createFromHostFunction(
@@ -3,10 +3,11 @@
3
3
  */
4
4
 
5
5
  #import <React/RCTBridgeModule.h>
6
+ #import <React/RCTEventEmitter.h>
6
7
 
7
8
  NS_ASSUME_NONNULL_BEGIN
8
9
 
9
- @interface RNDynamsoftImageManager : NSObject <RCTBridgeModule>
10
+ @interface RNDynamsoftImageManager : RCTEventEmitter <RCTBridgeModule>
10
11
 
11
12
  @end
12
13
 
@@ -44,17 +44,23 @@ RCT_EXPORT_MODULE(DynamsoftImageManagerModule)
44
44
  // --- RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install) ---
45
45
  RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install)
46
46
  {
47
- RCTBridge* bridge = [RCTBridge currentBridge];
48
- RCTCxxBridge* cxxBridge = (RCTCxxBridge*)bridge;
49
- if (cxxBridge == nil) {
47
+ RCTBridge *bridge = self.bridge;
48
+
49
+ if ([bridge respondsToSelector:NSSelectorFromString(@"parentBridge")]) {
50
+ bridge = [bridge valueForKey:@"parentBridge"];
51
+ }
52
+
53
+ RCTCxxBridge *cxxBridge = (RCTCxxBridge *)bridge;
54
+ if (cxxBridge == nil || cxxBridge.runtime == nil) {
50
55
  return @false;
51
56
  }
57
+
52
58
  auto jsiRuntime = (jsi::Runtime*) cxxBridge.runtime;
53
59
  if (jsiRuntime == nil) {
54
60
  return @false;
55
61
  }
56
62
 
57
- install(*(facebook::jsi::Runtime *)jsiRuntime, self);
63
+ install(*(facebook::jsi::Runtime *)cxxBridge.runtime, self);
58
64
  return @true;
59
65
  }
60
66
 
@@ -62,7 +68,7 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install)
62
68
  static void installHostFunction(
63
69
  jsi::Runtime &jsiRuntime,
64
70
  const char* name,
65
- size_t argCount,
71
+ unsigned int argCount,
66
72
  HostFunctionType hostFunction) {
67
73
 
68
74
  auto func = Function::createFromHostFunction(
@@ -4,12 +4,13 @@
4
4
 
5
5
  #import <Foundation/Foundation.h>
6
6
  #import <React/RCTBridgeModule.h>
7
+ #import <React/RCTEventEmitter.h>
7
8
 
8
9
  NS_ASSUME_NONNULL_BEGIN
9
10
 
10
11
  @class DSImageSourceAdapter;
11
12
 
12
- @interface RNDynamsoftImageSourceAdapter : NSObject <RCTBridgeModule>
13
+ @interface RNDynamsoftImageSourceAdapter : RCTEventEmitter <RCTBridgeModule>
13
14
 
14
15
  @property (nonatomic, strong) NSMutableDictionary<NSString *, DSImageSourceAdapter *> *isaDictionary;
15
16
 
@@ -134,17 +134,23 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(hasImage:(NSString *)key imageId:(NSInteg
134
134
  // --- RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install) ---
135
135
  RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install)
136
136
  {
137
- RCTBridge* bridge = [RCTBridge currentBridge];
138
- RCTCxxBridge* cxxBridge = (RCTCxxBridge*)bridge;
139
- if (cxxBridge == nil) {
137
+ RCTBridge *bridge = self.bridge;
138
+
139
+ if ([bridge respondsToSelector:NSSelectorFromString(@"parentBridge")]) {
140
+ bridge = [bridge valueForKey:@"parentBridge"];
141
+ }
142
+
143
+ RCTCxxBridge *cxxBridge = (RCTCxxBridge *)bridge;
144
+ if (cxxBridge == nil || cxxBridge.runtime == nil) {
140
145
  return @false;
141
146
  }
147
+
142
148
  auto jsiRuntime = (jsi::Runtime*) cxxBridge.runtime;
143
149
  if (jsiRuntime == nil) {
144
150
  return @false;
145
151
  }
146
152
 
147
- install(*(facebook::jsi::Runtime *)jsiRuntime, self);
153
+ install(*(facebook::jsi::Runtime *)cxxBridge.runtime, self);
148
154
  return @true;
149
155
  }
150
156
 
@@ -152,7 +158,7 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install)
152
158
  static void installHostFunction(
153
159
  jsi::Runtime &jsiRuntime,
154
160
  const char* name,
155
- size_t argCount,
161
+ unsigned int argCount,
156
162
  HostFunctionType hostFunction) {
157
163
 
158
164
  auto func = Function::createFromHostFunction(
@@ -235,7 +241,7 @@ static void install(jsi::Runtime &jsiRuntime, RNDynamsoftImageSourceAdapter *rnA
235
241
  if (!error && image) {
236
242
  // Compression quality set to 1.0 (highest quality)
237
243
  NSData *data = UIImageJPEGRepresentation(image, 1.0);
238
- NSString *base64String = [data base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
244
+ NSString *base64String = [data base64EncodedStringWithOptions:0];
239
245
 
240
246
  // convertNSStringToJSIString is assumed to be defined elsewhere
241
247
  return convertNSStringToJSIString(runtime, base64String);
@@ -6,6 +6,27 @@
6
6
  #import <DynamsoftCaptureVisionBundle/DynamsoftCaptureVisionBundle.h>
7
7
  #import "RNDynamsoftCaptureVisionRouter.h"
8
8
 
9
+ @implementation DSCrossVerificationCriteria (filter)
10
+
11
+ + (instancetype)createFromJson:(NSDictionary *)dic {
12
+ DSCrossVerificationCriteria *criteria = [[DSCrossVerificationCriteria alloc] init];
13
+ NSNumber *frameWindow = dic[@"frameWindow"];
14
+ NSNumber *minConsistentFrames = dic[@"minConsistentFrames"];
15
+ if (frameWindow) {
16
+ criteria.frameWindow = frameWindow.integerValue;
17
+ }
18
+ if (minConsistentFrames) {
19
+ criteria.minConsistentFrames = minConsistentFrames.integerValue;
20
+ }
21
+ return criteria;
22
+ }
23
+
24
+ - (NSDictionary *)toJson {
25
+ return @{ @"frameWindow" : @(self.frameWindow), @"minConsistentFrames" : @(self.minConsistentFrames) };
26
+ }
27
+
28
+ @end
29
+
9
30
  @implementation RNDynamsoftMultiCrossFilter
10
31
 
11
32
  RCT_EXPORT_MODULE(DynamsoftMultiCrossFilterModule)
@@ -103,4 +124,22 @@ RCT_EXPORT_METHOD(getMaxOverlappingFrames:(NSString *)key
103
124
  resolve(@([filter getMaxOverlappingFrames:type]));
104
125
  }
105
126
 
127
+ RCT_EXPORT_METHOD(setResultCrossVerificationCriteria:(NSString *)key type:(NSInteger)type criteria:(NSDictionary *)criteria) {
128
+ RNDynamsoftCaptureVisionRouter *router = [self.bridge moduleForClass:[RNDynamsoftCaptureVisionRouter class]];
129
+ DSMultiFrameResultCrossFilter *filter = [router.filterDictionary objectForKey:key];
130
+ DSCrossVerificationCriteria *c = [DSCrossVerificationCriteria createFromJson:criteria];
131
+ [filter setResultCrossVerificationCriteria:c resultItemTypes:type];
132
+ }
133
+
134
+ RCT_EXPORT_METHOD(getResultCrossVerificationCriteria:(NSString *)key
135
+ type:(NSInteger)type
136
+ resolver:(RCTPromiseResolveBlock)resolve
137
+ rejecter:(RCTPromiseRejectBlock)reject)
138
+ {
139
+ RNDynamsoftCaptureVisionRouter *router = [self.bridge moduleForClass:[RNDynamsoftCaptureVisionRouter class]];
140
+ DSMultiFrameResultCrossFilter *filter = [router.filterDictionary objectForKey:key];
141
+ DSCrossVerificationCriteria *criteria = [filter getResultCrossVerificationCriteria:type];
142
+ resolve([criteria toJson]);
143
+ }
144
+
106
145
  @end
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dynamsoft-capture-vision-react-native",
3
3
  "title": "Dynamsoft Capture Vision React Native",
4
- "version": "3.2.5001",
4
+ "version": "3.4.1000-beta.1",
5
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",
@@ -78,7 +78,10 @@ const installMethods = () => {
78
78
  * @returns {string} - The Base64-encoded string representation of the image data.
79
79
  * @see {@link IntermediateResultManager.getOriginalImage}
80
80
  */
81
- export function imageDataToBase64(imageData: ImageData): string {
81
+ export function imageDataToBase64(imageData: ImageData): string | undefined | null {
82
82
  installMethods();
83
+ if (typeof global.imageDataToBase64 !== 'function') {
84
+ return null;
85
+ }
83
86
  return global.imageDataToBase64(imageData);
84
87
  }
@@ -65,6 +65,9 @@ export abstract class ImageSourceAdapter {
65
65
  * */
66
66
  public addImageToBuffer(imageData: ImageData): void {
67
67
  installMethods()
68
+ if (typeof global.isaAddImageToBuffer !== 'function') {
69
+ return;
70
+ }
68
71
  global.isaAddImageToBuffer(this.isaId, imageData)
69
72
  }
70
73
 
@@ -75,6 +78,9 @@ export abstract class ImageSourceAdapter {
75
78
  * */
76
79
  public getImageData(): ImageData | null | undefined {
77
80
  installMethods()
81
+ if (typeof global.isaGetImageData !== 'function') {
82
+ return null;
83
+ }
78
84
  return global.isaGetImageData(this.isaId)
79
85
  }
80
86
 
@@ -187,16 +187,20 @@ export class CaptureVisionRouter {
187
187
  let processingDocumentResult = result.processingDocumentResult;
188
188
  if (processingDocumentResult && processingDocumentResult.deskewedImageResultItems && processingDocumentResult.deskewedImageResultItems.length > 0) {
189
189
  installMethods();
190
- let imageArr: ImageData[] = global.getCurrentDeskewedImages();
191
- for (let i = 0; i < processingDocumentResult.deskewedImageResultItems.length; i++) {
192
- processingDocumentResult.deskewedImageResultItems[i]!!.imageData = imageArr[i]!!;
190
+ let imageArr: ImageData[] | undefined | null = global.getCurrentDeskewedImages();
191
+ if (imageArr) {
192
+ for (let i = 0; i < processingDocumentResult.deskewedImageResultItems.length; i++) {
193
+ processingDocumentResult.deskewedImageResultItems[i]!!.imageData = imageArr[i]!!;
194
+ }
193
195
  }
194
196
  }
195
197
  if (processingDocumentResult && processingDocumentResult.enhancedImageResultItems && processingDocumentResult.enhancedImageResultItems.length > 0) {
196
198
  installMethods();
197
- let imageArr: ImageData[] = global.getCurrentEnhancedImages();
198
- for (let i = 0; i < processingDocumentResult.enhancedImageResultItems.length; i++) {
199
- processingDocumentResult.enhancedImageResultItems[i]!!.imageData = imageArr[i]!!;
199
+ let imageArr: ImageData[] | undefined | null = global.getCurrentEnhancedImages();
200
+ if (imageArr) {
201
+ for (let i = 0; i < processingDocumentResult.enhancedImageResultItems.length; i++) {
202
+ processingDocumentResult.enhancedImageResultItems[i]!!.imageData = imageArr[i]!!;
203
+ }
200
204
  }
201
205
  }
202
206
  for (let _receiver of this.receiverMap.values()) {
@@ -532,6 +536,9 @@ export class CaptureVisionRouter {
532
536
  capture(imageData: ImageData, template: string = ""): CapturedResult | undefined | null {
533
537
  installMethods();
534
538
  if (imageData) {
539
+ if (typeof global.captureImageData !== 'function') {
540
+ return null;
541
+ }
535
542
  let result = global.captureImageData(imageData, template);
536
543
  _populateResults(result)
537
544
  return result;
@@ -569,6 +576,9 @@ export class CaptureVisionRouter {
569
576
  captureFile(filePath: string, template: string = ""): CapturedResult | undefined | null {
570
577
  installMethods();
571
578
  if (filePath) {
579
+ if (typeof global.captureFile !== 'function') {
580
+ return null;
581
+ }
572
582
  let result = global.captureFile(filePath, template);
573
583
  _populateResults(result)
574
584
  return result;
@@ -595,6 +605,9 @@ export class CaptureVisionRouter {
595
605
  captureFileBytes(fileBytes: ArrayBuffer, template: string = ""): CapturedResult | undefined | null {
596
606
  installMethods();
597
607
  if (fileBytes) {
608
+ if (typeof global.captureFileBytes !== 'function') {
609
+ return null;
610
+ }
598
611
  let result = global.captureFileBytes(fileBytes, template);
599
612
  _populateResults(result)
600
613
  return result;
@@ -642,8 +655,11 @@ export class IntermediateResultManager {
642
655
  * @see {@link CaptureVisionRouter.addResultReceiver}
643
656
  * @see {@link CapturedResultReceiver}
644
657
  * */
645
- getOriginalImage(imageHashId: string): ImageData {
658
+ getOriginalImage(imageHashId: string): ImageData | undefined | null {
646
659
  installMethods();
660
+ if (typeof global.cvr_getOriginalImage !== 'function') {
661
+ return null;
662
+ }
647
663
  return global.cvr_getOriginalImage(imageHashId);
648
664
  }
649
665
  }
@@ -652,7 +668,7 @@ declare var global: {
652
668
  captureImageData: (imageData: ImageData, template: string) => CapturedResult | undefined | null;
653
669
  captureFile: (file: string, template: string) => CapturedResult | undefined | null;
654
670
  captureFileBytes: (fileBytes: ArrayBuffer, template: string) => CapturedResult | undefined | null;
655
- getCurrentDeskewedImages: () => ImageData[];
656
- getCurrentEnhancedImages: () => ImageData[];
657
- cvr_getOriginalImage: (imageHashId: string) => ImageData;
671
+ getCurrentDeskewedImages: () => ImageData[] | undefined | null;
672
+ getCurrentEnhancedImages: () => ImageData[] | undefined | null;
673
+ cvr_getOriginalImage: (imageHashId: string) => ImageData | undefined | null;
658
674
  }
@@ -1,6 +1,7 @@
1
1
  import type {CapturedResultItem, Quadrilateral, EnumCapturedResultItemType} from "../core";
2
2
  import type {EnumBarcodeFormat} from "./EnumBarcodeFormat";
3
3
  import type {AztecDetails, DataMatrixDetails, OneDCodeDetails, PDF417Details, QRCodeDetails} from "./BarcodeDetails";
4
+ import type { ECISegment } from "./ECISegment";
4
5
 
5
6
  /**
6
7
  * Interface BarcodeResultItem extends {@link CapturedResultItem}, represents a barcode result item decoded by barcode reader engine.
@@ -22,6 +23,11 @@ export interface BarcodeResultItem extends CapturedResultItem{
22
23
 
23
24
  /**The textual data decoded from the barcode. It represents the content of the barcode.*/
24
25
  text: string;
26
+
27
+ /**
28
+ * base64-encoded string representing the raw byte data of the barcode. It is a way to encode binary data as a string, making it easier to transmit or store.
29
+ */
30
+ bytes: string;
25
31
  /**
26
32
  * The location of the barcode in the form of a {@link Quadrilateral} (a set of coordinates defining the four corners of the detected barcode).
27
33
  * It describes where the barcode was found within an image.
@@ -53,4 +59,7 @@ export interface BarcodeResultItem extends CapturedResultItem{
53
59
  pdf417Details?: PDF417Details;
54
60
 
55
61
  aztecDetails?: AztecDetails;
62
+
63
+ /**Extended Channel Interpretation (ECI) segments within the barcode. It provides information about the character encoding used for different parts of the barcode data.*/
64
+ eciSegments?: ECISegment[];
56
65
  }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Represents the Extended Channel Interpretation (ECI) information within a barcode.
3
+ *
4
+ * Each ECI segment specifies the character encoding used for a portion of the decoded bytes.
5
+ * The charset names follow the IANA character set registry (e.g. "UTF-8", "ISO-8859-1").
6
+ */
7
+ export interface ECISegment {
8
+ /**
9
+ * ECI assignment number as defined by ISO/IEC 15424.
10
+ */
11
+ eciValue: number;
12
+ /**
13
+ * Charset encoding name defined by IANA (e.g. "UTF-8", "ISO-8859-1").
14
+ */
15
+ charsetEncoding: string;
16
+ /**
17
+ * Start index of this ECI segment in the decoded barcode bytes.
18
+ */
19
+ startIndex: number;
20
+ /**
21
+ * Length (in bytes) of this segment within the decoded barcode bytes.
22
+ */
23
+ length: number;
24
+ }
package/src/dbr/index.tsx CHANGED
@@ -7,3 +7,4 @@ export * from "./EnumLocalizationMode"
7
7
  export * from "./BarcodeDetails"
8
8
  export * from "./EnumQRCodeErrorCorrectionLevel"
9
9
  export type {SimplifiedBarcodeReaderSettings} from "./SimplifiedBarcodeReaderSettings"
10
+ export * from "./ECISegment"
@@ -4,4 +4,5 @@ export enum EnumResolution {
4
4
  RESOLUTION_720P = 2,
5
5
  Resolution1080P = 3,
6
6
  RESOLUTION_4K = 4,
7
+ RESOLUTION_MAX = 5,
7
8
  }
@@ -66,6 +66,9 @@ export class ImageEditorView extends Component<ImageEditorViewNativeProps, any>
66
66
  */
67
67
  public setOriginalImage(imageData: ImageData) {
68
68
  installMethods();
69
+ if (typeof global.editorView_setOriginalImage !== 'function') {
70
+ return;
71
+ }
69
72
  if (this.nativeCameraViewHandle != null) {
70
73
  global.editorView_setOriginalImage(this.nativeCameraViewHandle!, imageData);
71
74
  }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Interface CrossVerificationCriteria represents the criteria for cross-verification in a barcode scanning process.
3
+ * It includes parameters such as frameWindow, which defines the number of frames to consider for verification,
4
+ * and minConsistentFrames, which specifies the minimum number of consistent frames required for a successful verification.
5
+ */
6
+ export interface CrossVerificationCriteria {
7
+ /**The number of frames to consider for cross-verification. It defines the window of frames that will be analyzed to determine if the barcode detection is consistent across multiple frames. A larger frame window may provide more reliable verification but may also increase the time required for processing. */
8
+ frameWindow: number;
9
+
10
+ /**The minimum number of consistent frames required for a successful cross-verification. This parameter specifies how many frames within the defined frame window must consistently detect the same barcode for it to be considered a valid detection. A higher value may reduce false positives but may also require more frames to confirm a detection. */
11
+ minConsistentFrames: number;
12
+ }
@@ -93,6 +93,9 @@ export class ImageIO {
93
93
  * */
94
94
  readFromFile(path: string | null | undefined): ImageData | null | undefined {
95
95
  installMethods();
96
+ if (typeof global.imageIO_readFromFile !== 'function') {
97
+ return null;
98
+ }
96
99
  if (path && path.length > 0) {
97
100
  return global.imageIO_readFromFile(path);
98
101
  }
@@ -109,6 +112,9 @@ export class ImageIO {
109
112
  * */
110
113
  saveToFile(imageData: ImageData | null | undefined, path: string | null | undefined, overWrite: boolean): void {
111
114
  installMethods();
115
+ if (typeof global.imageIO_saveToFile !== 'function') {
116
+ return;
117
+ }
112
118
  if (imageData && path) {
113
119
  if (path.length > 0) {
114
120
  global.imageIO_saveToFile(imageData, path, overWrite);
@@ -125,6 +131,9 @@ export class ImageIO {
125
131
  * */
126
132
  readFromMemory(data: ArrayBuffer | null | undefined): ImageData | null | undefined {
127
133
  installMethods();
134
+ if (typeof global.imageIO_readFromMemory !== 'function') {
135
+ return null;
136
+ }
128
137
  if (data) {
129
138
  return global.imageIO_readFromMemory(data);
130
139
  }
@@ -140,6 +149,9 @@ export class ImageIO {
140
149
  * */
141
150
  saveToMemory(imageData: ImageData | null | undefined, format: EnumImageFileFormat): ArrayBuffer | null | undefined {
142
151
  installMethods();
152
+ if (typeof global.imageIO_saveToMemory !== 'function') {
153
+ return null;
154
+ }
143
155
  if (imageData) {
144
156
  return global.imageIO_saveToMemory(imageData, format);
145
157
  }
@@ -161,6 +173,9 @@ export class ImageDrawer {
161
173
  * */
162
174
  drawOnImage(imageData: ImageData | null | undefined, quads: Quadrilateral[] | null | undefined, colour: number | ColorValue, thickness: number): ImageData | null | undefined {
163
175
  installMethods();
176
+ if (typeof global.imageDrawer_drawOnImage !== 'function') {
177
+ return imageData;
178
+ }
164
179
  if (imageData && quads) {
165
180
  const colorNumber = processColor(colour) as number;
166
181
  if (colorNumber) {
@@ -191,6 +206,9 @@ export class ImageProcessor {
191
206
  }
192
207
  // convert to boolean
193
208
  rect.measuredInPercentage = !!rect.measuredInPercentage;
209
+ if (typeof global.imageProcessor_cropImage !== 'function') {
210
+ return imageData;
211
+ }
194
212
  return global.imageProcessor_cropImage(imageData, rect);
195
213
  }
196
214
 
@@ -210,6 +228,9 @@ export class ImageProcessor {
210
228
  if (!quad || !imageData) {
211
229
  return imageData;
212
230
  }
231
+ if (typeof global.imageProcessor_cropAndDeskewImage !== 'function') {
232
+ return imageData;
233
+ }
213
234
  return global.imageProcessor_cropAndDeskewImage(imageData, quad, dstWidth, dstHeight, padding);
214
235
  }
215
236
 
@@ -226,6 +247,9 @@ export class ImageProcessor {
226
247
  if(!imageData || brightness < -100 || brightness > 100) {
227
248
  return imageData;
228
249
  }
250
+ if (typeof global.imageProcessor_adjustBrightness !== 'function') {
251
+ return imageData;
252
+ }
229
253
  return global.imageProcessor_adjustBrightness(imageData, brightness);
230
254
  }
231
255
 
@@ -242,6 +266,9 @@ export class ImageProcessor {
242
266
  if(!imageData || contrast < -100 || contrast > 100) {
243
267
  return imageData;
244
268
  }
269
+ if (typeof global.imageProcessor_adjustContrast !== 'function') {
270
+ return imageData;
271
+ }
245
272
  return global.imageProcessor_adjustContrast(imageData, contrast);
246
273
  }
247
274
 
@@ -250,6 +277,9 @@ export class ImageProcessor {
250
277
  if(!imageData) {
251
278
  return imageData;
252
279
  }
280
+ if (typeof global.imageProcessor_filterImage !== 'function') {
281
+ return imageData;
282
+ }
253
283
  return global.imageProcessor_filterImage(imageData, filterType);
254
284
  }
255
285
 
@@ -268,6 +298,9 @@ export class ImageProcessor {
268
298
  if(!imageData || r < 0 || r > 1 || g < 0 || g > 1 || b < 0 || b > 1) {
269
299
  return imageData;
270
300
  }
301
+ if (typeof global.imageProcessor_convertToGray !== 'function') {
302
+ return imageData;
303
+ }
271
304
  return global.imageProcessor_convertToGray(imageData, r, g, b);
272
305
  }
273
306
 
@@ -285,6 +318,9 @@ export class ImageProcessor {
285
318
  if(!imageData || threshold < -1 || threshold > 255) {
286
319
  return imageData;
287
320
  }
321
+ if (typeof global.imageProcessor_convertToBinaryGlobal !== 'function') {
322
+ return imageData;
323
+ }
288
324
  return global.imageProcessor_convertToBinaryGlobal(imageData, threshold, invert);
289
325
  }
290
326
 
@@ -304,6 +340,9 @@ export class ImageProcessor {
304
340
  if(!imageData) {
305
341
  return imageData;
306
342
  }
343
+ if (typeof global.imageProcessor_convertToBinaryLocal !== 'function') {
344
+ return imageData;
345
+ }
307
346
  return global.imageProcessor_convertToBinaryLocal(imageData, blockSize, compensation, invert);
308
347
  }
309
348
  }
@@ -1,6 +1,7 @@
1
1
  import {NativeModules} from 'react-native';
2
2
  import type {CapturedResultFilter, CaptureVisionRouter} from '../cvr'
3
3
  import {EnumCapturedResultItemType} from '../core'
4
+ import type { CrossVerificationCriteria } from './CrossVerificationCriteria';
4
5
 
5
6
  // @ts-ignore Check whether __turboModuleProxy exists, it may not
6
7
  const isTurboModuleEnabled = global.__turboModuleProxy != null;
@@ -157,4 +158,26 @@ export class MultiFrameResultCrossFilter implements CapturedResultFilter {
157
158
  getMaxOverlappingFrames(type: EnumCapturedResultItemType | number): Promise<number> {
158
159
  return DynamsoftMultiCrossFilterModule.getMaxOverlappingFrames(this.filterId, type);
159
160
  }
161
+
162
+ /**
163
+ * Set the criteria for cross-verification of one or multiple specific result item types.
164
+ *
165
+ * @param types Specifies one or multiple specific result item types.
166
+ * @param criteria The criteria for cross-verification, including parameters such as frameWindow and minConsistentFrames.
167
+ * @see {@link CrossVerificationCriteria}
168
+ * */
169
+ setResultCrossVerificationCriteria(types: EnumCapturedResultItemType | number, criteria: CrossVerificationCriteria) {
170
+ DynamsoftMultiCrossFilterModule.setResultCrossVerificationCriteria(this.filterId, types, criteria);
171
+ }
172
+
173
+ /**
174
+ * Get the criteria for cross-verification of a given result item type.
175
+ *
176
+ * @param type Specifies a result item type.
177
+ * @return {Promise<CrossVerificationCriteria>} A promise that resolves the criteria for cross-verification, including parameters such as frameWindow and minConsistentFrames.
178
+ * @see {@link CrossVerificationCriteria}
179
+ * */
180
+ getResultCrossVerificationCriteria(type: EnumCapturedResultItemType | number): Promise<CrossVerificationCriteria> {
181
+ return DynamsoftMultiCrossFilterModule.getResultCrossVerificationCriteria(this.filterId, type);
182
+ }
160
183
  }
@@ -2,3 +2,4 @@ export * from "./UtilityModule"
2
2
  export * from "./MultiFrameResultCrossFilter"
3
3
  export * from "./ImageManager"
4
4
  export * from "./EnumFilterType"
5
+ export * from "./CrossVerificationCriteria"