dynamsoft-capture-vision-react-native 3.4.1200 → 3.4.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.
- package/LICENSE +5 -5
- package/README.md +62 -66
- 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/dysJniLibs/debug/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibs/debug/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibs/debug/x86/librn_dys.so +0 -0
- package/android/src/main/dysJniLibs/debug/x86_64/librn_dys.so +0 -0
- package/android/src/main/dysJniLibs/release/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibs/release/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibs/release/x86/librn_dys.so +0 -0
- package/android/src/main/dysJniLibs/release/x86_64/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor81/debug/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor81/debug/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor81/debug/x86/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor81/debug/x86_64/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor81/release/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor81/release/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor81/release/x86/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor81/release/x86_64/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor82/debug/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor82/debug/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor82/debug/x86/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor82/debug/x86_64/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor82/release/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor82/release/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor82/release/x86/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor82/release/x86_64/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor86/debug/arm64-v8a/librn_dys.so +3 -0
- package/android/src/main/dysJniLibsFor86/debug/armeabi-v7a/librn_dys.so +3 -0
- package/android/src/main/dysJniLibsFor86/debug/x86/librn_dys.so +3 -0
- package/android/src/main/dysJniLibsFor86/debug/x86_64/librn_dys.so +3 -0
- package/android/src/main/dysJniLibsFor86/release/arm64-v8a/librn_dys.so +3 -0
- package/android/src/main/dysJniLibsFor86/release/armeabi-v7a/librn_dys.so +3 -0
- package/android/src/main/dysJniLibsFor86/release/x86/librn_dys.so +3 -0
- package/android/src/main/dysJniLibsFor86/release/x86_64/librn_dys.so +3 -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,254 +1,254 @@
|
|
|
1
|
-
import {ImageSourceAdapter, type DSRect} from "../core";
|
|
2
|
-
import {NativeModules, Platform} from "react-native";
|
|
3
|
-
import {CameraView} from "./CameraView"
|
|
4
|
-
import {EnumCameraPosition} from "./EnumCameraPosition";
|
|
5
|
-
import type {EnumFocusMode} from "./EnumFocusMode";
|
|
6
|
-
import type {EnumEnhancedFeatures} from "./EnumEnhancedFeatures";
|
|
7
|
-
import type {EnumResolution} from "./EnumResolution";
|
|
8
|
-
|
|
9
|
-
// @ts-ignore Check whether __turboModuleProxy exists, it may not
|
|
10
|
-
const isTurboModuleEnabled = global.__turboModuleProxy != null;
|
|
11
|
-
|
|
12
|
-
const DynamsoftCameraEnhancerModule = isTurboModuleEnabled ?
|
|
13
|
-
require("./NativeDynamsoftCameraViewModule").default :
|
|
14
|
-
NativeModules.DynamsoftCameraView;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* The singleton instance of CameraEnhancer.
|
|
18
|
-
* */
|
|
19
|
-
let dce: CameraEnhancer | null;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* The CameraEnhancer class is the primary class of Dynamsoft Camera Enhancer that defines the camera controlling APIs.
|
|
23
|
-
* It is a subclass of {@link ImageSourceAdapter}.
|
|
24
|
-
* <p>
|
|
25
|
-
* In js end of react-native, CameraEnhancer uses singleton mode. You can only get CaptureVisionRouter instance by {@link CameraEnhancer.getInstance}.
|
|
26
|
-
* @hideconstructor
|
|
27
|
-
* */
|
|
28
|
-
export class CameraEnhancer extends ImageSourceAdapter {
|
|
29
|
-
private constructor() {
|
|
30
|
-
super();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
protected init() {
|
|
34
|
-
this.isaId = DynamsoftCameraEnhancerModule.createInstance()
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**Trigger to request the camera permission.*/
|
|
38
|
-
static async requestCameraPermission() {
|
|
39
|
-
if (Platform.OS === "android") {
|
|
40
|
-
DynamsoftCameraEnhancerModule.requestCameraPermission()
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Get the singleton instance of CameraEnhancer.
|
|
46
|
-
* <p>
|
|
47
|
-
* This method ensures that only one instance of CameraEnhancer is created
|
|
48
|
-
* and reused throughout the application. If an instance already exists, it will
|
|
49
|
-
* return the existing one. Otherwise, it will create a new instance and return it.
|
|
50
|
-
*
|
|
51
|
-
* @returns {CameraEnhancer} The singleton instance of CameraEnhancer.
|
|
52
|
-
* */
|
|
53
|
-
static getInstance(): CameraEnhancer {
|
|
54
|
-
if (dce) {
|
|
55
|
-
return dce;
|
|
56
|
-
}
|
|
57
|
-
return dce = new CameraEnhancer();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Destroys the CameraEnhancer instance and releases all associated resources.
|
|
62
|
-
* After calling this method, the instance will be set to null and cannot be used anymore.
|
|
63
|
-
* Only call this method when you want to completely dispose the CameraEnhancer instance, otherwise just call {@link CameraEnhancer.close} to stop the camera and release the video stream.
|
|
64
|
-
*/
|
|
65
|
-
dispose() {
|
|
66
|
-
DynamsoftCameraEnhancerModule.destroyInstance(this.isaId);
|
|
67
|
-
dce = null;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**Opens the currently selected camera and starts the video stream.*/
|
|
71
|
-
open() {
|
|
72
|
-
DynamsoftCameraEnhancerModule.open();
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**Closes the currently active camera and stops the video stream.*/
|
|
76
|
-
close() {
|
|
77
|
-
DynamsoftCameraEnhancerModule.close();
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Bind a CameraView instance with this CameraEnhancer instance.
|
|
82
|
-
*
|
|
83
|
-
* <p>Code Snippet:</p>
|
|
84
|
-
*
|
|
85
|
-
*```
|
|
86
|
-
* function App(): React.JSX.Element {
|
|
87
|
-
* const cameraView = useRef<CameraView>(null);
|
|
88
|
-
* const camera = CameraEnhancer.getInstance();
|
|
89
|
-
* useEffect(() => {
|
|
90
|
-
* camera.setCameraView(cameraView.current!!);
|
|
91
|
-
* camera.open();
|
|
92
|
-
* }, [camera, cameraView])
|
|
93
|
-
* return (<CameraView style={{flex:1}} ref={cameraView}/>);
|
|
94
|
-
* }
|
|
95
|
-
* ```
|
|
96
|
-
*
|
|
97
|
-
* @param view - the CameraView element
|
|
98
|
-
* */
|
|
99
|
-
setCameraView(view: CameraView | null) {
|
|
100
|
-
if (view) {
|
|
101
|
-
DynamsoftCameraEnhancerModule.setCameraView(view.nativeCameraViewHandle);
|
|
102
|
-
} else {
|
|
103
|
-
DynamsoftCameraEnhancerModule.setCameraView(0);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Select a camera with a camera position.
|
|
109
|
-
* @param position - One of the {@link EnumCameraPosition}
|
|
110
|
-
* @note {@link EnumCameraPosition.CP_BACK_DUAL_WIDE_AUTO} and {@link EnumCameraPosition.CP_BACK_ULTRA_WIDE} are only supported on iOS.
|
|
111
|
-
* */
|
|
112
|
-
selectCamera(position: EnumCameraPosition | number) {
|
|
113
|
-
if(Platform.OS !== "ios") {
|
|
114
|
-
if (position === EnumCameraPosition.CP_BACK_DUAL_WIDE_AUTO || position === EnumCameraPosition.CP_BACK_ULTRA_WIDE) {
|
|
115
|
-
position = EnumCameraPosition.CP_BACK;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
DynamsoftCameraEnhancerModule.selectCamera(position);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Get the camera position.
|
|
123
|
-
* @return {Promise<EnumCameraPosition|number>} - A promise that resolves {@link EnumCameraPosition.CP_BACK} or {@link EnumCameraPosition.CP_FRONT}.
|
|
124
|
-
* */
|
|
125
|
-
getCameraPosition(): Promise<EnumCameraPosition | number> {
|
|
126
|
-
return DynamsoftCameraEnhancerModule.getCameraPosition();
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Set the focus point of interest and trigger an one-off auto-focus.
|
|
131
|
-
* After the focus, you can either lock the focalngth or keep the continuous auto focus enabled by configuring the subsequent focus mode.
|
|
132
|
-
* @param floatX - The x of focus point of interest. The coordinate base of the point is "image".
|
|
133
|
-
* @param floatY - The y of focus point of interest. The coordinate base of the point is "image".
|
|
134
|
-
* @param focusMode The subsequent focus mode.
|
|
135
|
-
* @see EnumFocusMode
|
|
136
|
-
* */
|
|
137
|
-
setFocus(floatX: number, floatY: number, focusMode: EnumFocusMode | number) {
|
|
138
|
-
DynamsoftCameraEnhancerModule.setFocus(floatX, floatY, focusMode);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Get the currently actived focus mode.
|
|
143
|
-
* @return {Promise<EnumFocusMode|number>} - A promise that resolves one of {@link EnumFocusMode}.
|
|
144
|
-
* */
|
|
145
|
-
getFocusMode(): Promise<EnumFocusMode | number> {
|
|
146
|
-
return DynamsoftCameraEnhancerModule.getFocusMode();
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Set the zoom factor of the camera.
|
|
151
|
-
* @param factor - The zoom factor.
|
|
152
|
-
* */
|
|
153
|
-
setZoomFactor(factor: number) {
|
|
154
|
-
DynamsoftCameraEnhancerModule.setZoomFactor(factor);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Get the zoom factor of the camera.
|
|
159
|
-
* @return {Promise<number>} - A promise that resolves current zoom factor.
|
|
160
|
-
* */
|
|
161
|
-
getZoomFactor(): Promise<number> {
|
|
162
|
-
return DynamsoftCameraEnhancerModule.getZoomFactor();
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Enable the specified enhanced features. View {@link EnumEnhancedFeatures} to learn about these enhanced features.
|
|
167
|
-
* By default, these enhanced features are all disabled.
|
|
168
|
-
* <p>Code Snippet:</p>
|
|
169
|
-
*
|
|
170
|
-
*```
|
|
171
|
-
* cameraEnhancer.enableEnhancedFeatures(EnumEnhancedFeatures.EF_AUTO_ZOOM | EnumEnhancedFeatures.EF_FRAME_FILTER)
|
|
172
|
-
* ```
|
|
173
|
-
* @param features - An enum value or a bitwise combination of EnumEnhancedFeatures which indicates a series of enhanced features.
|
|
174
|
-
* @see {@link EnumEnhancedFeatures}
|
|
175
|
-
* */
|
|
176
|
-
enableEnhancedFeatures(features: EnumEnhancedFeatures | number) {
|
|
177
|
-
DynamsoftCameraEnhancerModule.enableEnhancedFeatures(features);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Disables one or more previously enabled enhanced features.
|
|
182
|
-
* <p>Code Snippet:</p>
|
|
183
|
-
*
|
|
184
|
-
*```
|
|
185
|
-
* cameraEnhancer.disableEnhancedFeatures(EnumEnhancedFeatures.EF_AUTO_ZOOM | EnumEnhancedFeatures.EF_FRAME_FILTER)
|
|
186
|
-
* ```
|
|
187
|
-
* @param features - An enum value or a bitwise combination of EnumEnhancedFeatures indicating the features to be disabled.
|
|
188
|
-
* @see {@link EnumEnhancedFeatures}
|
|
189
|
-
* */
|
|
190
|
-
disableEnhancedFeatures(features: EnumEnhancedFeatures | number) {
|
|
191
|
-
DynamsoftCameraEnhancerModule.disableEnhancedFeatures(features);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Sets the scan region within the camera's view which limits the frame acquisition to a specific area of the video feed.
|
|
196
|
-
* <p>Code Snippet:</p>
|
|
197
|
-
*
|
|
198
|
-
*```
|
|
199
|
-
* let scanRegion = {
|
|
200
|
-
* top: 0.25,
|
|
201
|
-
* bottom: 0.75,
|
|
202
|
-
* left: 0.25,
|
|
203
|
-
* right: 0.75,
|
|
204
|
-
* measuredInPercentage: true,
|
|
205
|
-
* }
|
|
206
|
-
* cameraEnhancer.setScanRegion(scanRegion);
|
|
207
|
-
* //...
|
|
208
|
-
* cameraEnhancer.setScanRegion(null); //Cancel the scan region
|
|
209
|
-
* ```
|
|
210
|
-
*
|
|
211
|
-
* @param region - specifies the scan region. If null or undefined, cancel the scan region.
|
|
212
|
-
* @remarks The region is always specified relative to the original video size, regardless of any transformations or zoom applied to the video display.
|
|
213
|
-
* @see {@link DSRect}
|
|
214
|
-
* */
|
|
215
|
-
setScanRegion(region: DSRect | null | undefined) {
|
|
216
|
-
DynamsoftCameraEnhancerModule.setScanRegion(region);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Retrieves the current scan region.
|
|
221
|
-
* @return {Promise<DSRect|null|undefined>} - A promise that resolves current scan region.
|
|
222
|
-
* @see {@link DSRect}
|
|
223
|
-
* */
|
|
224
|
-
getScanRegion(): Promise<DSRect | null | undefined> {
|
|
225
|
-
return DynamsoftCameraEnhancerModule.getScanRegion()
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Turn on the torch.
|
|
230
|
-
* */
|
|
231
|
-
turnOnTorch() {
|
|
232
|
-
DynamsoftCameraEnhancerModule.turnOnTorch()
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Turn off the torch.
|
|
237
|
-
* */
|
|
238
|
-
turnOffTorch() {
|
|
239
|
-
DynamsoftCameraEnhancerModule.turnOffTorch()
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* Set the resolution of the camera.
|
|
244
|
-
* @param resolution - One of the {@link EnumResolution}.
|
|
245
|
-
* */
|
|
246
|
-
setResolution(resolution: EnumResolution) {
|
|
247
|
-
DynamsoftCameraEnhancerModule.setResolution(resolution);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
destroy() {
|
|
251
|
-
this.close()
|
|
252
|
-
super.destroy();
|
|
253
|
-
}
|
|
254
|
-
}
|
|
1
|
+
import {ImageSourceAdapter, type DSRect} from "../core";
|
|
2
|
+
import {NativeModules, Platform} from "react-native";
|
|
3
|
+
import {CameraView} from "./CameraView"
|
|
4
|
+
import {EnumCameraPosition} from "./EnumCameraPosition";
|
|
5
|
+
import type {EnumFocusMode} from "./EnumFocusMode";
|
|
6
|
+
import type {EnumEnhancedFeatures} from "./EnumEnhancedFeatures";
|
|
7
|
+
import type {EnumResolution} from "./EnumResolution";
|
|
8
|
+
|
|
9
|
+
// @ts-ignore Check whether __turboModuleProxy exists, it may not
|
|
10
|
+
const isTurboModuleEnabled = global.__turboModuleProxy != null;
|
|
11
|
+
|
|
12
|
+
const DynamsoftCameraEnhancerModule = isTurboModuleEnabled ?
|
|
13
|
+
require("./NativeDynamsoftCameraViewModule").default :
|
|
14
|
+
NativeModules.DynamsoftCameraView;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The singleton instance of CameraEnhancer.
|
|
18
|
+
* */
|
|
19
|
+
let dce: CameraEnhancer | null;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The CameraEnhancer class is the primary class of Dynamsoft Camera Enhancer that defines the camera controlling APIs.
|
|
23
|
+
* It is a subclass of {@link ImageSourceAdapter}.
|
|
24
|
+
* <p>
|
|
25
|
+
* In js end of react-native, CameraEnhancer uses singleton mode. You can only get CaptureVisionRouter instance by {@link CameraEnhancer.getInstance}.
|
|
26
|
+
* @hideconstructor
|
|
27
|
+
* */
|
|
28
|
+
export class CameraEnhancer extends ImageSourceAdapter {
|
|
29
|
+
private constructor() {
|
|
30
|
+
super();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
protected init() {
|
|
34
|
+
this.isaId = DynamsoftCameraEnhancerModule.createInstance()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**Trigger to request the camera permission.*/
|
|
38
|
+
static async requestCameraPermission() {
|
|
39
|
+
if (Platform.OS === "android") {
|
|
40
|
+
DynamsoftCameraEnhancerModule.requestCameraPermission()
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Get the singleton instance of CameraEnhancer.
|
|
46
|
+
* <p>
|
|
47
|
+
* This method ensures that only one instance of CameraEnhancer is created
|
|
48
|
+
* and reused throughout the application. If an instance already exists, it will
|
|
49
|
+
* return the existing one. Otherwise, it will create a new instance and return it.
|
|
50
|
+
*
|
|
51
|
+
* @returns {CameraEnhancer} The singleton instance of CameraEnhancer.
|
|
52
|
+
* */
|
|
53
|
+
static getInstance(): CameraEnhancer {
|
|
54
|
+
if (dce) {
|
|
55
|
+
return dce;
|
|
56
|
+
}
|
|
57
|
+
return dce = new CameraEnhancer();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Destroys the CameraEnhancer instance and releases all associated resources.
|
|
62
|
+
* After calling this method, the instance will be set to null and cannot be used anymore.
|
|
63
|
+
* Only call this method when you want to completely dispose the CameraEnhancer instance, otherwise just call {@link CameraEnhancer.close} to stop the camera and release the video stream.
|
|
64
|
+
*/
|
|
65
|
+
dispose() {
|
|
66
|
+
DynamsoftCameraEnhancerModule.destroyInstance(this.isaId);
|
|
67
|
+
dce = null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**Opens the currently selected camera and starts the video stream.*/
|
|
71
|
+
open() {
|
|
72
|
+
DynamsoftCameraEnhancerModule.open();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**Closes the currently active camera and stops the video stream.*/
|
|
76
|
+
close() {
|
|
77
|
+
DynamsoftCameraEnhancerModule.close();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Bind a CameraView instance with this CameraEnhancer instance.
|
|
82
|
+
*
|
|
83
|
+
* <p>Code Snippet:</p>
|
|
84
|
+
*
|
|
85
|
+
*```
|
|
86
|
+
* function App(): React.JSX.Element {
|
|
87
|
+
* const cameraView = useRef<CameraView>(null);
|
|
88
|
+
* const camera = CameraEnhancer.getInstance();
|
|
89
|
+
* useEffect(() => {
|
|
90
|
+
* camera.setCameraView(cameraView.current!!);
|
|
91
|
+
* camera.open();
|
|
92
|
+
* }, [camera, cameraView])
|
|
93
|
+
* return (<CameraView style={{flex:1}} ref={cameraView}/>);
|
|
94
|
+
* }
|
|
95
|
+
* ```
|
|
96
|
+
*
|
|
97
|
+
* @param view - the CameraView element
|
|
98
|
+
* */
|
|
99
|
+
setCameraView(view: CameraView | null) {
|
|
100
|
+
if (view) {
|
|
101
|
+
DynamsoftCameraEnhancerModule.setCameraView(view.nativeCameraViewHandle);
|
|
102
|
+
} else {
|
|
103
|
+
DynamsoftCameraEnhancerModule.setCameraView(0);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Select a camera with a camera position.
|
|
109
|
+
* @param position - One of the {@link EnumCameraPosition}
|
|
110
|
+
* @note {@link EnumCameraPosition.CP_BACK_DUAL_WIDE_AUTO} and {@link EnumCameraPosition.CP_BACK_ULTRA_WIDE} are only supported on iOS.
|
|
111
|
+
* */
|
|
112
|
+
selectCamera(position: EnumCameraPosition | number) {
|
|
113
|
+
if(Platform.OS !== "ios") {
|
|
114
|
+
if (position === EnumCameraPosition.CP_BACK_DUAL_WIDE_AUTO || position === EnumCameraPosition.CP_BACK_ULTRA_WIDE) {
|
|
115
|
+
position = EnumCameraPosition.CP_BACK;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
DynamsoftCameraEnhancerModule.selectCamera(position);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Get the camera position.
|
|
123
|
+
* @return {Promise<EnumCameraPosition|number>} - A promise that resolves {@link EnumCameraPosition.CP_BACK} or {@link EnumCameraPosition.CP_FRONT}.
|
|
124
|
+
* */
|
|
125
|
+
getCameraPosition(): Promise<EnumCameraPosition | number> {
|
|
126
|
+
return DynamsoftCameraEnhancerModule.getCameraPosition();
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Set the focus point of interest and trigger an one-off auto-focus.
|
|
131
|
+
* After the focus, you can either lock the focalngth or keep the continuous auto focus enabled by configuring the subsequent focus mode.
|
|
132
|
+
* @param floatX - The x of focus point of interest. The coordinate base of the point is "image".
|
|
133
|
+
* @param floatY - The y of focus point of interest. The coordinate base of the point is "image".
|
|
134
|
+
* @param focusMode The subsequent focus mode.
|
|
135
|
+
* @see EnumFocusMode
|
|
136
|
+
* */
|
|
137
|
+
setFocus(floatX: number, floatY: number, focusMode: EnumFocusMode | number) {
|
|
138
|
+
DynamsoftCameraEnhancerModule.setFocus(floatX, floatY, focusMode);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Get the currently actived focus mode.
|
|
143
|
+
* @return {Promise<EnumFocusMode|number>} - A promise that resolves one of {@link EnumFocusMode}.
|
|
144
|
+
* */
|
|
145
|
+
getFocusMode(): Promise<EnumFocusMode | number> {
|
|
146
|
+
return DynamsoftCameraEnhancerModule.getFocusMode();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Set the zoom factor of the camera.
|
|
151
|
+
* @param factor - The zoom factor.
|
|
152
|
+
* */
|
|
153
|
+
setZoomFactor(factor: number) {
|
|
154
|
+
DynamsoftCameraEnhancerModule.setZoomFactor(factor);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Get the zoom factor of the camera.
|
|
159
|
+
* @return {Promise<number>} - A promise that resolves current zoom factor.
|
|
160
|
+
* */
|
|
161
|
+
getZoomFactor(): Promise<number> {
|
|
162
|
+
return DynamsoftCameraEnhancerModule.getZoomFactor();
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Enable the specified enhanced features. View {@link EnumEnhancedFeatures} to learn about these enhanced features.
|
|
167
|
+
* By default, these enhanced features are all disabled.
|
|
168
|
+
* <p>Code Snippet:</p>
|
|
169
|
+
*
|
|
170
|
+
*```
|
|
171
|
+
* cameraEnhancer.enableEnhancedFeatures(EnumEnhancedFeatures.EF_AUTO_ZOOM | EnumEnhancedFeatures.EF_FRAME_FILTER)
|
|
172
|
+
* ```
|
|
173
|
+
* @param features - An enum value or a bitwise combination of EnumEnhancedFeatures which indicates a series of enhanced features.
|
|
174
|
+
* @see {@link EnumEnhancedFeatures}
|
|
175
|
+
* */
|
|
176
|
+
enableEnhancedFeatures(features: EnumEnhancedFeatures | number) {
|
|
177
|
+
DynamsoftCameraEnhancerModule.enableEnhancedFeatures(features);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Disables one or more previously enabled enhanced features.
|
|
182
|
+
* <p>Code Snippet:</p>
|
|
183
|
+
*
|
|
184
|
+
*```
|
|
185
|
+
* cameraEnhancer.disableEnhancedFeatures(EnumEnhancedFeatures.EF_AUTO_ZOOM | EnumEnhancedFeatures.EF_FRAME_FILTER)
|
|
186
|
+
* ```
|
|
187
|
+
* @param features - An enum value or a bitwise combination of EnumEnhancedFeatures indicating the features to be disabled.
|
|
188
|
+
* @see {@link EnumEnhancedFeatures}
|
|
189
|
+
* */
|
|
190
|
+
disableEnhancedFeatures(features: EnumEnhancedFeatures | number) {
|
|
191
|
+
DynamsoftCameraEnhancerModule.disableEnhancedFeatures(features);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Sets the scan region within the camera's view which limits the frame acquisition to a specific area of the video feed.
|
|
196
|
+
* <p>Code Snippet:</p>
|
|
197
|
+
*
|
|
198
|
+
*```
|
|
199
|
+
* let scanRegion = {
|
|
200
|
+
* top: 0.25,
|
|
201
|
+
* bottom: 0.75,
|
|
202
|
+
* left: 0.25,
|
|
203
|
+
* right: 0.75,
|
|
204
|
+
* measuredInPercentage: true,
|
|
205
|
+
* }
|
|
206
|
+
* cameraEnhancer.setScanRegion(scanRegion);
|
|
207
|
+
* //...
|
|
208
|
+
* cameraEnhancer.setScanRegion(null); //Cancel the scan region
|
|
209
|
+
* ```
|
|
210
|
+
*
|
|
211
|
+
* @param region - specifies the scan region. If null or undefined, cancel the scan region.
|
|
212
|
+
* @remarks The region is always specified relative to the original video size, regardless of any transformations or zoom applied to the video display.
|
|
213
|
+
* @see {@link DSRect}
|
|
214
|
+
* */
|
|
215
|
+
setScanRegion(region: DSRect | null | undefined) {
|
|
216
|
+
DynamsoftCameraEnhancerModule.setScanRegion(region);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Retrieves the current scan region.
|
|
221
|
+
* @return {Promise<DSRect|null|undefined>} - A promise that resolves current scan region.
|
|
222
|
+
* @see {@link DSRect}
|
|
223
|
+
* */
|
|
224
|
+
getScanRegion(): Promise<DSRect | null | undefined> {
|
|
225
|
+
return DynamsoftCameraEnhancerModule.getScanRegion()
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Turn on the torch.
|
|
230
|
+
* */
|
|
231
|
+
turnOnTorch() {
|
|
232
|
+
DynamsoftCameraEnhancerModule.turnOnTorch()
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Turn off the torch.
|
|
237
|
+
* */
|
|
238
|
+
turnOffTorch() {
|
|
239
|
+
DynamsoftCameraEnhancerModule.turnOffTorch()
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Set the resolution of the camera.
|
|
244
|
+
* @param resolution - One of the {@link EnumResolution}.
|
|
245
|
+
* */
|
|
246
|
+
setResolution(resolution: EnumResolution) {
|
|
247
|
+
DynamsoftCameraEnhancerModule.setResolution(resolution);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
destroy() {
|
|
251
|
+
this.close()
|
|
252
|
+
super.destroy();
|
|
253
|
+
}
|
|
254
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {DynamsoftVersions} from '../VersionsModule'
|
|
2
|
-
import {Platform} from "react-native";
|
|
3
|
-
|
|
4
|
-
/** @hideconstructor */
|
|
5
|
-
export class CameraEnhancerModule {
|
|
6
|
-
static getVersion(): string {
|
|
7
|
-
return '['+Platform.OS+']: ' + DynamsoftVersions.dce
|
|
8
|
-
}
|
|
9
|
-
}
|
|
1
|
+
import {DynamsoftVersions} from '../VersionsModule'
|
|
2
|
+
import {Platform} from "react-native";
|
|
3
|
+
|
|
4
|
+
/** @hideconstructor */
|
|
5
|
+
export class CameraEnhancerModule {
|
|
6
|
+
static getVersion(): string {
|
|
7
|
+
return '['+Platform.OS+']: ' + DynamsoftVersions.dce
|
|
8
|
+
}
|
|
9
|
+
}
|