dynamsoft-capture-vision-react-native 3.0.5201 → 3.2.3000

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 (93) hide show
  1. package/README.md +5 -2
  2. package/android/build.gradle +4 -6
  3. package/android/gradle.properties +3 -3
  4. package/android/src/main/cpp/JsiCore.cpp +1 -1
  5. package/android/src/main/cpp/JsiDbr.cpp +208 -23
  6. package/android/src/main/cpp/JsiDcp.cpp +1 -1
  7. package/android/src/main/cpp/JsiDlr.cpp +10 -1
  8. package/android/src/main/cpp/JsiUtility.cpp +470 -62
  9. package/android/src/main/cpp/JsiUtility.h +13 -3
  10. package/android/src/main/dysJniLibs/debug/arm64-v8a/librn_dys.so +0 -0
  11. package/android/src/main/dysJniLibs/debug/armeabi-v7a/librn_dys.so +0 -0
  12. package/android/src/main/dysJniLibs/debug/x86/librn_dys.so +0 -0
  13. package/android/src/main/dysJniLibs/debug/x86_64/librn_dys.so +0 -0
  14. package/android/src/main/dysJniLibs/release/arm64-v8a/librn_dys.so +0 -0
  15. package/android/src/main/dysJniLibs/release/armeabi-v7a/librn_dys.so +0 -0
  16. package/android/src/main/dysJniLibs/release/x86/librn_dys.so +0 -0
  17. package/android/src/main/dysJniLibs/release/x86_64/librn_dys.so +0 -0
  18. package/android/src/main/dysJniLibsFor81/debug/arm64-v8a/librn_dys.so +0 -0
  19. package/android/src/main/dysJniLibsFor81/debug/armeabi-v7a/librn_dys.so +0 -0
  20. package/android/src/main/dysJniLibsFor81/debug/x86/librn_dys.so +0 -0
  21. package/android/src/main/dysJniLibsFor81/debug/x86_64/librn_dys.so +0 -0
  22. package/android/src/main/dysJniLibsFor81/release/arm64-v8a/librn_dys.so +0 -0
  23. package/android/src/main/dysJniLibsFor81/release/armeabi-v7a/librn_dys.so +0 -0
  24. package/android/src/main/dysJniLibsFor81/release/x86/librn_dys.so +0 -0
  25. package/android/src/main/dysJniLibsFor81/release/x86_64/librn_dys.so +0 -0
  26. package/android/src/main/dysJniLibsFor82/debug/arm64-v8a/librn_dys.so +0 -0
  27. package/android/src/main/dysJniLibsFor82/debug/armeabi-v7a/librn_dys.so +0 -0
  28. package/android/src/main/dysJniLibsFor82/debug/x86/librn_dys.so +0 -0
  29. package/android/src/main/dysJniLibsFor82/debug/x86_64/librn_dys.so +0 -0
  30. package/android/src/main/dysJniLibsFor82/release/arm64-v8a/librn_dys.so +0 -0
  31. package/android/src/main/dysJniLibsFor82/release/armeabi-v7a/librn_dys.so +0 -0
  32. package/android/src/main/dysJniLibsFor82/release/x86/librn_dys.so +0 -0
  33. package/android/src/main/dysJniLibsFor82/release/x86_64/librn_dys.so +0 -0
  34. package/android/src/main/java/com/dynamsoft/reactnativelib/CVRModule.kt +17 -2
  35. package/android/src/main/java/com/dynamsoft/reactnativelib/CameraViewManager.kt +13 -1
  36. package/android/src/main/java/com/dynamsoft/reactnativelib/ImageEditorViewManager.kt +1 -1
  37. package/android/src/main/java/com/dynamsoft/reactnativelib/{utils → basicutils}/Basic.kt +1 -1
  38. package/android/src/main/java/com/dynamsoft/reactnativelib/{utils → basicutils}/ForCore.kt +1 -2
  39. package/android/src/main/java/com/dynamsoft/reactnativelib/{utils → basicutils}/ForCvr.kt +1 -5
  40. package/android/src/main/java/com/dynamsoft/reactnativelib/{utils → basicutils}/ForDBR.kt +74 -3
  41. package/android/src/main/java/com/dynamsoft/reactnativelib/{utils → basicutils}/ForDCE.kt +33 -13
  42. package/android/src/main/java/com/dynamsoft/reactnativelib/{utils → basicutils}/ForDCP.kt +1 -1
  43. package/android/src/main/java/com/dynamsoft/reactnativelib/{utils → basicutils}/ForDDN.kt +1 -3
  44. package/android/src/main/java/com/dynamsoft/reactnativelib/{utils → basicutils}/ForDLR.kt +6 -3
  45. package/android/src/main/java/com/dynamsoft/reactnativelib/{utils → basicutils}/ImageUtil.kt +2 -2
  46. package/android/src/main/java/com/dynamsoft/reactnativelib/cvr/CaptureVisionRouterModuleImpl.kt +25 -5
  47. package/android/src/main/java/com/dynamsoft/reactnativelib/dce/CameraEnhancerModuleImpl.kt +6 -3
  48. package/android/src/main/java/com/dynamsoft/reactnativelib/dce/CameraViewManagerImpl.kt +15 -3
  49. package/android/src/main/java/com/dynamsoft/reactnativelib/dce/ImageEditorViewManagerImpl.kt +1 -5
  50. package/android/src/main/java/com/dynamsoft/reactnativelib/dce/ImageEditorViewModuleImpl.kt +2 -4
  51. package/android/src/main/java/com/dynamsoft/reactnativelib/dce/RNCameraView.kt +1 -2
  52. package/android/src/main/java/com/dynamsoft/reactnativelib/utility/ImageManagerModuleImpl.kt +75 -3
  53. package/android/src/main/java/com/dynamsoft/reactnativelib/utility/MultiCrossFilterModuleImpl.kt +2 -2
  54. package/dynamsoft-capture-vision-react-native.podspec +1 -1
  55. package/ios/CPP/ImageDataHostObject.cpp +1 -1
  56. package/ios/CPP/ImageDataHostObject.hpp +1 -1
  57. package/ios/CPP/RNDynamsoft+JSI.h +3 -0
  58. package/ios/CPP/RNDynamsoft+JSI.mm +119 -2
  59. package/ios/CPP/RNDynamsoft+Json.m +114 -14
  60. package/ios/CPP/YeetJSIUtils.h +2 -0
  61. package/ios/CPP/YeetJSIUtils.mm +15 -0
  62. package/ios/RNDynamsoftCameraView.h +4 -0
  63. package/ios/RNDynamsoftCameraView.m +25 -0
  64. package/ios/RNDynamsoftCameraViewManager.m +8 -2
  65. package/ios/RNDynamsoftCaptureVisionRouter.mm +149 -92
  66. package/ios/RNDynamsoftImageEditorViewManager.mm +71 -40
  67. package/ios/RNDynamsoftImageManager.mm +295 -81
  68. package/ios/RNDynamsoftImageSourceAdapter.mm +100 -65
  69. package/package.json +1 -1
  70. package/src/core/EnumGrayscaleEnhancementMode.tsx +1 -0
  71. package/src/core/EnumGrayscaleTransformationMode.tsx +1 -0
  72. package/src/core/EnumImageFileFormat.tsx +6 -0
  73. package/src/core/index.tsx +1 -0
  74. package/src/cvr/CaptureVisionRouter.tsx +33 -5
  75. package/src/dbr/BarcodeDetails.tsx +51 -0
  76. package/src/dbr/BarcodeResultItem.tsx +11 -0
  77. package/src/dbr/EnumBarcodeFormat.tsx +2 -0
  78. package/src/dbr/EnumDeblurMode.tsx +1 -0
  79. package/src/dbr/EnumLocalizationMode.tsx +1 -0
  80. package/src/dbr/EnumQRCodeErrorCorrectionLevel.tsx +6 -0
  81. package/src/dbr/index.tsx +2 -0
  82. package/src/dce/CameraEnhancer.tsx +14 -6
  83. package/src/dce/CameraView.tsx +10 -2
  84. package/src/dce/DynamsoftCameraViewNativeComponent.ts +25 -0
  85. package/src/dce/EnumCameraPosition.tsx +13 -1
  86. package/src/dce/EnumEnhancedFeatures.tsx +3 -4
  87. package/src/dce/ImageEditorView.tsx +1 -1
  88. package/src/dlr/CharacterResult.tsx +4 -1
  89. package/src/dlr/SimplifiedLabelRecognizerSettings.tsx +2 -0
  90. package/src/dlr/TextLineResultItem.tsx +5 -0
  91. package/src/utility/EnumFilterType.tsx +5 -0
  92. package/src/utility/ImageManager.tsx +227 -9
  93. package/src/utility/index.tsx +1 -0
@@ -1,5 +1,6 @@
1
1
  import {type ColorValue, NativeModules, processColor} from "react-native";
2
- import type {ImageData, Quadrilateral} from "../core";
2
+ import type {ImageData, Quadrilateral, EnumImageFileFormat, DSRect} from "../core";
3
+ import type {EnumFilterType} from "./EnumFilterType";
3
4
 
4
5
  // @ts-ignore Check whether __turboModuleProxy exists, it may not
5
6
  const isTurboModuleEnabled = global.__turboModuleProxy != null;
@@ -9,11 +10,20 @@ const DynamsoftImageManagerModule = isTurboModuleEnabled ?
9
10
  NativeModules.DynamsoftImageManagerModule;
10
11
 
11
12
  declare global {
12
- function imageManager_saveToFile(imageData: ImageData, path: string, overWrite: boolean): void;
13
+ function imageIO_saveToFile(imageData: ImageData, path: string, overWrite: boolean): void;
14
+ function imageIO_readFromFile(path: string): ImageData;
15
+ function imageIO_readFromMemory(data: ArrayBuffer): ImageData;
16
+ function imageIO_saveToMemory(imageData: ImageData, format: number): ArrayBuffer;
17
+ function imageDrawer_drawOnImage(imageData: ImageData, quads: Quadrilateral[], colour: number, thickness: number): ImageData;
18
+ function imageProcessor_cropImage(imageData: ImageData, rect: DSRect): ImageData | undefined;
19
+ function imageProcessor_cropAndDeskewImage(imageData: ImageData, quad: Quadrilateral, dstWidth: number, dstHeight: number, padding: number): ImageData | undefined;
20
+ function imageProcessor_adjustBrightness(imageData: ImageData, brightness: number) : ImageData | undefined;
21
+ function imageProcessor_adjustContrast(imageData: ImageData, contrast: number) : ImageData | undefined;
22
+ function imageProcessor_filterImage(imageData: ImageData, filterType: number) : ImageData | undefined;
23
+ function imageProcessor_convertToGray(imageData: ImageData, r: number, g: number, b: number) : ImageData | undefined;
24
+ function imageProcessor_convertToBinaryGlobal(imageData: ImageData, threshold: number, invert: boolean) : ImageData | undefined;
25
+ function imageProcessor_convertToBinaryLocal(imageData: ImageData, blockSize: number, compensation: number, invert: boolean): ImageData | undefined;
13
26
 
14
- function imageManager_drawOnImage(imageData: ImageData, quads: Quadrilateral[], colour: number, thickness: number): ImageData;
15
-
16
- function imageManager_cropImage(imageData: ImageData, quads: Quadrilateral): ImageData | undefined;
17
27
  }
18
28
 
19
29
  let isInstalled = false
@@ -27,8 +37,68 @@ const installMethods = () => {
27
37
  /**
28
38
  * The ImageManager class is a utility class for managing and manipulating images.
29
39
  * It provides functionality for saving images to files and drawing various shapes on images.
40
+ * @deprecated use {@link ImageIO}, {@link ImageDrawer}, {@link ImageProcessor} instead
30
41
  * */
31
42
  export class ImageManager {
43
+ /**
44
+ * Saves an image to the specified path and format.
45
+ * The desired file format is inferred from the file extension provided in the path parameter.
46
+ *
47
+ * @param imageData - The image to be saved, of type {@link ImageData}.
48
+ * @param path - The absolute file path, name and extension name, as a string, under which the image will be saved.
49
+ * @param overWrite - A flag indicating whether to overwrite the file if it already exists. Defaults to true.
50
+ * @deprecated use {@link ImageIO.saveToFile} instead
51
+ * */
52
+ saveToFile(imageData: ImageData | null | undefined, path: string | null | undefined, overWrite: boolean): void {
53
+ new ImageIO().saveToFile(imageData, path, overWrite);
54
+ }
55
+
56
+ /**
57
+ * Add quadrilaterals on the image.
58
+ *
59
+ * @param imageData - The {@link ImageData} to modify.
60
+ * @param quads - An array of {@link Quadrilateral} objects to be added on the image.
61
+ * @param colour - An ColorValue as an ARGB colour.
62
+ * @param thickness - The width of the border.
63
+ *
64
+ * @return {ImageData|null|undefined} - The modified ImageData.
65
+ * @deprecated use {@link ImageDrawer.drawOnImage} instead
66
+ * */
67
+ drawOnImage(imageData: ImageData | null | undefined, quads: Quadrilateral[] | null | undefined, colour: number | ColorValue, thickness: number): ImageData | null | undefined {
68
+ return new ImageDrawer().drawOnImage(imageData, quads, colour, thickness);
69
+ }
70
+
71
+
72
+ /**
73
+ * Crops an image using a quadrilateral.
74
+ * @param {ImageData} imageData - The image data to crop.
75
+ * @param {Quadrilateral} quad - The quadrilateral to use for cropping.
76
+ *
77
+ * @returns {ImageData|null|undefined} - The cropped image data.
78
+ * @deprecated use {@link ImageProcessor.cropAndDeskewImage} instead
79
+ * */
80
+ cropImage(imageData: ImageData | null | undefined, quad: Quadrilateral | null | undefined): ImageData | undefined | null {
81
+ return new ImageProcessor().cropAndDeskewImage(imageData, quad);
82
+ }
83
+ }
84
+
85
+ export class ImageIO {
86
+
87
+ /**
88
+ * Reads an image from the specified path.
89
+ *
90
+ * @param path - The absolute file path, name and extension name, as a string, of the image to be read.
91
+ *
92
+ * @return {ImageData|null|undefined} - The image data, of type {@link ImageData}, or null if the image cannot be read.
93
+ * */
94
+ readFromFile(path: string | null | undefined): ImageData | null | undefined {
95
+ installMethods();
96
+ if (path && path.length > 0) {
97
+ return global.imageIO_readFromFile(path);
98
+ }
99
+ return null;
100
+ }
101
+
32
102
  /**
33
103
  * Saves an image to the specified path and format.
34
104
  * The desired file format is inferred from the file extension provided in the path parameter.
@@ -41,11 +111,44 @@ export class ImageManager {
41
111
  installMethods();
42
112
  if (imageData && path) {
43
113
  if (path.length > 0) {
44
- global.imageManager_saveToFile(imageData, path, overWrite);
114
+ global.imageIO_saveToFile(imageData, path, overWrite);
45
115
  }
46
116
  }
47
117
  }
48
118
 
119
+ /**
120
+ * Reads an image from ArrayBuffer memory.
121
+ *
122
+ * @param data - The image data, of type ArrayBuffer.
123
+ *
124
+ * @return {ImageData|null|undefined} - The image data, of type {@link ImageData}, or null if the image cannot be read.
125
+ * */
126
+ readFromMemory(data: ArrayBuffer | null | undefined): ImageData | null | undefined {
127
+ installMethods();
128
+ if (data) {
129
+ return global.imageIO_readFromMemory(data);
130
+ }
131
+ return null;
132
+ }
133
+
134
+ /**
135
+ * Saves an image to the specified path and format.
136
+ * The desired file format is inferred from the file extension provided in the path parameter.
137
+ *
138
+ * @param imageData - The image to be saved, of type {@link ImageData}.
139
+ * @param format - The format of the image data, of type {@link EnumImageFileFormat}.
140
+ * */
141
+ saveToMemory(imageData: ImageData | null | undefined, format: EnumImageFileFormat): ArrayBuffer | null | undefined {
142
+ installMethods();
143
+ if (imageData) {
144
+ return global.imageIO_saveToMemory(imageData, format);
145
+ }
146
+ return null;
147
+ }
148
+
149
+ }
150
+
151
+ export class ImageDrawer {
49
152
  /**
50
153
  * Add quadrilaterals on the image.
51
154
  *
@@ -65,27 +168,142 @@ export class ImageManager {
65
168
  if (quads.length == 0 || thickness <= 0 || alpha == 0) {
66
169
  return imageData;
67
170
  }
68
- return global.imageManager_drawOnImage(imageData, quads, colorNumber, thickness);
171
+ return global.imageDrawer_drawOnImage(imageData, quads, colorNumber, thickness);
69
172
  }
70
173
  }
71
174
  return imageData;
72
175
  }
176
+ }
177
+
178
+ export class ImageProcessor {
179
+
180
+ /**
181
+ * Crops an image using a rectangle.
182
+ * @param {ImageData} imageData - The image data to crop.
183
+ * @param {DSRect} rect - The rectangle to use for cropping.
184
+ *
185
+ * @returns {ImageData|null|undefined} - The cropped image data.
186
+ * */
187
+ cropImage(imageData: ImageData | null | undefined, rect: DSRect | null | undefined): ImageData | null | undefined {
188
+ installMethods()
189
+ if (!rect || !imageData) {
190
+ return imageData;
191
+ }
192
+ // convert to boolean
193
+ rect.measuredInPercentage = !!rect.measuredInPercentage;
194
+ return global.imageProcessor_cropImage(imageData, rect);
195
+ }
73
196
 
74
197
 
75
198
  /**
76
199
  * Crops an image using a quadrilateral.
77
200
  * @param {ImageData} imageData - The image data to crop.
78
201
  * @param {Quadrilateral} quad - The quadrilateral to use for cropping.
202
+ * @param {number} dstWidth - The width of the cropped image.
203
+ * @param {number} dstHeight - The height of the cropped image.
204
+ * @param {number} padding - The padding size.
79
205
  *
80
206
  * @returns {ImageData|null|undefined} - The cropped image data.
81
207
  * */
82
- cropImage(imageData: ImageData | null | undefined, quad: Quadrilateral | null | undefined): ImageData | undefined | null {
208
+ cropAndDeskewImage(imageData: ImageData | null | undefined, quad: Quadrilateral | null | undefined, dstWidth: number = 0, dstHeight: number = 0, padding: number = 0): ImageData | undefined | null {
83
209
  installMethods();
84
210
  if (!quad || !imageData) {
85
211
  return imageData;
86
212
  }
87
- return global.imageManager_cropImage(imageData, quad);
213
+ return global.imageProcessor_cropAndDeskewImage(imageData, quad, dstWidth, dstHeight, padding);
214
+ }
215
+
216
+ /**
217
+ * Adjusts the brightness of an image.
218
+ *
219
+ * @param imageData - The image data to adjust the brightness of.
220
+ * @param brightness - The brightness adjustment value. Must be between -100 and 100.
221
+ *
222
+ * @return {ImageData|null|undefined} - The adjusted image data.
223
+ * */
224
+ adjustBrightness(imageData: ImageData | null | undefined, brightness: number): ImageData | null | undefined {
225
+ installMethods();
226
+ if(!imageData || brightness < -100 || brightness > 100) {
227
+ return imageData;
228
+ }
229
+ return global.imageProcessor_adjustBrightness(imageData, brightness);
88
230
  }
89
231
 
232
+ /**
233
+ * Adjusts the contrast of an image.
234
+ *
235
+ * @param imageData - The image data to adjust the contrast of.
236
+ * @param contrast - The contrast adjustment value. Must be between -100 and 100.
237
+ *
238
+ * @return {ImageData|null|undefined} - The adjusted image data.
239
+ * */
240
+ adjustContrast(imageData: ImageData | null | undefined, contrast: number): ImageData | null | undefined {
241
+ installMethods();
242
+ if(!imageData || contrast < -100 || contrast > 100) {
243
+ return imageData;
244
+ }
245
+ return global.imageProcessor_adjustContrast(imageData, contrast);
246
+ }
90
247
 
248
+ filterImage(imageData: ImageData | null | undefined, filterType: EnumFilterType): ImageData | null | undefined {
249
+ installMethods();
250
+ if(!imageData) {
251
+ return imageData;
252
+ }
253
+ return global.imageProcessor_filterImage(imageData, filterType);
254
+ }
255
+
256
+ /**
257
+ * Converts an image to grayscale.
258
+ *
259
+ * @param imageData - The image data to convert to grayscale.
260
+ * @param r - The weight of the red channel. Must be between 0 and 1.
261
+ * @param g - The weight of the green channel. Must be between 0 and 1.
262
+ * @param b - The weight of the blue channel. Must be between 0 and 1.
263
+ *
264
+ * @return {ImageData|null|undefined} - The grayscale image data.
265
+ * */
266
+ convertToGray(imageData: ImageData | null | undefined, r: number = 0.3, g: number = 0.59, b: number = 0.11): ImageData | null | undefined {
267
+ installMethods();
268
+ if(!imageData || r < 0 || r > 1 || g < 0 || g > 1 || b < 0 || b > 1) {
269
+ return imageData;
270
+ }
271
+ return global.imageProcessor_convertToGray(imageData, r, g, b);
272
+ }
273
+
274
+ /**
275
+ * Converts an image to binary using a global threshold.
276
+ *
277
+ * @param imageData - The image data to convert to binary.
278
+ * @param threshold - The threshold value. Must be between -1 and 255.(default is -1, automatic calculate the threshold).
279
+ * @param invert - If true, invert the binary image (black becomes white and white becomes black).
280
+ *
281
+ * @return {ImageData|null|undefined} - The binary image data.
282
+ * */
283
+ convertToBinaryGlobal(imageData: ImageData | null | undefined, threshold: number = -1, invert: boolean = false) {
284
+ installMethods();
285
+ if(!imageData || threshold < -1 || threshold > 255) {
286
+ return imageData;
287
+ }
288
+ return global.imageProcessor_convertToBinaryGlobal(imageData, threshold, invert);
289
+ }
290
+
291
+
292
+ /**
293
+ * Converts an image to binary using a local threshold.
294
+ *
295
+ * @param imageData - The image data to convert to binary.
296
+ * @param blockSize - Size of the block for local binarization(default is 0).
297
+ * @param compensation - Adjustment value to modify the threshold (default is 0).
298
+ * @param invert - If true, invert the binary image (black becomes white and white becomes black).
299
+ *
300
+ * @return {ImageData|null|undefined} - The binary image data.
301
+ * */
302
+ convertToBinaryLocal(imageData: ImageData | null | undefined, blockSize: number = 0, compensation: number = 0, invert: boolean = false) {
303
+ installMethods();
304
+ if(!imageData) {
305
+ return imageData;
306
+ }
307
+ return global.imageProcessor_convertToBinaryLocal(imageData, blockSize, compensation, invert);
308
+ }
91
309
  }
@@ -1,3 +1,4 @@
1
1
  export * from "./UtilityModule"
2
2
  export * from "./MultiFrameResultCrossFilter"
3
3
  export * from "./ImageManager"
4
+ export * from "./EnumFilterType"