dynamsoft-capture-vision-react-native 3.4.1300 → 3.4.3010
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +4 -4
- package/README.md +62 -62
- package/android/README.md +14 -14
- package/android/build.gradle +167 -163
- package/android/gradle.properties +20 -20
- package/android/settings.gradle +5 -5
- package/android/src/main/AndroidManifest.xml +6 -6
- package/android/src/main/AndroidManifest_noPackage.xml +5 -5
- package/android/src/main/cpp/CMakeLists.txt +21 -21
- package/android/src/main/cpp/ImgHO.cpp +94 -94
- package/android/src/main/cpp/ImgHO.h +34 -34
- package/android/src/main/cpp/JsiCore.cpp +296 -296
- package/android/src/main/cpp/JsiCore.h +51 -51
- package/android/src/main/cpp/JsiCvr.cpp +332 -332
- package/android/src/main/cpp/JsiCvr.h +54 -54
- package/android/src/main/cpp/JsiDbr.cpp +283 -283
- package/android/src/main/cpp/JsiDbr.h +26 -26
- package/android/src/main/cpp/JsiDce.cpp +59 -59
- package/android/src/main/cpp/JsiDce.h +17 -17
- package/android/src/main/cpp/JsiDcp.cpp +51 -51
- package/android/src/main/cpp/JsiDcp.h +31 -31
- package/android/src/main/cpp/JsiDdn.cpp +50 -50
- package/android/src/main/cpp/JsiDdn.h +28 -28
- package/android/src/main/cpp/JsiDlr.cpp +60 -60
- package/android/src/main/cpp/JsiDlr.h +26 -26
- package/android/src/main/cpp/JsiUtility.cpp +604 -604
- package/android/src/main/cpp/JsiUtility.h +26 -26
- package/android/src/main/cpp/RawBuffer.cpp +23 -23
- package/android/src/main/cpp/RawBuffer.h +24 -24
- package/android/src/main/cpp/android_log.h +14 -14
- package/android/src/main/dysJniLibsFor86/debug/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor86/debug/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor86/debug/x86/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor86/debug/x86_64/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor86/release/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor86/release/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor86/release/x86/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor86/release/x86_64/librn_dys.so +0 -0
- package/android/src/main/java/com/dynamsoft/reactnativelib/CVRModule.kt +137 -137
- package/android/src/main/java/com/dynamsoft/reactnativelib/CameraViewManager.kt +62 -62
- package/android/src/main/java/com/dynamsoft/reactnativelib/DCEModule.kt +125 -125
- package/android/src/main/java/com/dynamsoft/reactnativelib/DynamsoftBaseModule.kt +8 -8
- package/android/src/main/java/com/dynamsoft/reactnativelib/ISAModule.kt +73 -73
- package/android/src/main/java/com/dynamsoft/reactnativelib/ImageEditorViewManager.kt +14 -14
- package/android/src/main/java/com/dynamsoft/reactnativelib/ImageEditorViewModule.kt +35 -35
- package/android/src/main/java/com/dynamsoft/reactnativelib/ImageManagerModule.kt +15 -15
- package/android/src/main/java/com/dynamsoft/reactnativelib/LicenseModule.kt +29 -29
- package/android/src/main/java/com/dynamsoft/reactnativelib/MultiCrossFilterModule.kt +83 -83
- package/android/src/main/java/com/dynamsoft/reactnativelib/ReactNativeDcvPackage.kt +32 -32
- package/android/src/main/java/com/dynamsoft/reactnativelib/VersionsModule.kt +41 -41
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/Basic.kt +44 -44
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForCore.kt +50 -50
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForCvr.kt +129 -129
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForDBR.kt +157 -157
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForDCE.kt +110 -110
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForDCP.kt +49 -49
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForDDN.kt +85 -85
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForDLR.kt +72 -72
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ImageUtil.kt +58 -58
- package/android/src/main/java/com/dynamsoft/reactnativelib/core/ImageSourceAdapterModuleImpl.kt +120 -120
- package/android/src/main/java/com/dynamsoft/reactnativelib/cvr/CaptureVisionRouterModuleImpl.kt +306 -306
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/CameraEnhancerModuleImpl.kt +247 -247
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/CameraLifeCycleOwner.java +14 -14
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/CameraViewManagerImpl.kt +77 -77
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/ImageEditorViewManagerImpl.kt +15 -15
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/ImageEditorViewModuleImpl.kt +110 -110
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/RNCameraView.kt +20 -20
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/RNImageEditorView.kt +19 -19
- package/android/src/main/java/com/dynamsoft/reactnativelib/license/LicenseModuleImpl.kt +39 -39
- package/android/src/main/java/com/dynamsoft/reactnativelib/utility/ImageManagerModuleImpl.kt +120 -120
- package/android/src/main/java/com/dynamsoft/reactnativelib/utility/MultiCrossFilterModuleImpl.kt +111 -111
- package/app.plugin.js +21 -21
- package/dynamsoft-capture-vision-react-native.podspec +24 -24
- package/ios/CPP/DSImageData+HostObject.h +18 -18
- package/ios/CPP/DSImageData+HostObject.mm +38 -38
- package/ios/CPP/ImageDataHostObject.cpp +87 -87
- package/ios/CPP/ImageDataHostObject.hpp +35 -35
- package/ios/CPP/MutableRawBuffer.cpp +23 -23
- package/ios/CPP/MutableRawBuffer.hpp +23 -23
- package/ios/CPP/RNDynamsoft+JSI.h +22 -22
- package/ios/CPP/RNDynamsoft+JSI.mm +303 -303
- package/ios/CPP/RNDynamsoft+Json.h +93 -93
- package/ios/CPP/RNDynamsoft+Json.m +733 -733
- package/ios/CPP/YeetJSIUtils.h +56 -56
- package/ios/CPP/YeetJSIUtils.mm +208 -208
- package/ios/RNDynamsoftCameraView.h +31 -31
- package/ios/RNDynamsoftCameraView.m +108 -108
- package/ios/RNDynamsoftCameraViewManager.h +14 -14
- package/ios/RNDynamsoftCameraViewManager.m +195 -195
- package/ios/RNDynamsoftCaptureVisionRouter.h +18 -18
- package/ios/RNDynamsoftCaptureVisionRouter.mm +532 -532
- package/ios/RNDynamsoftImageEditorView.h +17 -17
- package/ios/RNDynamsoftImageEditorView.m +25 -25
- package/ios/RNDynamsoftImageEditorViewManager.h +14 -14
- package/ios/RNDynamsoftImageEditorViewManager.mm +183 -183
- package/ios/RNDynamsoftImageManager.h +14 -14
- package/ios/RNDynamsoftImageManager.mm +369 -369
- package/ios/RNDynamsoftImageSourceAdapter.h +19 -19
- package/ios/RNDynamsoftImageSourceAdapter.mm +255 -255
- package/ios/RNDynamsoftLicense.h +14 -14
- package/ios/RNDynamsoftLicense.m +62 -62
- package/ios/RNDynamsoftMultiCrossFilter.h +14 -14
- package/ios/RNDynamsoftMultiCrossFilter.m +145 -145
- package/ios/RNDynamsoftVersions.h +13 -13
- package/ios/RNDynamsoftVersions.m +27 -27
- package/package.json +48 -48
- package/src/NativeDynamsoftVersionsModule.tsx +20 -20
- package/src/VersionsModule.tsx +7 -7
- package/src/core/CapturedResultBase.tsx +18 -18
- package/src/core/CapturedResultItem.tsx +23 -23
- package/src/core/CoreModule.tsx +9 -9
- package/src/core/DSRect.tsx +29 -29
- package/src/core/EnumCaptureResultItemType.tsx +52 -52
- package/src/core/EnumColourChannelUsageType.tsx +26 -26
- package/src/core/EnumCrossVerificationStatus.tsx +46 -46
- package/src/core/EnumGrayscaleEnhancementMode.tsx +46 -46
- package/src/core/EnumGrayscaleTransformationMode.tsx +35 -35
- package/src/core/EnumImageFileFormat.tsx +6 -6
- package/src/core/EnumPixelFormat.tsx +53 -53
- package/src/core/ImageData.tsx +87 -87
- package/src/core/ImageSourceAdapter.tsx +160 -160
- package/src/core/NativeDynamsoftImageSourceAdapterModule.tsx +29 -29
- package/src/core/Point.tsx +13 -13
- package/src/core/Quadrilateral.tsx +12 -12
- package/src/core/index.tsx +18 -18
- package/src/cvr/CaptureVisionRouter.tsx +683 -683
- package/src/cvr/CaptureVisionRouterModule.tsx +9 -9
- package/src/cvr/CapturedResult.tsx +123 -123
- package/src/cvr/CapturedResultFilter.tsx +13 -13
- package/src/cvr/CapturedResultReceiver.tsx +71 -71
- package/src/cvr/EnumPresetTemplate.tsx +81 -81
- package/src/cvr/NativeDynamsoftCaptureVisionRouterModule.tsx +25 -25
- package/src/cvr/SimplifiedCaptureVisionSettings.tsx +61 -61
- package/src/cvr/index.tsx +11 -11
- package/src/dbr/BarcodeDetails.tsx +51 -51
- package/src/dbr/BarcodeReaderModule.tsx +9 -9
- package/src/dbr/BarcodeResultItem.tsx +65 -65
- package/src/dbr/DecodedBarcodesResult.tsx +14 -14
- package/src/dbr/ECISegment.tsx +23 -23
- package/src/dbr/EnumBarcodeFormat.tsx +112 -112
- package/src/dbr/EnumDeblurMode.tsx +29 -29
- package/src/dbr/EnumLocalizationMode.tsx +27 -27
- package/src/dbr/EnumQRCodeErrorCorrectionLevel.tsx +6 -6
- package/src/dbr/SimplifiedBarcodeReaderSettings.tsx +80 -80
- package/src/dbr/index.tsx +9 -9
- package/src/dce/CameraEnhancer.tsx +254 -254
- package/src/dce/CameraEnhancerModule.tsx +9 -9
- package/src/dce/CameraView.tsx +100 -100
- package/src/dce/DynamsoftCameraViewNativeComponent.ts +96 -96
- package/src/dce/DynamsoftImageEditorViewNativeComponent.ts +9 -9
- package/src/dce/EnumCameraPosition.tsx +25 -25
- package/src/dce/EnumDrawingLayerId.tsx +17 -17
- package/src/dce/EnumEnhancedFeatures.tsx +24 -24
- package/src/dce/EnumFocusMode.tsx +6 -6
- package/src/dce/EnumResolution.tsx +8 -8
- package/src/dce/EnumTorchState.tsx +10 -10
- package/src/dce/FeedBack.tsx +28 -28
- package/src/dce/ImageEditorView.tsx +131 -131
- package/src/dce/NativeDynamsoftCameraViewModule.tsx +47 -47
- package/src/dce/NativeDynamsoftImageEditorViewModule.ts +9 -9
- package/src/dce/index.tsx +13 -13
- package/src/dcp/CodeParserDedicatorModule.tsx +9 -9
- package/src/dcp/CodeParserModule.tsx +9 -9
- package/src/dcp/EnumMappingStatus.tsx +14 -14
- package/src/dcp/EnumValidationStatus.tsx +14 -14
- package/src/dcp/ParsedResult.tsx +14 -14
- package/src/dcp/ParsedResultItem.tsx +50 -50
- package/src/dcp/index.tsx +8 -8
- package/src/ddn/DeskewedImageResultItem.tsx +40 -40
- package/src/ddn/DetectedQuadResultItem.tsx +31 -31
- package/src/ddn/DocumentNormalizerModule.tsx +9 -9
- package/src/ddn/EnhancedImageResultItem.tsx +20 -20
- package/src/ddn/EnumImageColourMode.tsx +14 -14
- package/src/ddn/ProcessedDocumentResult.tsx +27 -27
- package/src/ddn/SimplifiedDocumentNormalizerSettings.tsx +65 -65
- package/src/ddn/index.tsx +11 -11
- package/src/dip/ImageProcessingModule.tsx +9 -9
- package/src/dip/index.tsx +1 -1
- package/src/dlr/CharacterResult.tsx +28 -28
- package/src/dlr/LabelRecognizerModule.tsx +9 -9
- package/src/dlr/RecognizedTextLinesResult.tsx +19 -19
- package/src/dlr/SimplifiedLabelRecognizerSettings.tsx +33 -33
- package/src/dlr/TextLineResultItem.tsx +41 -41
- package/src/dlr/index.tsx +8 -8
- package/src/index.tsx +13 -13
- package/src/license/LicenseManager.tsx +49 -49
- package/src/license/LicenseModule.tsx +9 -9
- package/src/license/NativeDynamsoftLicenseModule.tsx +7 -7
- package/src/license/index.tsx +7 -7
- package/src/utility/CrossVerificationCriteria.tsx +11 -11
- package/src/utility/EnumFilterType.tsx +5 -5
- package/src/utility/ImageManager.tsx +348 -348
- package/src/utility/MultiFrameResultCrossFilter.tsx +183 -183
- package/src/utility/NativeDynamsoftImageManagerModule.tsx +7 -7
- package/src/utility/NativeDynamsoftMultiCrossFilterModule.tsx +18 -18
- package/src/utility/UtilityModule.tsx +9 -9
- package/src/utility/index.tsx +4 -4
- package/android/.gitignore +0 -4
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Defines the range of pixel formats that an image can have, specifying how color and transparency data are represented in each pixel of the image.
|
|
3
|
-
* @see {@link ImageData.format}
|
|
4
|
-
* */
|
|
5
|
-
export enum EnumPixelFormat {
|
|
6
|
-
/** 0:Black, 1:White. */
|
|
7
|
-
IPF_BINARY = 0,
|
|
8
|
-
|
|
9
|
-
/** 0:White, 1:Black. */
|
|
10
|
-
IPF_BINARYINVERTED = 1,
|
|
11
|
-
|
|
12
|
-
/** 8bit gray. */
|
|
13
|
-
IPF_GRAYSCALED = 2,
|
|
14
|
-
|
|
15
|
-
/** NV21 */
|
|
16
|
-
IPF_NV21 = 3,
|
|
17
|
-
|
|
18
|
-
/** 16bit with RGB channel order stored in memory from high to low address. */
|
|
19
|
-
IPF_RGB_565 = 4,
|
|
20
|
-
|
|
21
|
-
/** 16bit with RGB channel order stored in memory from high to low address. */
|
|
22
|
-
IPF_RGB_555 = 5,
|
|
23
|
-
|
|
24
|
-
/** 24bit with RGB channel order stored in memory from high to low address. */
|
|
25
|
-
IPF_RGB_888 = 6,
|
|
26
|
-
|
|
27
|
-
/** 32bit with ARGB channel order stored in memory from high to low address. */
|
|
28
|
-
IPF_ARGB_8888 = 7,
|
|
29
|
-
|
|
30
|
-
/** 48bit with RGB channel order stored in memory from high to low address. */
|
|
31
|
-
IPF_RGB_161616 = 8,
|
|
32
|
-
|
|
33
|
-
/** 64bit with ARGB channel order stored in memory from high to low address. */
|
|
34
|
-
IPF_ARGB_16161616 = 9,
|
|
35
|
-
|
|
36
|
-
/** 32bit with ABGR channel order stored in memory from high to low address. */
|
|
37
|
-
IPF_ABGR_8888 = 10,
|
|
38
|
-
|
|
39
|
-
/** 64bit with ABGR channel order stored in memory from high to low address. */
|
|
40
|
-
IPF_ABGR_16161616 = 11,
|
|
41
|
-
|
|
42
|
-
/** 24bit with BGR channel order stored in memory from high to low address. */
|
|
43
|
-
IPF_BGR_888 = 12,
|
|
44
|
-
|
|
45
|
-
/** 0:Black, 255:White. */
|
|
46
|
-
IPF_BINARY_8 = 13,
|
|
47
|
-
|
|
48
|
-
/** NV12. */
|
|
49
|
-
IPF_NV12 = 14,
|
|
50
|
-
|
|
51
|
-
/** 0:white, 255:black. */
|
|
52
|
-
IPF_BINARY_8_INVERTED = 15,
|
|
53
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Defines the range of pixel formats that an image can have, specifying how color and transparency data are represented in each pixel of the image.
|
|
3
|
+
* @see {@link ImageData.format}
|
|
4
|
+
* */
|
|
5
|
+
export enum EnumPixelFormat {
|
|
6
|
+
/** 0:Black, 1:White. */
|
|
7
|
+
IPF_BINARY = 0,
|
|
8
|
+
|
|
9
|
+
/** 0:White, 1:Black. */
|
|
10
|
+
IPF_BINARYINVERTED = 1,
|
|
11
|
+
|
|
12
|
+
/** 8bit gray. */
|
|
13
|
+
IPF_GRAYSCALED = 2,
|
|
14
|
+
|
|
15
|
+
/** NV21 */
|
|
16
|
+
IPF_NV21 = 3,
|
|
17
|
+
|
|
18
|
+
/** 16bit with RGB channel order stored in memory from high to low address. */
|
|
19
|
+
IPF_RGB_565 = 4,
|
|
20
|
+
|
|
21
|
+
/** 16bit with RGB channel order stored in memory from high to low address. */
|
|
22
|
+
IPF_RGB_555 = 5,
|
|
23
|
+
|
|
24
|
+
/** 24bit with RGB channel order stored in memory from high to low address. */
|
|
25
|
+
IPF_RGB_888 = 6,
|
|
26
|
+
|
|
27
|
+
/** 32bit with ARGB channel order stored in memory from high to low address. */
|
|
28
|
+
IPF_ARGB_8888 = 7,
|
|
29
|
+
|
|
30
|
+
/** 48bit with RGB channel order stored in memory from high to low address. */
|
|
31
|
+
IPF_RGB_161616 = 8,
|
|
32
|
+
|
|
33
|
+
/** 64bit with ARGB channel order stored in memory from high to low address. */
|
|
34
|
+
IPF_ARGB_16161616 = 9,
|
|
35
|
+
|
|
36
|
+
/** 32bit with ABGR channel order stored in memory from high to low address. */
|
|
37
|
+
IPF_ABGR_8888 = 10,
|
|
38
|
+
|
|
39
|
+
/** 64bit with ABGR channel order stored in memory from high to low address. */
|
|
40
|
+
IPF_ABGR_16161616 = 11,
|
|
41
|
+
|
|
42
|
+
/** 24bit with BGR channel order stored in memory from high to low address. */
|
|
43
|
+
IPF_BGR_888 = 12,
|
|
44
|
+
|
|
45
|
+
/** 0:Black, 255:White. */
|
|
46
|
+
IPF_BINARY_8 = 13,
|
|
47
|
+
|
|
48
|
+
/** NV12. */
|
|
49
|
+
IPF_NV12 = 14,
|
|
50
|
+
|
|
51
|
+
/** 0:white, 255:black. */
|
|
52
|
+
IPF_BINARY_8_INVERTED = 15,
|
|
53
|
+
}
|
package/src/core/ImageData.tsx
CHANGED
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
import {EnumPixelFormat} from "./EnumPixelFormat";
|
|
2
|
-
import {NativeModules} from "react-native";
|
|
3
|
-
import {ImageEditorView} from "../dce";
|
|
4
|
-
import {ImageManager} from "../utility";
|
|
5
|
-
import {IntermediateResultManager} from "../cvr";
|
|
6
|
-
|
|
7
|
-
declare global {
|
|
8
|
-
function imageDataToBase64(imageData: ImageData): string; //Installed in ImageSourceAdapterModule
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* The ImageData interface represents image data, which contains the image bytes, width, height, stride, pixel format, orientation and a tag.
|
|
13
|
-
* <p>
|
|
14
|
-
* `Please release the imageData object when it is no longer needed. see` {@link ImageData.release}.
|
|
15
|
-
*
|
|
16
|
-
* If you want to display imagedata on react UI Element, you can use {@link imageDataToBase64}
|
|
17
|
-
* @see {@link imageDataToBase64}
|
|
18
|
-
* @see {@link ImageEditorView.setOriginalImage}
|
|
19
|
-
* @see {@link ImageManager.saveToFile}
|
|
20
|
-
* */
|
|
21
|
-
export interface ImageData {
|
|
22
|
-
/**
|
|
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
|
-
* */
|
|
25
|
-
buffer: ArrayBuffer;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* The width of the image in pixels.
|
|
29
|
-
* */
|
|
30
|
-
width: number;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* The height of the image in pixels.
|
|
34
|
-
* */
|
|
35
|
-
height: number;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* The stride (or row width) of the image in bytes.
|
|
39
|
-
* */
|
|
40
|
-
stride: number;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* The pixel format of the image, of type {@link EnumPixelFormat}
|
|
44
|
-
* */
|
|
45
|
-
format: EnumPixelFormat | number;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* The orientation information of the image.
|
|
49
|
-
* */
|
|
50
|
-
orientation: number;
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Release the native memory. Data cannot be used after release.
|
|
54
|
-
* */
|
|
55
|
-
release(): void;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// @ts-ignore Check whether __turboModuleProxy exists, it may not
|
|
59
|
-
const isTurboModuleEnabled = global.__turboModuleProxy != null;
|
|
60
|
-
|
|
61
|
-
const ISAModule = isTurboModuleEnabled ?
|
|
62
|
-
require("./NativeDynamsoftImageSourceAdapterModule").default :
|
|
63
|
-
NativeModules.DynamsoftImageSourceAdapterModule
|
|
64
|
-
|
|
65
|
-
let isInstalled = false
|
|
66
|
-
const installMethods = () => {
|
|
67
|
-
if (!isInstalled) {
|
|
68
|
-
ISAModule.install()
|
|
69
|
-
isInstalled = true
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Converts an ImageData object to a Base64-encoded string.
|
|
76
|
-
*
|
|
77
|
-
* @param {ImageData} imageData - The ImageData object to convert.
|
|
78
|
-
* @returns {string} - The Base64-encoded string representation of the image data.
|
|
79
|
-
* @see {@link IntermediateResultManager.getOriginalImage}
|
|
80
|
-
*/
|
|
81
|
-
export function imageDataToBase64(imageData: ImageData): string | undefined | null {
|
|
82
|
-
installMethods();
|
|
83
|
-
if (typeof global.imageDataToBase64 !== 'function') {
|
|
84
|
-
return null;
|
|
85
|
-
}
|
|
86
|
-
return global.imageDataToBase64(imageData);
|
|
87
|
-
}
|
|
1
|
+
import {EnumPixelFormat} from "./EnumPixelFormat";
|
|
2
|
+
import {NativeModules} from "react-native";
|
|
3
|
+
import {ImageEditorView} from "../dce";
|
|
4
|
+
import {ImageManager} from "../utility";
|
|
5
|
+
import {IntermediateResultManager} from "../cvr";
|
|
6
|
+
|
|
7
|
+
declare global {
|
|
8
|
+
function imageDataToBase64(imageData: ImageData): string; //Installed in ImageSourceAdapterModule
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The ImageData interface represents image data, which contains the image bytes, width, height, stride, pixel format, orientation and a tag.
|
|
13
|
+
* <p>
|
|
14
|
+
* `Please release the imageData object when it is no longer needed. see` {@link ImageData.release}.
|
|
15
|
+
*
|
|
16
|
+
* If you want to display imagedata on react UI Element, you can use {@link imageDataToBase64}
|
|
17
|
+
* @see {@link imageDataToBase64}
|
|
18
|
+
* @see {@link ImageEditorView.setOriginalImage}
|
|
19
|
+
* @see {@link ImageManager.saveToFile}
|
|
20
|
+
* */
|
|
21
|
+
export interface ImageData {
|
|
22
|
+
/**
|
|
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
|
+
* */
|
|
25
|
+
buffer: ArrayBuffer;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The width of the image in pixels.
|
|
29
|
+
* */
|
|
30
|
+
width: number;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The height of the image in pixels.
|
|
34
|
+
* */
|
|
35
|
+
height: number;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The stride (or row width) of the image in bytes.
|
|
39
|
+
* */
|
|
40
|
+
stride: number;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The pixel format of the image, of type {@link EnumPixelFormat}
|
|
44
|
+
* */
|
|
45
|
+
format: EnumPixelFormat | number;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The orientation information of the image.
|
|
49
|
+
* */
|
|
50
|
+
orientation: number;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Release the native memory. Data cannot be used after release.
|
|
54
|
+
* */
|
|
55
|
+
release(): void;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// @ts-ignore Check whether __turboModuleProxy exists, it may not
|
|
59
|
+
const isTurboModuleEnabled = global.__turboModuleProxy != null;
|
|
60
|
+
|
|
61
|
+
const ISAModule = isTurboModuleEnabled ?
|
|
62
|
+
require("./NativeDynamsoftImageSourceAdapterModule").default :
|
|
63
|
+
NativeModules.DynamsoftImageSourceAdapterModule
|
|
64
|
+
|
|
65
|
+
let isInstalled = false
|
|
66
|
+
const installMethods = () => {
|
|
67
|
+
if (!isInstalled) {
|
|
68
|
+
ISAModule.install()
|
|
69
|
+
isInstalled = true
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Converts an ImageData object to a Base64-encoded string.
|
|
76
|
+
*
|
|
77
|
+
* @param {ImageData} imageData - The ImageData object to convert.
|
|
78
|
+
* @returns {string} - The Base64-encoded string representation of the image data.
|
|
79
|
+
* @see {@link IntermediateResultManager.getOriginalImage}
|
|
80
|
+
*/
|
|
81
|
+
export function imageDataToBase64(imageData: ImageData): string | undefined | null {
|
|
82
|
+
installMethods();
|
|
83
|
+
if (typeof global.imageDataToBase64 !== 'function') {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
return global.imageDataToBase64(imageData);
|
|
87
|
+
}
|
|
@@ -1,160 +1,160 @@
|
|
|
1
|
-
import type {ImageData} from "./ImageData";
|
|
2
|
-
import {NativeModules} from "react-native";
|
|
3
|
-
import type {EnumColourChannelUsageType} from "./EnumColourChannelUsageType";
|
|
4
|
-
import {CameraEnhancer} from "../dce";
|
|
5
|
-
import {CaptureVisionRouter} from "../cvr";
|
|
6
|
-
|
|
7
|
-
// @ts-ignore Check whether __turboModuleProxy exists, it may not
|
|
8
|
-
const isTurboModuleEnabled = global.__turboModuleProxy != null;
|
|
9
|
-
|
|
10
|
-
const ISAModule = isTurboModuleEnabled ?
|
|
11
|
-
require("./NativeDynamsoftImageSourceAdapterModule").default :
|
|
12
|
-
NativeModules.DynamsoftImageSourceAdapterModule
|
|
13
|
-
|
|
14
|
-
let isInstalled = false
|
|
15
|
-
const installMethods = () => {
|
|
16
|
-
if (!isInstalled) {
|
|
17
|
-
ISAModule.install()
|
|
18
|
-
isInstalled = true
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
declare global {
|
|
23
|
-
function isaAddImageToBuffer(nativeIsaId: string, imageData: ImageData): void;
|
|
24
|
-
|
|
25
|
-
function isaGetImageData(nativeIsaId: string): ImageData | null | undefined;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* The ImageSourceAdapter class provides an interface for fetching and buffering images.
|
|
31
|
-
* It is an abstract class that needs to be implemented by a concrete class to provide actual functionality.
|
|
32
|
-
* `Each ImageSourceAdapter instance object will correspond to a native instance object.`
|
|
33
|
-
*
|
|
34
|
-
* @see {@link CameraEnhancer}
|
|
35
|
-
* @see {@link CaptureVisionRouter.setInput}
|
|
36
|
-
* @hideconstructor
|
|
37
|
-
* */
|
|
38
|
-
export abstract class ImageSourceAdapter {
|
|
39
|
-
protected isaId: string = "";
|
|
40
|
-
|
|
41
|
-
protected constructor() {
|
|
42
|
-
this.init();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
protected init() {
|
|
46
|
-
this.isaId = ISAModule.createDefaultNativeISA();
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**@internal*/
|
|
50
|
-
public _getIsaId(): string {
|
|
51
|
-
return this.isaId;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Destroy native instance. This object is no longer available after destroy().
|
|
56
|
-
* */
|
|
57
|
-
public destroy(): void {
|
|
58
|
-
ISAModule.destroy(this.isaId);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Adds an image to the buffer of the adapter.
|
|
63
|
-
*
|
|
64
|
-
* @param imageData The {@link ImageData} object to be added to the buffer.
|
|
65
|
-
* */
|
|
66
|
-
public addImageToBuffer(imageData: ImageData): void {
|
|
67
|
-
installMethods()
|
|
68
|
-
if (typeof global.isaAddImageToBuffer !== 'function') {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
global.isaAddImageToBuffer(this.isaId, imageData)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Get a buffered image.
|
|
76
|
-
*
|
|
77
|
-
* @returns {ImageData|null|undefined} - The {@link ImageData} object if available, otherwise`null` or `undefined` if no image is found in the buffer.
|
|
78
|
-
* */
|
|
79
|
-
public getImageData(): ImageData | null | undefined {
|
|
80
|
-
installMethods()
|
|
81
|
-
if (typeof global.isaGetImageData !== 'function') {
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
return global.isaGetImageData(this.isaId)
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Get the current number of images in the buffer.
|
|
89
|
-
*
|
|
90
|
-
* @returns {Promise<number>} - A promise that resolves to the number of images in the buffer.
|
|
91
|
-
* */
|
|
92
|
-
public getImageCount(): Promise<number> {
|
|
93
|
-
return ISAModule.getImageCount(this.isaId);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Determines whether the buffer is empty.
|
|
98
|
-
* */
|
|
99
|
-
public isBufferEmpty(): Promise<boolean> {
|
|
100
|
-
return ISAModule.isBufferEmpty(this.isaId);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Clear the image buffer.
|
|
105
|
-
* */
|
|
106
|
-
public clearBuffer(): Promise<void> {
|
|
107
|
-
return ISAModule.clearBuffer(this.isaId);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Get the current usage type for color channels in images.
|
|
113
|
-
*
|
|
114
|
-
* @returns {Promise<EnumColourChannelUsageType>} - A promise that resolves to an enum representing the color channel usage type.
|
|
115
|
-
* */
|
|
116
|
-
public getColourChannelUsageType(): Promise<EnumColourChannelUsageType> {
|
|
117
|
-
return ISAModule.getColourChannelUsageType(this.isaId);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Set the usage type of a color channel in images.
|
|
122
|
-
*
|
|
123
|
-
* @param type The usage type({@link EnumColourChannelUsageType}) to be set for the color channel.
|
|
124
|
-
* */
|
|
125
|
-
public setColourChannelUsageType(type: EnumColourChannelUsageType): Promise<void> {
|
|
126
|
-
return ISAModule.setColourChannelUsageType(this.isaId, type);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Get the maximum number of images that can be buffered.
|
|
131
|
-
*
|
|
132
|
-
* @return {Promise<number>} - A promise that resolves to the maximum capability of the Buffer.
|
|
133
|
-
* */
|
|
134
|
-
public getMaximumImageCount(): Promise<number> {
|
|
135
|
-
return ISAModule.getMaximumImageCount(this.isaId);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Set the maximum number of images that can be buffered at any time.
|
|
140
|
-
*
|
|
141
|
-
* @param count - The maximum capability of the Buffer.
|
|
142
|
-
* */
|
|
143
|
-
public setMaximumImageCount(count: number): Promise<void> {
|
|
144
|
-
return ISAModule.setNextImageToReturn(this.isaId, count);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Start fetching images from the source to the Buffer of ImageSourceAdapter.
|
|
149
|
-
* */
|
|
150
|
-
public startFetching(): void {
|
|
151
|
-
ISAModule.startFetching(this.isaId);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Stop fetching images from the source to the Buffer of ImageSourceAdapter.
|
|
156
|
-
* */
|
|
157
|
-
public stopFetching(): void {
|
|
158
|
-
ISAModule.stopFetching(this.isaId);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
1
|
+
import type {ImageData} from "./ImageData";
|
|
2
|
+
import {NativeModules} from "react-native";
|
|
3
|
+
import type {EnumColourChannelUsageType} from "./EnumColourChannelUsageType";
|
|
4
|
+
import {CameraEnhancer} from "../dce";
|
|
5
|
+
import {CaptureVisionRouter} from "../cvr";
|
|
6
|
+
|
|
7
|
+
// @ts-ignore Check whether __turboModuleProxy exists, it may not
|
|
8
|
+
const isTurboModuleEnabled = global.__turboModuleProxy != null;
|
|
9
|
+
|
|
10
|
+
const ISAModule = isTurboModuleEnabled ?
|
|
11
|
+
require("./NativeDynamsoftImageSourceAdapterModule").default :
|
|
12
|
+
NativeModules.DynamsoftImageSourceAdapterModule
|
|
13
|
+
|
|
14
|
+
let isInstalled = false
|
|
15
|
+
const installMethods = () => {
|
|
16
|
+
if (!isInstalled) {
|
|
17
|
+
ISAModule.install()
|
|
18
|
+
isInstalled = true
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
declare global {
|
|
23
|
+
function isaAddImageToBuffer(nativeIsaId: string, imageData: ImageData): void;
|
|
24
|
+
|
|
25
|
+
function isaGetImageData(nativeIsaId: string): ImageData | null | undefined;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The ImageSourceAdapter class provides an interface for fetching and buffering images.
|
|
31
|
+
* It is an abstract class that needs to be implemented by a concrete class to provide actual functionality.
|
|
32
|
+
* `Each ImageSourceAdapter instance object will correspond to a native instance object.`
|
|
33
|
+
*
|
|
34
|
+
* @see {@link CameraEnhancer}
|
|
35
|
+
* @see {@link CaptureVisionRouter.setInput}
|
|
36
|
+
* @hideconstructor
|
|
37
|
+
* */
|
|
38
|
+
export abstract class ImageSourceAdapter {
|
|
39
|
+
protected isaId: string = "";
|
|
40
|
+
|
|
41
|
+
protected constructor() {
|
|
42
|
+
this.init();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
protected init() {
|
|
46
|
+
this.isaId = ISAModule.createDefaultNativeISA();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**@internal*/
|
|
50
|
+
public _getIsaId(): string {
|
|
51
|
+
return this.isaId;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Destroy native instance. This object is no longer available after destroy().
|
|
56
|
+
* */
|
|
57
|
+
public destroy(): void {
|
|
58
|
+
ISAModule.destroy(this.isaId);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Adds an image to the buffer of the adapter.
|
|
63
|
+
*
|
|
64
|
+
* @param imageData The {@link ImageData} object to be added to the buffer.
|
|
65
|
+
* */
|
|
66
|
+
public addImageToBuffer(imageData: ImageData): void {
|
|
67
|
+
installMethods()
|
|
68
|
+
if (typeof global.isaAddImageToBuffer !== 'function') {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
global.isaAddImageToBuffer(this.isaId, imageData)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Get a buffered image.
|
|
76
|
+
*
|
|
77
|
+
* @returns {ImageData|null|undefined} - The {@link ImageData} object if available, otherwise`null` or `undefined` if no image is found in the buffer.
|
|
78
|
+
* */
|
|
79
|
+
public getImageData(): ImageData | null | undefined {
|
|
80
|
+
installMethods()
|
|
81
|
+
if (typeof global.isaGetImageData !== 'function') {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
return global.isaGetImageData(this.isaId)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Get the current number of images in the buffer.
|
|
89
|
+
*
|
|
90
|
+
* @returns {Promise<number>} - A promise that resolves to the number of images in the buffer.
|
|
91
|
+
* */
|
|
92
|
+
public getImageCount(): Promise<number> {
|
|
93
|
+
return ISAModule.getImageCount(this.isaId);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Determines whether the buffer is empty.
|
|
98
|
+
* */
|
|
99
|
+
public isBufferEmpty(): Promise<boolean> {
|
|
100
|
+
return ISAModule.isBufferEmpty(this.isaId);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Clear the image buffer.
|
|
105
|
+
* */
|
|
106
|
+
public clearBuffer(): Promise<void> {
|
|
107
|
+
return ISAModule.clearBuffer(this.isaId);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Get the current usage type for color channels in images.
|
|
113
|
+
*
|
|
114
|
+
* @returns {Promise<EnumColourChannelUsageType>} - A promise that resolves to an enum representing the color channel usage type.
|
|
115
|
+
* */
|
|
116
|
+
public getColourChannelUsageType(): Promise<EnumColourChannelUsageType> {
|
|
117
|
+
return ISAModule.getColourChannelUsageType(this.isaId);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Set the usage type of a color channel in images.
|
|
122
|
+
*
|
|
123
|
+
* @param type The usage type({@link EnumColourChannelUsageType}) to be set for the color channel.
|
|
124
|
+
* */
|
|
125
|
+
public setColourChannelUsageType(type: EnumColourChannelUsageType): Promise<void> {
|
|
126
|
+
return ISAModule.setColourChannelUsageType(this.isaId, type);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Get the maximum number of images that can be buffered.
|
|
131
|
+
*
|
|
132
|
+
* @return {Promise<number>} - A promise that resolves to the maximum capability of the Buffer.
|
|
133
|
+
* */
|
|
134
|
+
public getMaximumImageCount(): Promise<number> {
|
|
135
|
+
return ISAModule.getMaximumImageCount(this.isaId);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Set the maximum number of images that can be buffered at any time.
|
|
140
|
+
*
|
|
141
|
+
* @param count - The maximum capability of the Buffer.
|
|
142
|
+
* */
|
|
143
|
+
public setMaximumImageCount(count: number): Promise<void> {
|
|
144
|
+
return ISAModule.setNextImageToReturn(this.isaId, count);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Start fetching images from the source to the Buffer of ImageSourceAdapter.
|
|
149
|
+
* */
|
|
150
|
+
public startFetching(): void {
|
|
151
|
+
ISAModule.startFetching(this.isaId);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Stop fetching images from the source to the Buffer of ImageSourceAdapter.
|
|
156
|
+
* */
|
|
157
|
+
public stopFetching(): void {
|
|
158
|
+
ISAModule.stopFetching(this.isaId);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import {type TurboModule, TurboModuleRegistry} from "react-native";
|
|
2
|
-
|
|
3
|
-
export interface Spec extends TurboModule {
|
|
4
|
-
install(): boolean;
|
|
5
|
-
|
|
6
|
-
createDefaultNativeISA(): string;
|
|
7
|
-
|
|
8
|
-
destroy(isaId: string): void;
|
|
9
|
-
|
|
10
|
-
getImageCount(isaId: string): Promise<number>;
|
|
11
|
-
|
|
12
|
-
isBufferEmpty(isaId: string): Promise<boolean>;
|
|
13
|
-
|
|
14
|
-
clearBuffer(isaId: string): Promise<void>;
|
|
15
|
-
|
|
16
|
-
getColourChannelUsageType(isaId: string): Promise<number>;
|
|
17
|
-
|
|
18
|
-
setColourChannelUsageType(isaId: string, type: number): Promise<void>;
|
|
19
|
-
|
|
20
|
-
getMaximumImageCount(isaId: string): Promise<number>;
|
|
21
|
-
|
|
22
|
-
setMaximumImageCount(isaId: string, maxCount: number): Promise<void>;
|
|
23
|
-
|
|
24
|
-
startFetching(isaId: string): void;
|
|
25
|
-
|
|
26
|
-
stopFetching(isaId: string): void;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export default TurboModuleRegistry.get<Spec>("DynamsoftImageSourceAdapterModule") as Spec | null;
|
|
1
|
+
import {type TurboModule, TurboModuleRegistry} from "react-native";
|
|
2
|
+
|
|
3
|
+
export interface Spec extends TurboModule {
|
|
4
|
+
install(): boolean;
|
|
5
|
+
|
|
6
|
+
createDefaultNativeISA(): string;
|
|
7
|
+
|
|
8
|
+
destroy(isaId: string): void;
|
|
9
|
+
|
|
10
|
+
getImageCount(isaId: string): Promise<number>;
|
|
11
|
+
|
|
12
|
+
isBufferEmpty(isaId: string): Promise<boolean>;
|
|
13
|
+
|
|
14
|
+
clearBuffer(isaId: string): Promise<void>;
|
|
15
|
+
|
|
16
|
+
getColourChannelUsageType(isaId: string): Promise<number>;
|
|
17
|
+
|
|
18
|
+
setColourChannelUsageType(isaId: string, type: number): Promise<void>;
|
|
19
|
+
|
|
20
|
+
getMaximumImageCount(isaId: string): Promise<number>;
|
|
21
|
+
|
|
22
|
+
setMaximumImageCount(isaId: string, maxCount: number): Promise<void>;
|
|
23
|
+
|
|
24
|
+
startFetching(isaId: string): void;
|
|
25
|
+
|
|
26
|
+
stopFetching(isaId: string): void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default TurboModuleRegistry.get<Spec>("DynamsoftImageSourceAdapterModule") as Spec | null;
|