dynamsoft-capture-vision-react-native 3.0.5201 → 3.2.5000
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/README.md +5 -2
- package/android/build.gradle +4 -6
- package/android/gradle.properties +3 -3
- package/android/src/main/cpp/JsiCore.cpp +1 -1
- package/android/src/main/cpp/JsiDbr.cpp +208 -23
- package/android/src/main/cpp/JsiDcp.cpp +1 -1
- package/android/src/main/cpp/JsiDlr.cpp +10 -1
- package/android/src/main/cpp/JsiUtility.cpp +470 -62
- package/android/src/main/cpp/JsiUtility.h +13 -3
- 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/java/com/dynamsoft/reactnativelib/CVRModule.kt +17 -2
- package/android/src/main/java/com/dynamsoft/reactnativelib/CameraViewManager.kt +13 -1
- package/android/src/main/java/com/dynamsoft/reactnativelib/ImageEditorViewManager.kt +1 -1
- package/android/src/main/java/com/dynamsoft/reactnativelib/{utils → basicutils}/Basic.kt +1 -1
- package/android/src/main/java/com/dynamsoft/reactnativelib/{utils → basicutils}/ForCore.kt +1 -2
- package/android/src/main/java/com/dynamsoft/reactnativelib/{utils → basicutils}/ForCvr.kt +1 -5
- package/android/src/main/java/com/dynamsoft/reactnativelib/{utils → basicutils}/ForDBR.kt +74 -3
- package/android/src/main/java/com/dynamsoft/reactnativelib/{utils → basicutils}/ForDCE.kt +33 -13
- package/android/src/main/java/com/dynamsoft/reactnativelib/{utils → basicutils}/ForDCP.kt +1 -1
- package/android/src/main/java/com/dynamsoft/reactnativelib/{utils → basicutils}/ForDDN.kt +1 -3
- package/android/src/main/java/com/dynamsoft/reactnativelib/{utils → basicutils}/ForDLR.kt +6 -3
- package/android/src/main/java/com/dynamsoft/reactnativelib/{utils → basicutils}/ImageUtil.kt +2 -2
- package/android/src/main/java/com/dynamsoft/reactnativelib/cvr/CaptureVisionRouterModuleImpl.kt +25 -5
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/CameraEnhancerModuleImpl.kt +6 -3
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/CameraViewManagerImpl.kt +15 -3
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/ImageEditorViewManagerImpl.kt +1 -5
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/ImageEditorViewModuleImpl.kt +2 -4
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/RNCameraView.kt +1 -2
- package/android/src/main/java/com/dynamsoft/reactnativelib/utility/ImageManagerModuleImpl.kt +75 -3
- package/android/src/main/java/com/dynamsoft/reactnativelib/utility/MultiCrossFilterModuleImpl.kt +2 -2
- package/dynamsoft-capture-vision-react-native.podspec +1 -1
- package/ios/CPP/ImageDataHostObject.cpp +1 -1
- package/ios/CPP/ImageDataHostObject.hpp +1 -1
- package/ios/CPP/RNDynamsoft+JSI.h +3 -0
- package/ios/CPP/RNDynamsoft+JSI.mm +119 -2
- package/ios/CPP/RNDynamsoft+Json.m +114 -14
- package/ios/CPP/YeetJSIUtils.h +2 -0
- package/ios/CPP/YeetJSIUtils.mm +15 -0
- package/ios/RNDynamsoftCameraView.h +4 -0
- package/ios/RNDynamsoftCameraView.m +25 -0
- package/ios/RNDynamsoftCameraViewManager.m +8 -2
- package/ios/RNDynamsoftCaptureVisionRouter.mm +149 -92
- package/ios/RNDynamsoftImageEditorViewManager.mm +71 -40
- package/ios/RNDynamsoftImageManager.mm +295 -81
- package/ios/RNDynamsoftImageSourceAdapter.mm +100 -65
- package/package.json +1 -1
- package/src/core/EnumGrayscaleEnhancementMode.tsx +1 -0
- package/src/core/EnumGrayscaleTransformationMode.tsx +1 -0
- package/src/core/EnumImageFileFormat.tsx +6 -0
- package/src/core/index.tsx +1 -0
- package/src/cvr/CaptureVisionRouter.tsx +33 -5
- package/src/dbr/BarcodeDetails.tsx +51 -0
- package/src/dbr/BarcodeResultItem.tsx +11 -0
- package/src/dbr/EnumBarcodeFormat.tsx +2 -0
- package/src/dbr/EnumDeblurMode.tsx +1 -0
- package/src/dbr/EnumLocalizationMode.tsx +1 -0
- package/src/dbr/EnumQRCodeErrorCorrectionLevel.tsx +6 -0
- package/src/dbr/index.tsx +2 -0
- package/src/dce/CameraEnhancer.tsx +14 -6
- package/src/dce/CameraView.tsx +10 -2
- package/src/dce/DynamsoftCameraViewNativeComponent.ts +25 -0
- package/src/dce/EnumCameraPosition.tsx +13 -1
- package/src/dce/EnumEnhancedFeatures.tsx +3 -4
- package/src/dce/ImageEditorView.tsx +1 -1
- package/src/dlr/CharacterResult.tsx +4 -1
- package/src/dlr/SimplifiedLabelRecognizerSettings.tsx +2 -0
- package/src/dlr/TextLineResultItem.tsx +5 -0
- package/src/utility/EnumFilterType.tsx +5 -0
- package/src/utility/ImageManager.tsx +227 -9
- package/src/utility/index.tsx +1 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
package com.dynamsoft.reactnativelib
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import com.dynamsoft.cvr.CaptureVisionRouter
|
|
4
|
+
import com.dynamsoft.cvr.CaptureVisionRouterException
|
|
4
5
|
import com.dynamsoft.reactnativelib.cvr.CaptureVisionRouterModuleImpl
|
|
5
|
-
import com.facebook.react.bridge.Arguments
|
|
6
6
|
import com.facebook.react.bridge.Promise
|
|
7
7
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
8
8
|
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
@@ -110,5 +110,20 @@ class CVRModule(reactApplicationContext: ReactApplicationContext) : ReactContext
|
|
|
110
110
|
impl.removeListener(type)
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
+
@ReactMethod
|
|
114
|
+
fun switchCapturingTemplate(template: String, promise: Promise) {
|
|
115
|
+
impl.switchCapturingTemplate(template, promise)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@ReactMethod
|
|
119
|
+
fun clearDLModelBuffers() {
|
|
120
|
+
impl.clearDLModelBuffers()
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
@ReactMethod
|
|
124
|
+
fun setGlobalIntraOpNumThreads(intraOpNumThreads: Int) {
|
|
125
|
+
impl.setGlobalIntraOpNumThreads(intraOpNumThreads)
|
|
126
|
+
}
|
|
127
|
+
|
|
113
128
|
|
|
114
129
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
package com.dynamsoft.reactnativelib
|
|
2
2
|
|
|
3
3
|
import com.dynamsoft.dce.CameraView
|
|
4
|
-
import com.dynamsoft.
|
|
4
|
+
import com.dynamsoft.reactnativelib.basicutils.setCameraToggleButtonState
|
|
5
|
+
import com.dynamsoft.reactnativelib.basicutils.toCameraToggleButtonState
|
|
6
|
+
import com.dynamsoft.reactnativelib.dce.CameraViewManagerImpl
|
|
5
7
|
import com.facebook.react.bridge.ReadableArray
|
|
6
8
|
import com.facebook.react.bridge.ReadableMap
|
|
7
9
|
import com.facebook.react.uimanager.SimpleViewManager
|
|
@@ -47,4 +49,14 @@ class CameraViewManager : SimpleViewManager<CameraView>() {
|
|
|
47
49
|
view?.let { impl.setTorchButtonVisible(it, value) }
|
|
48
50
|
}
|
|
49
51
|
|
|
52
|
+
@ReactProp(name = "cameraToggleButton")
|
|
53
|
+
fun setCameraToggleButton(view: CameraView, cameraToggleButton: ReadableMap) {
|
|
54
|
+
view.setCameraToggleButtonState(cameraToggleButton.toCameraToggleButtonState())
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@ReactProp(name = "cameraToggleButtonVisible")
|
|
58
|
+
fun setCameraToggleButtonVisible(view: CameraView, isVisible: Boolean) {
|
|
59
|
+
view.cameraToggleButtonVisible = isVisible
|
|
60
|
+
}
|
|
61
|
+
|
|
50
62
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
package com.dynamsoft.reactnativelib
|
|
2
2
|
|
|
3
3
|
import com.dynamsoft.dce.ImageEditorView
|
|
4
|
-
import com.dynamsoft.
|
|
4
|
+
import com.dynamsoft.reactnativelib.dce.ImageEditorViewManagerImpl
|
|
5
5
|
import com.facebook.react.uimanager.SimpleViewManager
|
|
6
6
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
7
7
|
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
package com.dynamsoft.
|
|
1
|
+
package com.dynamsoft.reactnativelib.basicutils
|
|
2
2
|
|
|
3
3
|
import android.graphics.Point
|
|
4
4
|
import com.dynamsoft.core.basic_structures.CapturedResultBase
|
|
5
5
|
import com.dynamsoft.core.basic_structures.CapturedResultItem
|
|
6
6
|
import com.dynamsoft.core.basic_structures.Quadrilateral
|
|
7
|
-
import com.dynamsoft.reactnativelib.utils.toWritableArray
|
|
8
7
|
import com.facebook.react.bridge.Arguments
|
|
9
8
|
import com.facebook.react.bridge.ReadableMap
|
|
10
9
|
import com.facebook.react.bridge.WritableArray
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
package com.dynamsoft.reactnativelib.
|
|
1
|
+
package com.dynamsoft.reactnativelib.basicutils
|
|
2
2
|
|
|
3
3
|
import android.util.Log
|
|
4
4
|
import com.dynamsoft.core.basic_structures.CapturedResultItem
|
|
@@ -13,10 +13,6 @@ import com.dynamsoft.ddn.DeskewedImageResultItem
|
|
|
13
13
|
import com.dynamsoft.ddn.DetectedQuadResultItem
|
|
14
14
|
import com.dynamsoft.ddn.EnhancedImageResultItem
|
|
15
15
|
import com.dynamsoft.dlr.TextLineResultItem
|
|
16
|
-
import com.dynamsoft.reactnative.basicutils.toQuad
|
|
17
|
-
import com.dynamsoft.reactnative.basicutils.toWritableArray
|
|
18
|
-
import com.dynamsoft.reactnative.basicutils.toWritableMap
|
|
19
|
-
import com.dynamsoft.reactnative.basicutils.updateFromReadableMap
|
|
20
16
|
import com.facebook.react.bridge.Arguments
|
|
21
17
|
import com.facebook.react.bridge.ReadableMap
|
|
22
18
|
import com.facebook.react.bridge.WritableArray
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
package com.dynamsoft.
|
|
1
|
+
package com.dynamsoft.reactnativelib.basicutils
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
import com.dynamsoft.core.basic_structures.CapturedResultItem
|
|
5
|
+
import com.dynamsoft.dbr.AztecDetails
|
|
6
|
+
import com.dynamsoft.dbr.BarcodeDetails
|
|
5
7
|
import com.dynamsoft.dbr.BarcodeResultItem
|
|
8
|
+
import com.dynamsoft.dbr.DataMatrixDetails
|
|
6
9
|
import com.dynamsoft.dbr.DecodedBarcodesResult
|
|
10
|
+
import com.dynamsoft.dbr.OneDCodeDetails
|
|
11
|
+
import com.dynamsoft.dbr.PDF417Details
|
|
12
|
+
import com.dynamsoft.dbr.QRCodeDetails
|
|
7
13
|
import com.dynamsoft.dbr.SimplifiedBarcodeReaderSettings
|
|
8
|
-
import com.dynamsoft.reactnativelib.utils.toIntArray
|
|
9
|
-
import com.dynamsoft.reactnativelib.utils.toWritableArray
|
|
10
14
|
import com.facebook.react.bridge.Arguments
|
|
11
15
|
import com.facebook.react.bridge.ReadableMap
|
|
12
16
|
import com.facebook.react.bridge.WritableArray
|
|
@@ -25,6 +29,14 @@ fun BarcodeResultItem.toWritableMap(): WritableMap = Arguments.createMap().apply
|
|
|
25
29
|
putInt("moduleSize", moduleSize)
|
|
26
30
|
putBoolean("isMirrored", isMirrored)
|
|
27
31
|
putBoolean("isDPM", isDPM)
|
|
32
|
+
when (details) {
|
|
33
|
+
is QRCodeDetails -> putMap("qrCodeDetails", details.toWritableMap())
|
|
34
|
+
is AztecDetails -> putMap("aztecDetails", details.toWritableMap())
|
|
35
|
+
is OneDCodeDetails -> putMap("oneDCodeDetails", details.toWritableMap())
|
|
36
|
+
is DataMatrixDetails -> putMap("dataMatrixDetails", details.toWritableMap())
|
|
37
|
+
is PDF417Details -> putMap("pdf417Details", details.toWritableMap())
|
|
38
|
+
else -> Unit
|
|
39
|
+
}
|
|
28
40
|
}
|
|
29
41
|
|
|
30
42
|
fun Array<out BarcodeResultItem>.toWritableArray(): WritableArray = Arguments.createArray().apply {
|
|
@@ -63,9 +75,68 @@ fun SimplifiedBarcodeReaderSettings.updateFromReadableMap(newSettings: ReadableM
|
|
|
63
75
|
if (newSettings.hasKey("minBarcodeTextLength")) minBarcodeTextLength = newSettings.getInt("minBarcodeTextLength")
|
|
64
76
|
if (newSettings.hasKey("barcodeTextRegExPattern"))
|
|
65
77
|
barcodeTextRegExPattern = newSettings.getString("barcodeTextRegExPattern")
|
|
78
|
+
if (newSettings.hasKey("localizationModes"))
|
|
79
|
+
localizationModes = newSettings.getArray("localizationModes")?.toIntArray()
|
|
80
|
+
if (newSettings.hasKey("deblurModes"))
|
|
81
|
+
deblurModes = newSettings.getArray("deblurModes")?.toIntArray()
|
|
66
82
|
if (newSettings.hasKey("grayscaleTransformationModes"))
|
|
67
83
|
grayscaleTransformationModes = newSettings.getArray("grayscaleTransformationModes")?.toIntArray()
|
|
68
84
|
if (newSettings.hasKey("grayscaleEnhancementModes"))
|
|
69
85
|
grayscaleEnhancementModes = newSettings.getArray("grayscaleEnhancementModes")?.toIntArray()
|
|
70
86
|
if (newSettings.hasKey("scaleDownThreshold")) scaleDownThreshold = newSettings.getInt("scaleDownThreshold")
|
|
87
|
+
maxThreadsInOneTask = if (newSettings.hasKey("maxThreadsInOneTask")) newSettings.getInt("maxThreadsInOneTask") else maxThreadsInOneTask
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
fun BarcodeDetails.toWritableMap(): WritableMap = Arguments.createMap().apply {
|
|
91
|
+
when (this) {
|
|
92
|
+
is QRCodeDetails -> {
|
|
93
|
+
putInt("columns", columns)
|
|
94
|
+
putInt("errorCorrectionLevel", errorCorrectionLevel)
|
|
95
|
+
putInt("version", version)
|
|
96
|
+
putInt("model", model)
|
|
97
|
+
putInt("mode", mode)
|
|
98
|
+
putInt("page", page)
|
|
99
|
+
putInt("totalPage", totalPage)
|
|
100
|
+
putInt("parityData", parityData.toInt())
|
|
101
|
+
putInt("dataMaskPattern", dataMaskPattern)
|
|
102
|
+
putArray("codewords", Arguments.fromArray(codewords))
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
is AztecDetails -> {
|
|
106
|
+
putInt("rows", rows)
|
|
107
|
+
putInt("columns", columns)
|
|
108
|
+
putInt("layerNumber", layerNumber)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
is OneDCodeDetails -> {
|
|
112
|
+
putArray("startCharsBytes", Arguments.fromArray(startCharsBytes))
|
|
113
|
+
putArray("stopCharsBytes", Arguments.fromArray(stopCharsBytes))
|
|
114
|
+
putArray("checkDigitBytes", Arguments.fromArray(checkDigitBytes))
|
|
115
|
+
putDouble("startPatternRange_lower", startPatternRange.lower.toDouble())
|
|
116
|
+
putDouble("middlePatternRange_lower", middlePatternRange.lower.toDouble())
|
|
117
|
+
putDouble("endPatternRange_lower", endPatternRange.lower.toDouble())
|
|
118
|
+
putDouble("startPatternRange_upper", startPatternRange.upper.toDouble())
|
|
119
|
+
putDouble("middlePatternRange_upper", middlePatternRange.upper.toDouble())
|
|
120
|
+
putDouble("endPatternRange_upper", endPatternRange.upper.toDouble())
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
is DataMatrixDetails -> {
|
|
124
|
+
putInt("rows", rows)
|
|
125
|
+
putInt("columns", columns)
|
|
126
|
+
putInt("dataRegionRows", dataRegionRows)
|
|
127
|
+
putInt("dataRegionColumns", dataRegionColumns)
|
|
128
|
+
putInt("dataRegionNumber", dataRegionNumber)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
is PDF417Details -> {
|
|
132
|
+
putInt("rows", rows)
|
|
133
|
+
putInt("columns", columns)
|
|
134
|
+
putInt("errorCorrectionLevel", errorCorrectionLevel)
|
|
135
|
+
putBoolean("hasLeftRowIndicator", hasLeftRowIndicator())
|
|
136
|
+
putBoolean("hasRightRowIndicator", hasRightRowIndicator())
|
|
137
|
+
putArray("codewords", Arguments.fromArray(codewords))
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
else -> Unit
|
|
141
|
+
}
|
|
71
142
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
package com.dynamsoft.reactnativelib.
|
|
1
|
+
package com.dynamsoft.reactnativelib.basicutils
|
|
2
2
|
|
|
3
3
|
import android.content.Context
|
|
4
4
|
import android.graphics.Point
|
|
@@ -7,7 +7,6 @@ import android.graphics.drawable.Drawable
|
|
|
7
7
|
import androidx.appcompat.content.res.AppCompatResources
|
|
8
8
|
import com.dynamsoft.core.basic_structures.DSRect
|
|
9
9
|
import com.dynamsoft.dce.CameraView
|
|
10
|
-
import com.dynamsoft.reactnative.basicutils.base64ToDrawable
|
|
11
10
|
import com.facebook.react.bridge.Arguments
|
|
12
11
|
import com.facebook.react.bridge.ReadableMap
|
|
13
12
|
import com.facebook.react.bridge.ReadableType
|
|
@@ -44,27 +43,44 @@ fun DSRect.toWritableMap(): WritableMap = Arguments.createMap().apply {
|
|
|
44
43
|
putBoolean("measuredInPercentage", this@toWritableMap.measuredInPercentage)
|
|
45
44
|
}
|
|
46
45
|
|
|
47
|
-
fun ReadableMap.toTorchButtonState():
|
|
46
|
+
fun ReadableMap.toTorchButtonState(): CameraViewButtonState {
|
|
48
47
|
val rect = if (hasKey("location")) getMap("location")!!.toRect() else Rect(25,100,70,145)
|
|
49
|
-
val visible = if (hasKey("visible")) getBoolean("visible") else
|
|
48
|
+
val visible = if (hasKey("visible")) getBoolean("visible") else null
|
|
50
49
|
val torchOnImageBase64 = if (hasKey("torchOnImageBase64")) getString("torchOnImageBase64") else null
|
|
51
50
|
val torchOffImageBase64 = if (hasKey("torchOffImageBase64")) getString("torchOffImageBase64") else null
|
|
52
|
-
return
|
|
51
|
+
return CameraViewButtonState(rect, visible, torchOnImageBase64, torchOffImageBase64)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
fun ReadableMap.toCameraToggleButtonState(): CameraViewButtonState {
|
|
55
|
+
val rect = if (hasKey("location")) getMap("location")!!.toRect() else Rect(25,100,70,145)
|
|
56
|
+
val visible = if (hasKey("visible")) getBoolean("visible") else false
|
|
57
|
+
val cameraImageBase64 = if (hasKey("cameraToggleImageBase64")) getString("cameraToggleImageBase64") else null
|
|
58
|
+
return CameraViewButtonState(rect, visible, cameraBase64 = cameraImageBase64)
|
|
53
59
|
}
|
|
54
60
|
|
|
55
|
-
fun CameraView.setTorchButtonState(torchButtonState:
|
|
61
|
+
fun CameraView.setTorchButtonState(torchButtonState: CameraViewButtonState) {
|
|
56
62
|
setTorchButton(
|
|
57
63
|
torchButtonState.getLeftTopPoint(), torchButtonState.getWidth(), torchButtonState.getHeight(),
|
|
58
64
|
torchButtonState.getTouchOnDrawable(context), torchButtonState.getTouchOffDrawable(context)
|
|
59
65
|
)
|
|
60
|
-
|
|
66
|
+
torchButtonState.visible?.apply {
|
|
67
|
+
torchButtonVisible = this
|
|
68
|
+
}
|
|
61
69
|
}
|
|
62
70
|
|
|
63
|
-
|
|
71
|
+
fun CameraView.setCameraToggleButtonState(cameraToggleButtonState: CameraViewButtonState) {
|
|
72
|
+
setCameraToggleButton(
|
|
73
|
+
cameraToggleButtonState.getLeftTopPoint(), cameraToggleButtonState.getWidth(), cameraToggleButtonState.getHeight(),
|
|
74
|
+
cameraToggleButtonState.getCameraToggleDrawable(context)
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
class CameraViewButtonState(
|
|
64
79
|
val location: Rect,
|
|
65
|
-
val visible: Boolean,
|
|
80
|
+
val visible: Boolean? = null,
|
|
66
81
|
val touchOnBase64: String? = null,
|
|
67
|
-
val touchOffBase64: String? = null
|
|
82
|
+
val touchOffBase64: String? = null,
|
|
83
|
+
val cameraBase64: String? = null,
|
|
68
84
|
) {
|
|
69
85
|
fun getLeftTopPoint() = Point(location.left, location.top)
|
|
70
86
|
fun getWidth() = location.width()
|
|
@@ -73,18 +89,22 @@ class TorchButtonState(
|
|
|
73
89
|
fun getTouchOnDrawable(context: Context): Drawable {
|
|
74
90
|
return base64ToDrawable(touchOnBase64, context.resources!!) ?: AppCompatResources.getDrawable(
|
|
75
91
|
context,
|
|
76
|
-
com.dynamsoft.R.drawable.
|
|
92
|
+
com.dynamsoft.R.drawable.icon_flash_on
|
|
77
93
|
)!!
|
|
78
94
|
}
|
|
79
95
|
|
|
80
96
|
fun getTouchOffDrawable(context: Context): Drawable {
|
|
81
97
|
return base64ToDrawable(touchOffBase64, context.resources!!) ?: AppCompatResources.getDrawable(
|
|
82
98
|
context,
|
|
83
|
-
com.dynamsoft.R.drawable.
|
|
99
|
+
com.dynamsoft.R.drawable.icon_flash_off
|
|
84
100
|
)!!
|
|
85
101
|
}
|
|
86
102
|
|
|
103
|
+
fun getCameraToggleDrawable(context: Context): Drawable {
|
|
104
|
+
return base64ToDrawable(cameraBase64, context.resources!!) ?: AppCompatResources.getDrawable(context, com.dynamsoft.R.drawable.icon_turn_camera)!!
|
|
105
|
+
}
|
|
106
|
+
|
|
87
107
|
override fun toString(): String {
|
|
88
|
-
return "
|
|
108
|
+
return "CameraViewButtonState(location=$location, visible=$visible, touchOnBase64=$touchOnBase64, touchOffBase64=$touchOffBase64)"
|
|
89
109
|
}
|
|
90
110
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
package com.dynamsoft.
|
|
1
|
+
package com.dynamsoft.reactnativelib.basicutils
|
|
2
2
|
|
|
3
3
|
import com.dynamsoft.core.basic_structures.CapturedResultItem
|
|
4
4
|
import com.dynamsoft.ddn.DeskewedImageResultItem
|
|
@@ -6,8 +6,6 @@ import com.dynamsoft.ddn.DetectedQuadResultItem
|
|
|
6
6
|
import com.dynamsoft.ddn.EnhancedImageResultItem
|
|
7
7
|
import com.dynamsoft.ddn.ProcessedDocumentResult
|
|
8
8
|
import com.dynamsoft.ddn.SimplifiedDocumentNormalizerSettings
|
|
9
|
-
import com.dynamsoft.reactnativelib.utils.toIntArray
|
|
10
|
-
import com.dynamsoft.reactnativelib.utils.toWritableArray
|
|
11
9
|
import com.facebook.react.bridge.Arguments
|
|
12
10
|
import com.facebook.react.bridge.ReadableMap
|
|
13
11
|
import com.facebook.react.bridge.WritableArray
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
package com.dynamsoft.
|
|
1
|
+
package com.dynamsoft.reactnativelib.basicutils
|
|
2
2
|
|
|
3
3
|
import com.dynamsoft.core.basic_structures.CapturedResultItem
|
|
4
4
|
import com.dynamsoft.dlr.CharacterResult
|
|
5
5
|
import com.dynamsoft.dlr.RecognizedTextLinesResult
|
|
6
6
|
import com.dynamsoft.dlr.SimplifiedLabelRecognizerSettings
|
|
7
7
|
import com.dynamsoft.dlr.TextLineResultItem
|
|
8
|
-
import com.dynamsoft.reactnativelib.utils.toIntArray
|
|
9
|
-
import com.dynamsoft.reactnativelib.utils.toWritableArray
|
|
10
8
|
import com.facebook.react.bridge.Arguments
|
|
11
9
|
import com.facebook.react.bridge.ReadableMap
|
|
12
10
|
import com.facebook.react.bridge.WritableArray
|
|
@@ -23,6 +21,7 @@ fun CharacterResult.toWritableMap() : WritableMap = Arguments.createMap().apply
|
|
|
23
21
|
putInt("characterHConfidence",characterHConfidence)
|
|
24
22
|
putInt("characterMConfidence",characterMConfidence)
|
|
25
23
|
putInt("characterLConfidence",characterLConfidence)
|
|
24
|
+
putMap("location", location.toWritableMap())
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
fun TextLineResultItem.toWritableMap(): WritableMap = Arguments.createMap().apply {
|
|
@@ -30,6 +29,7 @@ fun TextLineResultItem.toWritableMap(): WritableMap = Arguments.createMap().appl
|
|
|
30
29
|
putMap("location", location.toWritableMap())
|
|
31
30
|
putArray("characterResults", characterResults.toWitableArray())
|
|
32
31
|
putString("text", text)
|
|
32
|
+
putString("rawText", rawText)
|
|
33
33
|
putString("specificationName", specificationName)
|
|
34
34
|
putInt("confidence", confidence)
|
|
35
35
|
}
|
|
@@ -52,6 +52,7 @@ fun SimplifiedLabelRecognizerSettings.toWritableMap(): WritableMap = Arguments.c
|
|
|
52
52
|
putString("characterModelName", characterModelName)
|
|
53
53
|
putString("lineStringRegExPattern", lineStringRegExPattern)
|
|
54
54
|
putInt("scaleDownThreshold", scaleDownThreshold)
|
|
55
|
+
putInt("maxThreadsInOneTask", maxThreadsInOneTask)
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
fun SimplifiedLabelRecognizerSettings.updateFromReadableMap(newSettings: ReadableMap) {
|
|
@@ -66,4 +67,6 @@ fun SimplifiedLabelRecognizerSettings.updateFromReadableMap(newSettings: Readabl
|
|
|
66
67
|
|
|
67
68
|
grayscaleEnhancementModes = if (newSettings.hasKey("grayscaleEnhancementModes"))
|
|
68
69
|
newSettings.getArray("grayscaleEnhancementModes")?.toIntArray() else grayscaleEnhancementModes
|
|
70
|
+
|
|
71
|
+
maxThreadsInOneTask = if (newSettings.hasKey("maxThreadsInOneTask")) newSettings.getInt("maxThreadsInOneTask") else maxThreadsInOneTask
|
|
69
72
|
}
|
package/android/src/main/java/com/dynamsoft/reactnativelib/{utils → basicutils}/ImageUtil.kt
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
package com.dynamsoft.
|
|
1
|
+
package com.dynamsoft.reactnativelib.basicutils
|
|
2
2
|
|
|
3
3
|
import android.content.res.Resources
|
|
4
4
|
import android.graphics.Bitmap
|
|
@@ -10,7 +10,7 @@ import com.dynamsoft.core.basic_structures.ImageData
|
|
|
10
10
|
import java.io.ByteArrayOutputStream
|
|
11
11
|
|
|
12
12
|
fun bitmap2Byte(bitmap: Bitmap?): ByteArray? {
|
|
13
|
-
if (null == bitmap) return null
|
|
13
|
+
if (null == bitmap) return null
|
|
14
14
|
val outputStream = ByteArrayOutputStream()
|
|
15
15
|
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream)
|
|
16
16
|
return outputStream.toByteArray()
|
package/android/src/main/java/com/dynamsoft/reactnativelib/cvr/CaptureVisionRouterModuleImpl.kt
CHANGED
|
@@ -11,10 +11,10 @@ import com.dynamsoft.ddn.DeskewedImageResultItem
|
|
|
11
11
|
import com.dynamsoft.ddn.EnhancedImageResultItem
|
|
12
12
|
import com.dynamsoft.ddn.ProcessedDocumentResult
|
|
13
13
|
import com.dynamsoft.dlr.RecognizedTextLinesResult
|
|
14
|
-
import com.dynamsoft.
|
|
14
|
+
import com.dynamsoft.reactnativelib.basicutils.toWritableMap
|
|
15
|
+
import com.dynamsoft.reactnativelib.basicutils.toWritableMap
|
|
15
16
|
import com.dynamsoft.reactnativelib.core.ImageSourceAdapterModuleImpl
|
|
16
|
-
import com.dynamsoft.reactnativelib.
|
|
17
|
-
import com.dynamsoft.reactnativelib.utils.updateFromReadableMap
|
|
17
|
+
import com.dynamsoft.reactnativelib.basicutils.updateFromReadableMap
|
|
18
18
|
import com.facebook.react.bridge.*
|
|
19
19
|
import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter
|
|
20
20
|
import kotlinx.coroutines.delay
|
|
@@ -176,7 +176,7 @@ class CaptureVisionRouterModuleImpl(private val reactContext: ReactApplicationCo
|
|
|
176
176
|
try {
|
|
177
177
|
promise.resolve(cvr.getSimplifiedSettings(template).toWritableMap())
|
|
178
178
|
} catch (e: CaptureVisionRouterException) {
|
|
179
|
-
promise.reject(e.errorCode.toString(), e.message)
|
|
179
|
+
promise.reject(e.errorCode.toString(), e.message)
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
|
|
@@ -189,7 +189,7 @@ class CaptureVisionRouterModuleImpl(private val reactContext: ReactApplicationCo
|
|
|
189
189
|
}
|
|
190
190
|
promise.resolve(null)
|
|
191
191
|
} catch (e: CaptureVisionRouterException) {
|
|
192
|
-
promise.reject(e.errorCode.toString(), e.message)
|
|
192
|
+
promise.reject(e.errorCode.toString(), e.message)
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
|
|
@@ -232,6 +232,26 @@ class CaptureVisionRouterModuleImpl(private val reactContext: ReactApplicationCo
|
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
234
|
|
|
235
|
+
@ReactMethod
|
|
236
|
+
fun switchCapturingTemplate(template: String, promise: Promise) {
|
|
237
|
+
try {
|
|
238
|
+
cvr.switchCapturingTemplate(template)
|
|
239
|
+
promise.resolve(null)
|
|
240
|
+
} catch (e: CaptureVisionRouterException) {
|
|
241
|
+
promise.reject(e.errorCode.toString(), e.message)
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
@ReactMethod
|
|
246
|
+
fun clearDLModelBuffers() {
|
|
247
|
+
CaptureVisionRouter.clearDLModelBuffers()
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
@ReactMethod
|
|
251
|
+
fun setGlobalIntraOpNumThreads(intraOpNumThreads: Int) {
|
|
252
|
+
CaptureVisionRouter.setGlobalIntraOpNumThreads(intraOpNumThreads)
|
|
253
|
+
}
|
|
254
|
+
|
|
235
255
|
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
236
256
|
fun install(): Boolean {
|
|
237
257
|
reactContext.javaScriptContextHolder?.apply {
|
|
@@ -12,8 +12,8 @@ import com.dynamsoft.dce.EnumResolution
|
|
|
12
12
|
import com.dynamsoft.dce.Feedback
|
|
13
13
|
import com.dynamsoft.dce.utils.PermissionUtil
|
|
14
14
|
import com.dynamsoft.reactnativelib.core.ImageSourceAdapterModuleImpl.Companion.mapISA
|
|
15
|
-
import com.dynamsoft.reactnativelib.
|
|
16
|
-
import com.dynamsoft.reactnativelib.
|
|
15
|
+
import com.dynamsoft.reactnativelib.basicutils.toScanRegion
|
|
16
|
+
import com.dynamsoft.reactnativelib.basicutils.toWritableMap
|
|
17
17
|
import com.facebook.react.bridge.Arguments
|
|
18
18
|
import com.facebook.react.bridge.LifecycleEventListener
|
|
19
19
|
import com.facebook.react.bridge.Promise
|
|
@@ -97,6 +97,9 @@ class CameraEnhancerModuleImpl(private val reactContext: ReactApplicationContext
|
|
|
97
97
|
|
|
98
98
|
@ReactMethod
|
|
99
99
|
fun setCameraView(viewTag: Int) {
|
|
100
|
+
if(viewTag == 0) {
|
|
101
|
+
return
|
|
102
|
+
}
|
|
100
103
|
currentCameraViewId = viewTag
|
|
101
104
|
findAndSetCameraView(viewTag)
|
|
102
105
|
}
|
|
@@ -172,7 +175,7 @@ class CameraEnhancerModuleImpl(private val reactContext: ReactApplicationContext
|
|
|
172
175
|
}
|
|
173
176
|
@ReactMethod
|
|
174
177
|
fun getResolution(promise: Promise) {
|
|
175
|
-
val resolution = camera.
|
|
178
|
+
val resolution = camera.resolution ?: Size(0,0)
|
|
176
179
|
promise.resolve(Arguments.createMap().apply {
|
|
177
180
|
putInt("width", resolution.width)
|
|
178
181
|
putInt("height", resolution.height)
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
package com.dynamsoft.
|
|
1
|
+
package com.dynamsoft.reactnativelib.dce
|
|
2
2
|
|
|
3
3
|
import com.dynamsoft.dce.CameraView
|
|
4
4
|
import com.dynamsoft.dce.DrawingLayer
|
|
5
|
-
import com.dynamsoft.reactnativelib.
|
|
6
|
-
import com.dynamsoft.reactnativelib.
|
|
5
|
+
import com.dynamsoft.reactnativelib.basicutils.setCameraToggleButtonState
|
|
6
|
+
import com.dynamsoft.reactnativelib.basicutils.setTorchButtonState
|
|
7
|
+
import com.dynamsoft.reactnativelib.basicutils.toCameraToggleButtonState
|
|
8
|
+
import com.dynamsoft.reactnativelib.basicutils.toTorchButtonState
|
|
7
9
|
import com.facebook.react.bridge.ReadableArray
|
|
8
10
|
import com.facebook.react.bridge.ReadableMap
|
|
9
11
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
@@ -55,6 +57,16 @@ class CameraViewManagerImpl {
|
|
|
55
57
|
view.torchButtonVisible = isVisible
|
|
56
58
|
}
|
|
57
59
|
|
|
60
|
+
@ReactProp(name = "cameraToggleButton")
|
|
61
|
+
fun setCameraToggleButton(view: CameraView, cameraToggleButton: ReadableMap) {
|
|
62
|
+
view.setCameraToggleButtonState(cameraToggleButton.toCameraToggleButtonState())
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@ReactProp(name = "cameraToggleButtonVisible")
|
|
66
|
+
fun setCameraToggleButtonVisible(view: CameraView, isVisible: Boolean) {
|
|
67
|
+
view.cameraToggleButtonVisible = isVisible
|
|
68
|
+
}
|
|
69
|
+
|
|
58
70
|
// private fun View.manuallyMeasureAndLayout() {
|
|
59
71
|
// measure(
|
|
60
72
|
// View.MeasureSpec.makeMeasureSpec(measuredWidth, View.MeasureSpec.EXACTLY),
|
package/android/src/main/java/com/dynamsoft/reactnativelib/dce/ImageEditorViewManagerImpl.kt
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
package com.dynamsoft.
|
|
1
|
+
package com.dynamsoft.reactnativelib.dce
|
|
2
2
|
|
|
3
|
-
import android.view.Choreographer
|
|
4
|
-
import android.view.View
|
|
5
3
|
import com.dynamsoft.dce.ImageEditorView
|
|
6
|
-
import com.dynamsoft.reactnativelib.dce.RNImageEditorView
|
|
7
|
-
import com.facebook.react.uimanager.SimpleViewManager
|
|
8
4
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
9
5
|
|
|
10
6
|
class ImageEditorViewManagerImpl {
|
|
@@ -2,13 +2,11 @@ package com.dynamsoft.reactnativelib.dce
|
|
|
2
2
|
|
|
3
3
|
import android.util.Log
|
|
4
4
|
import com.dynamsoft.core.basic_structures.ImageData
|
|
5
|
-
import com.dynamsoft.dce.CameraView
|
|
6
5
|
import com.dynamsoft.dce.DrawingItem
|
|
7
6
|
import com.dynamsoft.dce.ImageEditorView
|
|
8
7
|
import com.dynamsoft.dce.QuadDrawingItem
|
|
9
|
-
import com.dynamsoft.
|
|
10
|
-
import com.dynamsoft.
|
|
11
|
-
import com.dynamsoft.reactnativelib.core.ImageSourceAdapterModuleImpl.Companion.nativeInstall
|
|
8
|
+
import com.dynamsoft.reactnativelib.basicutils.toQuad
|
|
9
|
+
import com.dynamsoft.reactnativelib.basicutils.toWritableMap
|
|
12
10
|
import com.facebook.react.bridge.Promise
|
|
13
11
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
14
12
|
import com.facebook.react.bridge.ReactMethod
|