dynamsoft-capture-vision-react-native 3.4.1300 → 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 +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/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
package/android/src/main/java/com/dynamsoft/reactnativelib/cvr/CaptureVisionRouterModuleImpl.kt
CHANGED
|
@@ -1,306 +1,306 @@
|
|
|
1
|
-
package com.dynamsoft.reactnativelib.cvr
|
|
2
|
-
|
|
3
|
-
import android.util.Log
|
|
4
|
-
import com.dynamsoft.core.basic_structures.CompletionListener
|
|
5
|
-
import com.dynamsoft.core.basic_structures.EnumCapturedResultItemType
|
|
6
|
-
import com.dynamsoft.core.basic_structures.ImageData
|
|
7
|
-
import com.dynamsoft.cvr.*
|
|
8
|
-
import com.dynamsoft.dbr.DecodedBarcodesResult
|
|
9
|
-
import com.dynamsoft.dcp.ParsedResult
|
|
10
|
-
import com.dynamsoft.ddn.DeskewedImageResultItem
|
|
11
|
-
import com.dynamsoft.ddn.EnhancedImageResultItem
|
|
12
|
-
import com.dynamsoft.ddn.ProcessedDocumentResult
|
|
13
|
-
import com.dynamsoft.dlr.RecognizedTextLinesResult
|
|
14
|
-
import com.dynamsoft.reactnativelib.basicutils.toWritableMap
|
|
15
|
-
import com.dynamsoft.reactnativelib.core.ImageSourceAdapterModuleImpl
|
|
16
|
-
import com.dynamsoft.reactnativelib.basicutils.updateFromReadableMap
|
|
17
|
-
import com.facebook.react.bridge.*
|
|
18
|
-
import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter
|
|
19
|
-
import kotlinx.coroutines.delay
|
|
20
|
-
import kotlinx.coroutines.runBlocking
|
|
21
|
-
|
|
22
|
-
private const val onCapturedResultReceived_Event = "onCapturedResultReceived"
|
|
23
|
-
private const val onDecodedBarcodesReceived_Event = "onDecodedBarcodesReceived"
|
|
24
|
-
private const val onProcessedDocumentResultReceived_Event = "onProcessedDocumentResultReceived"
|
|
25
|
-
private const val onRecognizedTextLinesReceived_Event = "onRecognizedTextLinesReceived"
|
|
26
|
-
private const val onParsedResultsReceived_Event = "onParsedResultsReceived"
|
|
27
|
-
private const val TAG = "CvrModule"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
val filterMap = hashMapOf<String, CapturedResultFilter>()
|
|
31
|
-
|
|
32
|
-
class CaptureVisionRouterModuleImpl(private val reactContext: ReactApplicationContext) {
|
|
33
|
-
companion object {
|
|
34
|
-
const val NAME = "DynamsoftCaptureVisionRouterModule"
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
private var ifStopCapturing = false
|
|
38
|
-
private var currentDeskewedImages: Array<ImageData>? = null
|
|
39
|
-
private var currentEnhancedImages: Array<ImageData>? = null
|
|
40
|
-
private var cvr: CaptureVisionRouter? = null
|
|
41
|
-
private val emitter by lazy { reactContext.getJSModule(RCTDeviceEventEmitter::class.java) }
|
|
42
|
-
|
|
43
|
-
private var continueCRR = false
|
|
44
|
-
private var crrRemoved = false
|
|
45
|
-
private val crrMap by lazy {
|
|
46
|
-
mapOf(
|
|
47
|
-
onCapturedResultReceived_Event to object : CapturedResultReceiver {
|
|
48
|
-
override fun onCapturedResultReceived(result: CapturedResult) {
|
|
49
|
-
currentDeskewedImages =
|
|
50
|
-
result.items.filter { it.type == EnumCapturedResultItemType.CRIT_DESKEWED_IMAGE }
|
|
51
|
-
.map { (it as DeskewedImageResultItem).imageData }.toTypedArray()
|
|
52
|
-
currentEnhancedImages =
|
|
53
|
-
result.items.filter { it.type == EnumCapturedResultItemType.CRIT_ENHANCED_IMAGE }
|
|
54
|
-
.map { (it as EnhancedImageResultItem).imageData }.toTypedArray()
|
|
55
|
-
emitResultAndWaitForResponse(onCapturedResultReceived_Event, result.toWritableMap())
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
onDecodedBarcodesReceived_Event to object : CapturedResultReceiver {
|
|
59
|
-
override fun onDecodedBarcodesReceived(result: DecodedBarcodesResult) {
|
|
60
|
-
emitResultAndWaitForResponse(onDecodedBarcodesReceived_Event, result.toWritableMap())
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
onProcessedDocumentResultReceived_Event to object : CapturedResultReceiver {
|
|
64
|
-
override fun onProcessedDocumentResultReceived(result: ProcessedDocumentResult) {
|
|
65
|
-
currentDeskewedImages = result.deskewedImageResultItems.map { (it as DeskewedImageResultItem).imageData }.toTypedArray()
|
|
66
|
-
currentEnhancedImages = result.enhancedImageResultItems.map { (it as EnhancedImageResultItem).imageData }.toTypedArray()
|
|
67
|
-
emitResultAndWaitForResponse(onProcessedDocumentResultReceived_Event, result.toWritableMap())
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
onRecognizedTextLinesReceived_Event to object : CapturedResultReceiver {
|
|
71
|
-
override fun onRecognizedTextLinesReceived(result: RecognizedTextLinesResult) {
|
|
72
|
-
emitResultAndWaitForResponse(onRecognizedTextLinesReceived_Event, result.toWritableMap())
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
onParsedResultsReceived_Event to object : CapturedResultReceiver {
|
|
76
|
-
override fun onParsedResultsReceived(result: ParsedResult) {
|
|
77
|
-
emitResultAndWaitForResponse(onParsedResultsReceived_Event, result.toWritableMap())
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
)
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
private fun emitResultAndWaitForResponse(eventKey: String, result: WritableMap) {
|
|
84
|
-
continueCRR = false
|
|
85
|
-
emitter.emit(eventKey, result)
|
|
86
|
-
while (!continueCRR && !crrRemoved && !ifStopCapturing) {
|
|
87
|
-
//waiting for js callback end
|
|
88
|
-
runBlocking {
|
|
89
|
-
delay(5)
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
fun getName() = NAME
|
|
95
|
-
|
|
96
|
-
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
97
|
-
fun createInstance(): Boolean {
|
|
98
|
-
if(cvr == null) cvr = CaptureVisionRouter()
|
|
99
|
-
return true
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
103
|
-
fun destroyInstance(): Boolean {
|
|
104
|
-
cvr?.removeAllResultReceivers()
|
|
105
|
-
ifStopCapturing = true
|
|
106
|
-
cvr?.stopCapturing()
|
|
107
|
-
try {
|
|
108
|
-
cvr?.input = null
|
|
109
|
-
} catch (_: Exception) {}
|
|
110
|
-
cvr = null
|
|
111
|
-
return true
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
@ReactMethod
|
|
115
|
-
fun continueCRR() {
|
|
116
|
-
continueCRR = true
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
@ReactMethod
|
|
120
|
-
fun addListener(type: String?) {
|
|
121
|
-
crrRemoved = false
|
|
122
|
-
crrMap[type]?.let { cvr?.addResultReceiver(it) }
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
@ReactMethod
|
|
126
|
-
fun removeListeners(count: Int) {
|
|
127
|
-
//keep
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
@ReactMethod
|
|
131
|
-
fun removeListener(type: String?) {
|
|
132
|
-
crrMap[type]?.let { cvr?.removeResultReceiver(it) }
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
@ReactMethod
|
|
136
|
-
fun removeAllResultListeners() {
|
|
137
|
-
crrRemoved = true
|
|
138
|
-
crrMap.forEach {
|
|
139
|
-
cvr?.removeResultReceiver(it.value)
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
@ReactMethod
|
|
144
|
-
fun addFilter(filterId: String?) {
|
|
145
|
-
cvr?.addResultFilter(filterMap[filterId])
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
@ReactMethod
|
|
149
|
-
fun removeFilter(filterId: String?) {
|
|
150
|
-
cvr?.removeResultFilter(filterMap[filterId])
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
@ReactMethod
|
|
154
|
-
fun startCapturing(template: String, promise: Promise) {
|
|
155
|
-
ifStopCapturing = false
|
|
156
|
-
cvr?.startCapturing(template, object : CompletionListener {
|
|
157
|
-
override fun onSuccess() {
|
|
158
|
-
Log.i(TAG, "onSuccess: startCapturing($template)")
|
|
159
|
-
promise.resolve(null)
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
override fun onFailure(errorCode: Int, errorString: String?) {
|
|
163
|
-
Log.e(TAG, "onFailure: startCapturing($template). ErrorCode: $errorCode. ErrorString: $errorString")
|
|
164
|
-
promise.reject(errorCode.toString(), errorString)
|
|
165
|
-
}
|
|
166
|
-
})
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
@ReactMethod
|
|
170
|
-
fun stopCapturing(promise: Promise) {
|
|
171
|
-
ifStopCapturing = true
|
|
172
|
-
cvr?.stopCapturing()
|
|
173
|
-
promise.resolve(null)
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
@ReactMethod
|
|
177
|
-
fun setInput(inputId: String) {
|
|
178
|
-
ImageSourceAdapterModuleImpl.mapISA[inputId]?.apply { cvr?.input = this }
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
@ReactMethod
|
|
182
|
-
fun resetSettings(promise: Promise) {
|
|
183
|
-
try {
|
|
184
|
-
cvr?.resetSettings()
|
|
185
|
-
promise.resolve(true)
|
|
186
|
-
} catch (e: CaptureVisionRouterException) {
|
|
187
|
-
promise.reject(e.errorCode.toString(), e.message)
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
@ReactMethod
|
|
192
|
-
fun getSimplifiedSettings(template: String, promise: Promise) {
|
|
193
|
-
try {
|
|
194
|
-
promise.resolve(cvr?.getSimplifiedSettings(template)?.toWritableMap())
|
|
195
|
-
} catch (e: CaptureVisionRouterException) {
|
|
196
|
-
promise.reject(e.errorCode.toString(), e.message)
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
@ReactMethod
|
|
201
|
-
fun updateSettings(settings: ReadableMap, template: String, promise: Promise) {
|
|
202
|
-
try {
|
|
203
|
-
cvr?.getSimplifiedSettings(template)?.apply {
|
|
204
|
-
updateFromReadableMap(settings)
|
|
205
|
-
cvr?.updateSettings(template, this)
|
|
206
|
-
}
|
|
207
|
-
promise.resolve(null)
|
|
208
|
-
} catch (e: CaptureVisionRouterException) {
|
|
209
|
-
promise.reject(e.errorCode.toString(), e.message)
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
@ReactMethod
|
|
214
|
-
fun initSettings(content: String, promise: Promise) {
|
|
215
|
-
try {
|
|
216
|
-
cvr?.initSettings(content)
|
|
217
|
-
promise.resolve(null)
|
|
218
|
-
} catch (e: CaptureVisionRouterException) {
|
|
219
|
-
promise.reject(e.errorCode.toString(), e.message)
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
@ReactMethod
|
|
224
|
-
fun initSettingsFromFile(path: String, promise: Promise) {
|
|
225
|
-
try {
|
|
226
|
-
cvr?.initSettingsFromFile(path)
|
|
227
|
-
promise.resolve(null)
|
|
228
|
-
} catch (e: CaptureVisionRouterException) {
|
|
229
|
-
promise.reject(e.errorCode.toString(), e.message)
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
@ReactMethod
|
|
234
|
-
fun outputSettingsToFile(template: String, path: String, includeDefaultValues: Boolean, promise: Promise) {
|
|
235
|
-
try {
|
|
236
|
-
cvr?.outputSettingsToFile(template, path, includeDefaultValues)
|
|
237
|
-
promise.resolve(null)
|
|
238
|
-
} catch (e: CaptureVisionRouterException) {
|
|
239
|
-
promise.reject(e.errorCode.toString(), e.message)
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
@ReactMethod
|
|
244
|
-
fun outputSettings(template: String, includeDefaultValues: Boolean, promise: Promise) {
|
|
245
|
-
try {
|
|
246
|
-
promise.resolve(cvr?.outputSettings(template, includeDefaultValues))
|
|
247
|
-
} catch (e: CaptureVisionRouterException) {
|
|
248
|
-
promise.reject(e.errorCode.toString(), e.message)
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
@ReactMethod
|
|
253
|
-
fun switchCapturingTemplate(template: String, promise: Promise) {
|
|
254
|
-
try {
|
|
255
|
-
cvr?.switchCapturingTemplate(template)
|
|
256
|
-
promise.resolve(null)
|
|
257
|
-
} catch (e: CaptureVisionRouterException) {
|
|
258
|
-
promise.reject(e.errorCode.toString(), e.message)
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
@ReactMethod
|
|
263
|
-
fun clearDLModelBuffers() {
|
|
264
|
-
CaptureVisionRouter.clearDLModelBuffers()
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
@ReactMethod
|
|
268
|
-
fun setGlobalIntraOpNumThreads(intraOpNumThreads: Int) {
|
|
269
|
-
CaptureVisionRouter.setGlobalIntraOpNumThreads(intraOpNumThreads)
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
273
|
-
fun install(): Boolean {
|
|
274
|
-
reactContext.javaScriptContextHolder?.apply {
|
|
275
|
-
nativeInstall(this.get())
|
|
276
|
-
}
|
|
277
|
-
return true
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
//@Native
|
|
281
|
-
private fun captureImageDataCalledInJSI(imageData: ImageData, template: String): CapturedResult {
|
|
282
|
-
return cvr?.capture(imageData, template) ?: CapturedResult()
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
//@Native
|
|
286
|
-
private fun captureFileCalledInJSI(filePath: String, template: String): CapturedResult {
|
|
287
|
-
return cvr?.capture(filePath, template) ?: CapturedResult()
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
//@Native
|
|
291
|
-
private fun captureFileBytesCalledInJSI(fileBytes: ByteArray, template: String): CapturedResult {
|
|
292
|
-
return cvr?.capture(fileBytes, template) ?: CapturedResult()
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
//@Native
|
|
296
|
-
private fun getOriginalImageCalledInJSI(imageHashId: String): ImageData {
|
|
297
|
-
var originalImage = cvr?.intermediateResultManager?.getOriginalImage(imageHashId)
|
|
298
|
-
if (originalImage == null) {
|
|
299
|
-
originalImage = ImageData()
|
|
300
|
-
originalImage.bytes = ByteArray(0)
|
|
301
|
-
}
|
|
302
|
-
return originalImage
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
private external fun nativeInstall(jsiPtr: Long)
|
|
306
|
-
}
|
|
1
|
+
package com.dynamsoft.reactnativelib.cvr
|
|
2
|
+
|
|
3
|
+
import android.util.Log
|
|
4
|
+
import com.dynamsoft.core.basic_structures.CompletionListener
|
|
5
|
+
import com.dynamsoft.core.basic_structures.EnumCapturedResultItemType
|
|
6
|
+
import com.dynamsoft.core.basic_structures.ImageData
|
|
7
|
+
import com.dynamsoft.cvr.*
|
|
8
|
+
import com.dynamsoft.dbr.DecodedBarcodesResult
|
|
9
|
+
import com.dynamsoft.dcp.ParsedResult
|
|
10
|
+
import com.dynamsoft.ddn.DeskewedImageResultItem
|
|
11
|
+
import com.dynamsoft.ddn.EnhancedImageResultItem
|
|
12
|
+
import com.dynamsoft.ddn.ProcessedDocumentResult
|
|
13
|
+
import com.dynamsoft.dlr.RecognizedTextLinesResult
|
|
14
|
+
import com.dynamsoft.reactnativelib.basicutils.toWritableMap
|
|
15
|
+
import com.dynamsoft.reactnativelib.core.ImageSourceAdapterModuleImpl
|
|
16
|
+
import com.dynamsoft.reactnativelib.basicutils.updateFromReadableMap
|
|
17
|
+
import com.facebook.react.bridge.*
|
|
18
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter
|
|
19
|
+
import kotlinx.coroutines.delay
|
|
20
|
+
import kotlinx.coroutines.runBlocking
|
|
21
|
+
|
|
22
|
+
private const val onCapturedResultReceived_Event = "onCapturedResultReceived"
|
|
23
|
+
private const val onDecodedBarcodesReceived_Event = "onDecodedBarcodesReceived"
|
|
24
|
+
private const val onProcessedDocumentResultReceived_Event = "onProcessedDocumentResultReceived"
|
|
25
|
+
private const val onRecognizedTextLinesReceived_Event = "onRecognizedTextLinesReceived"
|
|
26
|
+
private const val onParsedResultsReceived_Event = "onParsedResultsReceived"
|
|
27
|
+
private const val TAG = "CvrModule"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
val filterMap = hashMapOf<String, CapturedResultFilter>()
|
|
31
|
+
|
|
32
|
+
class CaptureVisionRouterModuleImpl(private val reactContext: ReactApplicationContext) {
|
|
33
|
+
companion object {
|
|
34
|
+
const val NAME = "DynamsoftCaptureVisionRouterModule"
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private var ifStopCapturing = false
|
|
38
|
+
private var currentDeskewedImages: Array<ImageData>? = null
|
|
39
|
+
private var currentEnhancedImages: Array<ImageData>? = null
|
|
40
|
+
private var cvr: CaptureVisionRouter? = null
|
|
41
|
+
private val emitter by lazy { reactContext.getJSModule(RCTDeviceEventEmitter::class.java) }
|
|
42
|
+
|
|
43
|
+
private var continueCRR = false
|
|
44
|
+
private var crrRemoved = false
|
|
45
|
+
private val crrMap by lazy {
|
|
46
|
+
mapOf(
|
|
47
|
+
onCapturedResultReceived_Event to object : CapturedResultReceiver {
|
|
48
|
+
override fun onCapturedResultReceived(result: CapturedResult) {
|
|
49
|
+
currentDeskewedImages =
|
|
50
|
+
result.items.filter { it.type == EnumCapturedResultItemType.CRIT_DESKEWED_IMAGE }
|
|
51
|
+
.map { (it as DeskewedImageResultItem).imageData }.toTypedArray()
|
|
52
|
+
currentEnhancedImages =
|
|
53
|
+
result.items.filter { it.type == EnumCapturedResultItemType.CRIT_ENHANCED_IMAGE }
|
|
54
|
+
.map { (it as EnhancedImageResultItem).imageData }.toTypedArray()
|
|
55
|
+
emitResultAndWaitForResponse(onCapturedResultReceived_Event, result.toWritableMap())
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
onDecodedBarcodesReceived_Event to object : CapturedResultReceiver {
|
|
59
|
+
override fun onDecodedBarcodesReceived(result: DecodedBarcodesResult) {
|
|
60
|
+
emitResultAndWaitForResponse(onDecodedBarcodesReceived_Event, result.toWritableMap())
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
onProcessedDocumentResultReceived_Event to object : CapturedResultReceiver {
|
|
64
|
+
override fun onProcessedDocumentResultReceived(result: ProcessedDocumentResult) {
|
|
65
|
+
currentDeskewedImages = result.deskewedImageResultItems.map { (it as DeskewedImageResultItem).imageData }.toTypedArray()
|
|
66
|
+
currentEnhancedImages = result.enhancedImageResultItems.map { (it as EnhancedImageResultItem).imageData }.toTypedArray()
|
|
67
|
+
emitResultAndWaitForResponse(onProcessedDocumentResultReceived_Event, result.toWritableMap())
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
onRecognizedTextLinesReceived_Event to object : CapturedResultReceiver {
|
|
71
|
+
override fun onRecognizedTextLinesReceived(result: RecognizedTextLinesResult) {
|
|
72
|
+
emitResultAndWaitForResponse(onRecognizedTextLinesReceived_Event, result.toWritableMap())
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
onParsedResultsReceived_Event to object : CapturedResultReceiver {
|
|
76
|
+
override fun onParsedResultsReceived(result: ParsedResult) {
|
|
77
|
+
emitResultAndWaitForResponse(onParsedResultsReceived_Event, result.toWritableMap())
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
private fun emitResultAndWaitForResponse(eventKey: String, result: WritableMap) {
|
|
84
|
+
continueCRR = false
|
|
85
|
+
emitter.emit(eventKey, result)
|
|
86
|
+
while (!continueCRR && !crrRemoved && !ifStopCapturing) {
|
|
87
|
+
//waiting for js callback end
|
|
88
|
+
runBlocking {
|
|
89
|
+
delay(5)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
fun getName() = NAME
|
|
95
|
+
|
|
96
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
97
|
+
fun createInstance(): Boolean {
|
|
98
|
+
if(cvr == null) cvr = CaptureVisionRouter()
|
|
99
|
+
return true
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
103
|
+
fun destroyInstance(): Boolean {
|
|
104
|
+
cvr?.removeAllResultReceivers()
|
|
105
|
+
ifStopCapturing = true
|
|
106
|
+
cvr?.stopCapturing()
|
|
107
|
+
try {
|
|
108
|
+
cvr?.input = null
|
|
109
|
+
} catch (_: Exception) {}
|
|
110
|
+
cvr = null
|
|
111
|
+
return true
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
@ReactMethod
|
|
115
|
+
fun continueCRR() {
|
|
116
|
+
continueCRR = true
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
@ReactMethod
|
|
120
|
+
fun addListener(type: String?) {
|
|
121
|
+
crrRemoved = false
|
|
122
|
+
crrMap[type]?.let { cvr?.addResultReceiver(it) }
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
@ReactMethod
|
|
126
|
+
fun removeListeners(count: Int) {
|
|
127
|
+
//keep
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@ReactMethod
|
|
131
|
+
fun removeListener(type: String?) {
|
|
132
|
+
crrMap[type]?.let { cvr?.removeResultReceiver(it) }
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
@ReactMethod
|
|
136
|
+
fun removeAllResultListeners() {
|
|
137
|
+
crrRemoved = true
|
|
138
|
+
crrMap.forEach {
|
|
139
|
+
cvr?.removeResultReceiver(it.value)
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
@ReactMethod
|
|
144
|
+
fun addFilter(filterId: String?) {
|
|
145
|
+
cvr?.addResultFilter(filterMap[filterId])
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
@ReactMethod
|
|
149
|
+
fun removeFilter(filterId: String?) {
|
|
150
|
+
cvr?.removeResultFilter(filterMap[filterId])
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
@ReactMethod
|
|
154
|
+
fun startCapturing(template: String, promise: Promise) {
|
|
155
|
+
ifStopCapturing = false
|
|
156
|
+
cvr?.startCapturing(template, object : CompletionListener {
|
|
157
|
+
override fun onSuccess() {
|
|
158
|
+
Log.i(TAG, "onSuccess: startCapturing($template)")
|
|
159
|
+
promise.resolve(null)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
override fun onFailure(errorCode: Int, errorString: String?) {
|
|
163
|
+
Log.e(TAG, "onFailure: startCapturing($template). ErrorCode: $errorCode. ErrorString: $errorString")
|
|
164
|
+
promise.reject(errorCode.toString(), errorString)
|
|
165
|
+
}
|
|
166
|
+
})
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
@ReactMethod
|
|
170
|
+
fun stopCapturing(promise: Promise) {
|
|
171
|
+
ifStopCapturing = true
|
|
172
|
+
cvr?.stopCapturing()
|
|
173
|
+
promise.resolve(null)
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
@ReactMethod
|
|
177
|
+
fun setInput(inputId: String) {
|
|
178
|
+
ImageSourceAdapterModuleImpl.mapISA[inputId]?.apply { cvr?.input = this }
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
@ReactMethod
|
|
182
|
+
fun resetSettings(promise: Promise) {
|
|
183
|
+
try {
|
|
184
|
+
cvr?.resetSettings()
|
|
185
|
+
promise.resolve(true)
|
|
186
|
+
} catch (e: CaptureVisionRouterException) {
|
|
187
|
+
promise.reject(e.errorCode.toString(), e.message)
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
@ReactMethod
|
|
192
|
+
fun getSimplifiedSettings(template: String, promise: Promise) {
|
|
193
|
+
try {
|
|
194
|
+
promise.resolve(cvr?.getSimplifiedSettings(template)?.toWritableMap())
|
|
195
|
+
} catch (e: CaptureVisionRouterException) {
|
|
196
|
+
promise.reject(e.errorCode.toString(), e.message)
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
@ReactMethod
|
|
201
|
+
fun updateSettings(settings: ReadableMap, template: String, promise: Promise) {
|
|
202
|
+
try {
|
|
203
|
+
cvr?.getSimplifiedSettings(template)?.apply {
|
|
204
|
+
updateFromReadableMap(settings)
|
|
205
|
+
cvr?.updateSettings(template, this)
|
|
206
|
+
}
|
|
207
|
+
promise.resolve(null)
|
|
208
|
+
} catch (e: CaptureVisionRouterException) {
|
|
209
|
+
promise.reject(e.errorCode.toString(), e.message)
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
@ReactMethod
|
|
214
|
+
fun initSettings(content: String, promise: Promise) {
|
|
215
|
+
try {
|
|
216
|
+
cvr?.initSettings(content)
|
|
217
|
+
promise.resolve(null)
|
|
218
|
+
} catch (e: CaptureVisionRouterException) {
|
|
219
|
+
promise.reject(e.errorCode.toString(), e.message)
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
@ReactMethod
|
|
224
|
+
fun initSettingsFromFile(path: String, promise: Promise) {
|
|
225
|
+
try {
|
|
226
|
+
cvr?.initSettingsFromFile(path)
|
|
227
|
+
promise.resolve(null)
|
|
228
|
+
} catch (e: CaptureVisionRouterException) {
|
|
229
|
+
promise.reject(e.errorCode.toString(), e.message)
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
@ReactMethod
|
|
234
|
+
fun outputSettingsToFile(template: String, path: String, includeDefaultValues: Boolean, promise: Promise) {
|
|
235
|
+
try {
|
|
236
|
+
cvr?.outputSettingsToFile(template, path, includeDefaultValues)
|
|
237
|
+
promise.resolve(null)
|
|
238
|
+
} catch (e: CaptureVisionRouterException) {
|
|
239
|
+
promise.reject(e.errorCode.toString(), e.message)
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
@ReactMethod
|
|
244
|
+
fun outputSettings(template: String, includeDefaultValues: Boolean, promise: Promise) {
|
|
245
|
+
try {
|
|
246
|
+
promise.resolve(cvr?.outputSettings(template, includeDefaultValues))
|
|
247
|
+
} catch (e: CaptureVisionRouterException) {
|
|
248
|
+
promise.reject(e.errorCode.toString(), e.message)
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
@ReactMethod
|
|
253
|
+
fun switchCapturingTemplate(template: String, promise: Promise) {
|
|
254
|
+
try {
|
|
255
|
+
cvr?.switchCapturingTemplate(template)
|
|
256
|
+
promise.resolve(null)
|
|
257
|
+
} catch (e: CaptureVisionRouterException) {
|
|
258
|
+
promise.reject(e.errorCode.toString(), e.message)
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
@ReactMethod
|
|
263
|
+
fun clearDLModelBuffers() {
|
|
264
|
+
CaptureVisionRouter.clearDLModelBuffers()
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
@ReactMethod
|
|
268
|
+
fun setGlobalIntraOpNumThreads(intraOpNumThreads: Int) {
|
|
269
|
+
CaptureVisionRouter.setGlobalIntraOpNumThreads(intraOpNumThreads)
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
273
|
+
fun install(): Boolean {
|
|
274
|
+
reactContext.javaScriptContextHolder?.apply {
|
|
275
|
+
nativeInstall(this.get())
|
|
276
|
+
}
|
|
277
|
+
return true
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
//@Native
|
|
281
|
+
private fun captureImageDataCalledInJSI(imageData: ImageData, template: String): CapturedResult {
|
|
282
|
+
return cvr?.capture(imageData, template) ?: CapturedResult()
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
//@Native
|
|
286
|
+
private fun captureFileCalledInJSI(filePath: String, template: String): CapturedResult {
|
|
287
|
+
return cvr?.capture(filePath, template) ?: CapturedResult()
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
//@Native
|
|
291
|
+
private fun captureFileBytesCalledInJSI(fileBytes: ByteArray, template: String): CapturedResult {
|
|
292
|
+
return cvr?.capture(fileBytes, template) ?: CapturedResult()
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
//@Native
|
|
296
|
+
private fun getOriginalImageCalledInJSI(imageHashId: String): ImageData {
|
|
297
|
+
var originalImage = cvr?.intermediateResultManager?.getOriginalImage(imageHashId)
|
|
298
|
+
if (originalImage == null) {
|
|
299
|
+
originalImage = ImageData()
|
|
300
|
+
originalImage.bytes = ByteArray(0)
|
|
301
|
+
}
|
|
302
|
+
return originalImage
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
private external fun nativeInstall(jsiPtr: Long)
|
|
306
|
+
}
|