dynamsoft-capture-vision-react-native 2.4.2000-alpha.3 → 2.6.1012
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 -0
- package/README.md +32 -4
- package/android/build.gradle +1 -5
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/CameraEnhancerModuleImpl.kt +73 -64
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/ImageEditorViewManagerImpl.kt +2 -18
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/ImageEditorViewModuleImpl.kt +49 -51
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/RNImageEditorView.kt +19 -0
- package/android/src/main/java/com/dynamsoft/reactnativelib/utils/ForDDN.kt +2 -0
- package/android/src/newarch/com/dynamsoft/reactnativelib/CameraViewManager.kt +6 -0
- package/dynamsoft-capture-vision-react-native.podspec +3 -5
- package/ios/CPP/RNDynamsoft+JSI.h +19 -0
- package/ios/CPP/RNDynamsoft+JSI.mm +145 -0
- package/ios/{RNDynamsoftCaptureVision/CPP → CPP}/RNDynamsoft+Json.h +12 -5
- package/ios/{RNDynamsoftCaptureVision/CPP/RNDynamsoft+Json.mm → CPP/RNDynamsoft+Json.m} +6 -124
- package/ios/{RNDynamsoftCaptureVision/RNDynamsoftCaptureVisionRouter.mm → RNDynamsoftCaptureVisionRouter.mm} +1 -0
- package/ios/{RNDynamsoftCaptureVision/RNDynamsoftImageEditorViewManager.mm → RNDynamsoftImageEditorViewManager.mm} +5 -1
- package/ios/{RNDynamsoftCaptureVision/RNDynamsoftImageManager.mm → RNDynamsoftImageManager.mm} +6 -2
- package/package.json +2 -2
- package/src/core/CapturedResultItem.tsx +18 -2
- package/src/core/CompletionListener.tsx +4 -3
- package/src/core/CoreModule.tsx +3 -3
- package/src/core/DSRect.tsx +28 -21
- package/src/core/EnumCaptureResultItemType.tsx +38 -7
- package/src/core/EnumColourChannelUsageType.tsx +25 -7
- package/src/core/EnumCrossVerificationStatus.tsx +43 -0
- package/src/core/EnumGrayscaleEnhancementMode.tsx +40 -7
- package/src/core/EnumGrayscaleTransformationMode.tsx +29 -5
- package/src/core/EnumPixelFormat.tsx +37 -32
- package/src/core/ImageData.tsx +51 -4
- package/src/core/ImageSourceAdapter.tsx +132 -72
- package/src/core/NativeDynamsoftImageSourceAdapterModule.tsx +24 -13
- package/src/core/Point.tsx +12 -9
- package/src/core/Quadrilateral.tsx +9 -5
- package/src/core/Rect.tsx +19 -16
- package/src/cvr/CaptureVisionRouter.tsx +571 -279
- package/src/cvr/CapturedResult.tsx +117 -76
- package/src/cvr/CapturedResultFilter.tsx +7 -0
- package/src/cvr/CapturedResultReceiver.tsx +59 -3
- package/src/cvr/EnumPresetTemplate.tsx +66 -1
- package/src/cvr/SimplifiedCaptureVisionSettings.tsx +45 -0
- package/src/dbr/BarcodeResultItem.tsx +31 -1
- package/src/dbr/DecodedBarcodesResult.tsx +18 -0
- package/src/dbr/EnumBarcodeFormat.tsx +11 -0
- package/src/dbr/EnumDeblurMode.tsx +28 -12
- package/src/dbr/EnumLocalizationMode.tsx +15 -1
- package/src/dbr/SimplifiedBarcodeReaderSettings.tsx +72 -12
- package/src/dce/CameraEnhancer.tsx +211 -89
- package/src/dce/CameraView.tsx +17 -0
- package/src/dce/DynamsoftCameraViewNativeComponent.ts +43 -0
- package/src/dce/EnumCameraPosition.tsx +3 -0
- package/src/dce/EnumDrawingLayerId.tsx +11 -0
- package/src/dce/EnumEnhancedFeatures.tsx +23 -7
- package/src/dce/EnumFocusMode.tsx +2 -0
- package/src/dce/FeedBack.tsx +9 -0
- package/src/dce/ImageEditorView.tsx +33 -1
- package/src/dcp/EnumMappingStatus.tsx +12 -3
- package/src/dcp/EnumValidationStatus.tsx +12 -3
- package/src/dcp/ParsedResult.tsx +16 -0
- package/src/dcp/ParsedResultItem.tsx +35 -0
- package/src/ddn/DetectedQuadResultItem.tsx +23 -0
- package/src/ddn/DetectedQuadsResult.tsx +20 -1
- package/src/ddn/EnumImageColourMode.tsx +9 -0
- package/src/ddn/NormalizedImageResultItem.tsx +25 -0
- package/src/ddn/NormalizedImagesResult.tsx +17 -1
- package/src/ddn/SimplifiedDocumentNormalizerSettings.tsx +38 -2
- package/src/dlr/CharacterResult.tsx +17 -0
- package/src/dlr/RecognizedTextLinesResult.tsx +23 -1
- package/src/dlr/SimplifiedLabelRecognizerSettings.tsx +21 -0
- package/src/dlr/TextLineResultItem.tsx +26 -0
- package/src/license/LicenseManager.tsx +19 -0
- package/src/utility/ImageManager.tsx +23 -0
- package/src/utility/MultiFrameResultCrossFilter.tsx +99 -6
- package/android/.gitignore +0 -4
- package/ios/ReactNativeDcv.xcodeproj/project.pbxproj +0 -390
- /package/ios/{RNDynamsoftCaptureVision/CPP → CPP}/DSImageData+HostObject.h +0 -0
- /package/ios/{RNDynamsoftCaptureVision/CPP → CPP}/DSImageData+HostObject.mm +0 -0
- /package/ios/{RNDynamsoftCaptureVision/CPP → CPP}/ImageDataHostObject.cpp +0 -0
- /package/ios/{RNDynamsoftCaptureVision/CPP → CPP}/ImageDataHostObject.hpp +0 -0
- /package/ios/{RNDynamsoftCaptureVision/CPP → CPP}/MutableRawBuffer.cpp +0 -0
- /package/ios/{RNDynamsoftCaptureVision/CPP → CPP}/MutableRawBuffer.hpp +0 -0
- /package/ios/{RNDynamsoftCaptureVision/CPP → CPP}/YeetJSIUtils.h +0 -0
- /package/ios/{RNDynamsoftCaptureVision/CPP → CPP}/YeetJSIUtils.mm +0 -0
- /package/ios/{RNDynamsoftCaptureVision/RNDynamsoftCameraView.h → RNDynamsoftCameraView.h} +0 -0
- /package/ios/{RNDynamsoftCaptureVision/RNDynamsoftCameraView.m → RNDynamsoftCameraView.m} +0 -0
- /package/ios/{RNDynamsoftCaptureVision/RNDynamsoftCameraViewManager.h → RNDynamsoftCameraViewManager.h} +0 -0
- /package/ios/{RNDynamsoftCaptureVision/RNDynamsoftCameraViewManager.m → RNDynamsoftCameraViewManager.m} +0 -0
- /package/ios/{RNDynamsoftCaptureVision/RNDynamsoftCaptureVisionRouter.h → RNDynamsoftCaptureVisionRouter.h} +0 -0
- /package/ios/{RNDynamsoftCaptureVision/RNDynamsoftImageEditorView.h → RNDynamsoftImageEditorView.h} +0 -0
- /package/ios/{RNDynamsoftCaptureVision/RNDynamsoftImageEditorView.m → RNDynamsoftImageEditorView.m} +0 -0
- /package/ios/{RNDynamsoftCaptureVision/RNDynamsoftImageEditorViewManager.h → RNDynamsoftImageEditorViewManager.h} +0 -0
- /package/ios/{RNDynamsoftCaptureVision/RNDynamsoftImageManager.h → RNDynamsoftImageManager.h} +0 -0
- /package/ios/{RNDynamsoftCaptureVision/RNDynamsoftImageSourceAdapter.h → RNDynamsoftImageSourceAdapter.h} +0 -0
- /package/ios/{RNDynamsoftCaptureVision/RNDynamsoftImageSourceAdapter.mm → RNDynamsoftImageSourceAdapter.mm} +0 -0
- /package/ios/{RNDynamsoftCaptureVision/RNDynamsoftLicense.h → RNDynamsoftLicense.h} +0 -0
- /package/ios/{RNDynamsoftCaptureVision/RNDynamsoftLicense.m → RNDynamsoftLicense.m} +0 -0
- /package/ios/{RNDynamsoftCaptureVision/RNDynamsoftMultiCrossFilter.h → RNDynamsoftMultiCrossFilter.h} +0 -0
- /package/ios/{RNDynamsoftCaptureVision/RNDynamsoftMultiCrossFilter.m → RNDynamsoftMultiCrossFilter.m} +0 -0
- /package/ios/{RNDynamsoftCaptureVision/RNDynamsoftVersions.h → RNDynamsoftVersions.h} +0 -0
- /package/ios/{RNDynamsoftCaptureVision/RNDynamsoftVersions.m → RNDynamsoftVersions.m} +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
License Notice
|
|
2
|
+
|
|
3
|
+
The source code of the Dynamsoft Capture Vision (DCV) React Native Edition published here is released under the Apache 2.0 license: http://www.apache.org/licenses/LICENSE-2.0. Dynamsoft Barcode Reader (DBR) and Dynamsoft Camera Enhancer (DCE) SDK upon which Dynamsoft Capture Vision (DCV) depends are provided under a commercial license from https://www.dynamsoft.com/company/license-agreement/. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4
|
+
|
|
5
|
+
Copyright © 2003–2025 Dynamsoft. All Rights Reserved.
|
package/README.md
CHANGED
|
@@ -18,17 +18,45 @@ DCV powers your software development through the following aspects:
|
|
|
18
18
|
|
|
19
19
|
DCV enables you to develop highly customizable applications for barcode reading, label recognition, document board detection, and result parsing. These applications offer enterprise-grade performance and can be tailored to meet your specific business needs.
|
|
20
20
|
|
|
21
|
+
## System Requirements
|
|
22
|
+
|
|
23
|
+
### React Native
|
|
24
|
+
|
|
25
|
+
- Supported Version: 0.71.0 or higher
|
|
26
|
+
|
|
27
|
+
### Android
|
|
28
|
+
|
|
29
|
+
- Supported OS: Android 5.0 (API Level 21) or higher.
|
|
30
|
+
- Supported ABI: armeabi-v7a, arm64-v8a, x86 and x86_64.
|
|
31
|
+
- Development Environment: Android Studio 2022.2.1 or higher.
|
|
32
|
+
|
|
33
|
+
### iOS
|
|
34
|
+
|
|
35
|
+
- Supported OS: iOS 11+ (iOS 13+ recommended).
|
|
36
|
+
- Supported ABI: arm64 and x86_64.
|
|
37
|
+
- Development Environment: Xcode 13+ (Xcode 14.1+ recommended).
|
|
38
|
+
|
|
39
|
+
### Others
|
|
40
|
+
|
|
41
|
+
- Node: 18 or higher
|
|
42
|
+
|
|
43
|
+
## User Guide
|
|
44
|
+
|
|
45
|
+
- [Barcode Reader Integration Guide](https://github.com/Dynamsoft/capture-vision-react-native-samples/blob/main/barcode-reader-integration-guide.md)
|
|
46
|
+
- [Document Scanner Integration Guide](https://github.com/Dynamsoft/capture-vision-react-native-samples/blob/main/document-scanner-integration-guide.md)
|
|
47
|
+
- [MRZ Scanner Integration Guide](https://github.com/Dynamsoft/capture-vision-react-native-samples/blob/main/mrz-scanner-integration-guide.md)
|
|
48
|
+
|
|
21
49
|
## Samples
|
|
22
50
|
|
|
23
51
|
You can view all the DCV React Native samples via the following links:
|
|
24
52
|
|
|
25
|
-
- [
|
|
26
|
-
- [
|
|
27
|
-
- [
|
|
53
|
+
- [ScanSingleBarcode](https://github.com/Dynamsoft/capture-vision-react-native-samples/tree/main/ScanSingleBarcode)
|
|
54
|
+
- [DetectAndDeskewDocument](https://github.com/Dynamsoft/capture-vision-react-native-samples/tree/main/DetectAndDeskewDocument)
|
|
55
|
+
- [ScanMRZ](https://github.com/Dynamsoft/capture-vision-react-native-samples/tree/main/ScanMRZ)
|
|
28
56
|
|
|
29
57
|
## License
|
|
30
58
|
|
|
31
|
-
- You can
|
|
59
|
+
- You can request a 30-day trial license via the [Request a Trial License](https://www.dynamsoft.com/customer/license/trialLicense?product=dcv&utm_source=npm&package=mobile) link.
|
|
32
60
|
|
|
33
61
|
## Contact
|
|
34
62
|
|
package/android/build.gradle
CHANGED
|
@@ -110,10 +110,6 @@ rootProject.allprojects {
|
|
|
110
110
|
maven {
|
|
111
111
|
url "https://download2.dynamsoft.com/maven/aar"
|
|
112
112
|
}
|
|
113
|
-
maven {
|
|
114
|
-
url "http://192.168.8.101:8081/repository/maven-dynamsoft-public/"
|
|
115
|
-
allowInsecureProtocol true
|
|
116
|
-
}
|
|
117
113
|
}
|
|
118
114
|
}
|
|
119
115
|
|
|
@@ -129,5 +125,5 @@ dependencies {
|
|
|
129
125
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
|
|
130
126
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3"
|
|
131
127
|
|
|
132
|
-
implementation "com.dynamsoft:dynamsoftcapturevisionbundle:2.
|
|
128
|
+
implementation "com.dynamsoft:dynamsoftcapturevisionbundle:2.6.1002"
|
|
133
129
|
}
|
|
@@ -1,36 +1,46 @@
|
|
|
1
1
|
package com.dynamsoft.reactnativelib.dce
|
|
2
2
|
|
|
3
|
-
import android.annotation.SuppressLint
|
|
4
3
|
import android.graphics.PointF
|
|
5
4
|
import android.util.Log
|
|
6
|
-
import androidx.annotation.MainThread
|
|
7
5
|
import androidx.lifecycle.Lifecycle
|
|
8
|
-
import com.dynamsoft.dce
|
|
6
|
+
import com.dynamsoft.dce.CameraEnhancer
|
|
7
|
+
import com.dynamsoft.dce.CameraView
|
|
8
|
+
import com.dynamsoft.dce.EnumCameraPosition
|
|
9
|
+
import com.dynamsoft.dce.EnumFocusMode
|
|
10
|
+
import com.dynamsoft.dce.Feedback
|
|
9
11
|
import com.dynamsoft.dce.utils.PermissionUtil
|
|
10
12
|
import com.dynamsoft.reactnative.dce.utils.CameraLifeCycleOwner
|
|
11
13
|
import com.dynamsoft.reactnativelib.core.ImageSourceAdapterModuleImpl.Companion.mapISA
|
|
12
14
|
import com.dynamsoft.reactnativelib.utils.toScanRegion
|
|
13
15
|
import com.dynamsoft.reactnativelib.utils.toWritableMap
|
|
14
|
-
import com.facebook.react.bridge
|
|
16
|
+
import com.facebook.react.bridge.LifecycleEventListener
|
|
17
|
+
import com.facebook.react.bridge.Promise
|
|
18
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
19
|
+
import com.facebook.react.bridge.ReactMethod
|
|
20
|
+
import com.facebook.react.bridge.ReadableMap
|
|
15
21
|
import com.facebook.react.uimanager.UIManagerHelper
|
|
16
22
|
import kotlinx.coroutines.CoroutineName
|
|
17
23
|
import kotlinx.coroutines.CoroutineScope
|
|
18
24
|
import kotlinx.coroutines.Dispatchers
|
|
25
|
+
import kotlinx.coroutines.MainScope
|
|
26
|
+
import kotlinx.coroutines.isActive
|
|
19
27
|
import kotlinx.coroutines.launch
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import kotlin.coroutines.suspendCoroutine
|
|
28
|
+
import kotlinx.coroutines.withContext
|
|
29
|
+
import kotlinx.coroutines.withTimeoutOrNull
|
|
23
30
|
|
|
24
31
|
|
|
25
32
|
class CameraEnhancerModuleImpl(private val reactContext: ReactApplicationContext) : LifecycleEventListener {
|
|
26
33
|
companion object {
|
|
27
34
|
const val NAME = "DynamsoftCameraView"
|
|
28
|
-
const val TAG = "
|
|
35
|
+
const val TAG = "CameraEnhancerModule"
|
|
29
36
|
}
|
|
30
37
|
|
|
38
|
+
private var ifOpenCalled = false
|
|
31
39
|
private var cameraLifecycleOwner = CameraLifeCycleOwner()
|
|
32
|
-
private var camera: CameraEnhancer
|
|
33
|
-
|
|
40
|
+
private var camera: CameraEnhancer = CameraEnhancer(cameraLifecycleOwner).apply {
|
|
41
|
+
mapISA[this.toString()] = this
|
|
42
|
+
}
|
|
43
|
+
private var currentCameraViewId: Int? = null
|
|
34
44
|
|
|
35
45
|
init {
|
|
36
46
|
reactContext.addLifecycleEventListener(this)
|
|
@@ -41,12 +51,14 @@ class CameraEnhancerModuleImpl(private val reactContext: ReactApplicationContext
|
|
|
41
51
|
override fun onHostResume() {
|
|
42
52
|
cameraLifecycleOwner.lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_START)
|
|
43
53
|
cameraLifecycleOwner.lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_RESUME)
|
|
54
|
+
if(ifOpenCalled) {
|
|
55
|
+
open()
|
|
56
|
+
}
|
|
44
57
|
}
|
|
45
58
|
|
|
46
59
|
override fun onHostPause() {
|
|
47
60
|
cameraLifecycleOwner.lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_PAUSE)
|
|
48
61
|
cameraLifecycleOwner.lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_STOP)
|
|
49
|
-
|
|
50
62
|
}
|
|
51
63
|
|
|
52
64
|
override fun onHostDestroy() {
|
|
@@ -62,105 +74,89 @@ class CameraEnhancerModuleImpl(private val reactContext: ReactApplicationContext
|
|
|
62
74
|
|
|
63
75
|
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
64
76
|
fun createInstance(): String {
|
|
65
|
-
|
|
66
|
-
camera = CameraEnhancer(cameraLifecycleOwner).apply {
|
|
67
|
-
mapISA[this.toString()] = this
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return camera!!.toString()
|
|
77
|
+
return camera.toString()
|
|
71
78
|
}
|
|
72
79
|
|
|
73
80
|
@ReactMethod
|
|
74
81
|
fun open() {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
} catch (e: CameraEnhancerException) {
|
|
83
|
-
e.printStackTrace()
|
|
82
|
+
ifOpenCalled = true
|
|
83
|
+
if (currentCameraViewId != null && (camera.cameraView == null || camera.cameraView?.id != currentCameraViewId)) {
|
|
84
|
+
findAndSetCameraView(currentCameraViewId!!) { camera.open() }
|
|
85
|
+
} else {
|
|
86
|
+
camera.open()
|
|
84
87
|
}
|
|
85
88
|
}
|
|
86
89
|
|
|
87
90
|
@ReactMethod
|
|
88
91
|
fun close() {
|
|
89
|
-
|
|
92
|
+
ifOpenCalled = false
|
|
93
|
+
camera.close()
|
|
90
94
|
}
|
|
91
95
|
|
|
92
|
-
@SuppressLint("LongLogTag")
|
|
93
96
|
@ReactMethod
|
|
94
97
|
fun setCameraView(viewTag: Int) {
|
|
95
98
|
currentCameraViewId = viewTag
|
|
96
|
-
|
|
97
|
-
try {
|
|
98
|
-
val cameraView = findCameraView(viewTag)
|
|
99
|
-
camera?.cameraView = cameraView
|
|
100
|
-
} catch (e: Exception) {
|
|
101
|
-
Log.w(TAG, "setCameraView: " + e.message )
|
|
102
|
-
}
|
|
103
|
-
}
|
|
99
|
+
findAndSetCameraView(viewTag)
|
|
104
100
|
}
|
|
105
101
|
|
|
106
102
|
@ReactMethod
|
|
107
103
|
fun selectCamera(@EnumCameraPosition position: Int) {
|
|
108
|
-
camera
|
|
104
|
+
camera.selectCamera(position)
|
|
109
105
|
}
|
|
110
106
|
|
|
111
107
|
@ReactMethod
|
|
112
108
|
fun getCameraPosition(promise: Promise) {
|
|
113
|
-
promise.resolve(camera
|
|
109
|
+
promise.resolve(camera.cameraPosition)
|
|
114
110
|
}
|
|
115
111
|
|
|
116
112
|
@ReactMethod
|
|
117
113
|
fun setFocus(x: Float, y: Float, @EnumFocusMode focusMode: Int) {
|
|
118
|
-
camera
|
|
114
|
+
camera.setFocus(PointF(x, y), focusMode)
|
|
119
115
|
}
|
|
120
116
|
|
|
121
117
|
@ReactMethod
|
|
122
118
|
fun getFocusMode(promise: Promise) {
|
|
123
|
-
promise.resolve(camera
|
|
119
|
+
promise.resolve(camera.focusMode)
|
|
124
120
|
}
|
|
125
121
|
|
|
126
122
|
@ReactMethod
|
|
127
123
|
fun setZoomFactor(factor: Float) {
|
|
128
|
-
camera
|
|
124
|
+
camera.zoomFactor = factor
|
|
129
125
|
}
|
|
130
126
|
|
|
131
127
|
@ReactMethod
|
|
132
128
|
fun getZoomFactor(promise: Promise) {
|
|
133
|
-
promise.resolve(camera
|
|
129
|
+
promise.resolve(camera.zoomFactor)
|
|
134
130
|
}
|
|
135
131
|
|
|
136
132
|
@ReactMethod
|
|
137
133
|
fun enableEnhancedFeatures(features: Int) {
|
|
138
|
-
camera
|
|
134
|
+
camera.enableEnhancedFeatures(features)
|
|
139
135
|
}
|
|
140
136
|
|
|
141
137
|
@ReactMethod
|
|
142
138
|
fun disableEnhancedFeatures(features: Int) {
|
|
143
|
-
camera
|
|
139
|
+
camera.disableEnhancedFeatures(features)
|
|
144
140
|
}
|
|
145
141
|
|
|
146
142
|
@ReactMethod
|
|
147
143
|
fun setScanRegion(region: ReadableMap?) {
|
|
148
|
-
camera
|
|
144
|
+
camera.scanRegion = region?.toScanRegion()
|
|
149
145
|
}
|
|
150
146
|
|
|
151
147
|
@ReactMethod
|
|
152
148
|
fun getScanRegion(promise: Promise) {
|
|
153
|
-
promise.resolve(camera
|
|
149
|
+
promise.resolve(camera.scanRegion?.toWritableMap())
|
|
154
150
|
}
|
|
155
151
|
|
|
156
152
|
@ReactMethod
|
|
157
153
|
fun turnOnTorch() {
|
|
158
|
-
camera
|
|
154
|
+
camera.turnOnTorch()
|
|
159
155
|
}
|
|
160
156
|
|
|
161
157
|
@ReactMethod
|
|
162
158
|
fun turnOffTorch() {
|
|
163
|
-
camera
|
|
159
|
+
camera.turnOffTorch()
|
|
164
160
|
}
|
|
165
161
|
|
|
166
162
|
@ReactMethod
|
|
@@ -173,24 +169,37 @@ class CameraEnhancerModuleImpl(private val reactContext: ReactApplicationContext
|
|
|
173
169
|
Feedback.vibrate(reactContext)
|
|
174
170
|
}
|
|
175
171
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
172
|
+
private fun findAndSetCameraView(viewTag: Int, afterSetCameraView: () -> Unit = {}) {
|
|
173
|
+
CoroutineScope(Dispatchers.Default).launch(CoroutineName("setCameraView")) {
|
|
174
|
+
val cameraView = findCameraView(viewTag)
|
|
175
|
+
if (cameraView == null) {
|
|
176
|
+
Log.e(TAG, "setCameraView: Can't not find cameraView!(viewId = $viewTag)")
|
|
177
|
+
return@launch
|
|
178
|
+
}
|
|
179
|
+
MainScope().launch {
|
|
180
|
+
camera.cameraView = cameraView
|
|
181
|
+
afterSetCameraView()
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
private suspend fun findCameraView(viewId: Int): CameraView? = withTimeoutOrNull(300) {
|
|
187
|
+
while (true) {
|
|
188
|
+
val view = withContext(Dispatchers.Main) {
|
|
189
|
+
try {
|
|
190
|
+
UIManagerHelper.getUIManager(reactContext, viewId)?.resolveView(viewId) as? CameraView
|
|
191
|
+
} catch (e: Exception) {
|
|
192
|
+
null
|
|
193
|
+
}
|
|
188
194
|
}
|
|
189
|
-
Log.d(TAG, "Found view $viewId!")
|
|
190
195
|
if (view != null) {
|
|
191
|
-
|
|
192
|
-
}
|
|
193
|
-
|
|
196
|
+
return@withTimeoutOrNull view
|
|
197
|
+
}
|
|
198
|
+
if (!isActive) {
|
|
199
|
+
break
|
|
194
200
|
}
|
|
195
201
|
}
|
|
202
|
+
return@withTimeoutOrNull null
|
|
203
|
+
}
|
|
204
|
+
|
|
196
205
|
}
|
package/android/src/main/java/com/dynamsoft/reactnativelib/dce/ImageEditorViewManagerImpl.kt
CHANGED
|
@@ -3,6 +3,7 @@ package com.dynamsoft.reactnative.dce
|
|
|
3
3
|
import android.view.Choreographer
|
|
4
4
|
import android.view.View
|
|
5
5
|
import com.dynamsoft.dce.ImageEditorView
|
|
6
|
+
import com.dynamsoft.reactnativelib.dce.RNImageEditorView
|
|
6
7
|
import com.facebook.react.uimanager.SimpleViewManager
|
|
7
8
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
8
9
|
|
|
@@ -12,24 +13,7 @@ class ImageEditorViewManagerImpl {
|
|
|
12
13
|
}
|
|
13
14
|
fun getName() = TAG
|
|
14
15
|
fun createViewInstance(context: ThemedReactContext): ImageEditorView {
|
|
15
|
-
return
|
|
16
|
-
Choreographer.getInstance().postFrameCallback(object : Choreographer.FrameCallback {
|
|
17
|
-
override fun doFrame(frameTimeNanos: Long) {
|
|
18
|
-
manuallyMeasureAndLayout()
|
|
19
|
-
viewTreeObserver.dispatchOnGlobalLayout()
|
|
20
|
-
Choreographer.getInstance().postFrameCallback(this)
|
|
21
|
-
}
|
|
22
|
-
})
|
|
23
|
-
}
|
|
16
|
+
return RNImageEditorView(context)
|
|
24
17
|
}
|
|
25
18
|
|
|
26
|
-
private fun View.manuallyMeasureAndLayout() {
|
|
27
|
-
measure(
|
|
28
|
-
View.MeasureSpec.makeMeasureSpec(measuredWidth, View.MeasureSpec.EXACTLY),
|
|
29
|
-
View.MeasureSpec.makeMeasureSpec(measuredHeight, View.MeasureSpec.EXACTLY)
|
|
30
|
-
)
|
|
31
|
-
layout(0, 0, measuredWidth, measuredHeight)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
19
|
}
|
|
@@ -2,24 +2,26 @@ 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
|
|
5
6
|
import com.dynamsoft.dce.DrawingItem
|
|
6
7
|
import com.dynamsoft.dce.ImageEditorView
|
|
7
8
|
import com.dynamsoft.dce.QuadDrawingItem
|
|
8
9
|
import com.dynamsoft.reactnative.basicutils.toQuad
|
|
9
10
|
import com.dynamsoft.reactnative.basicutils.toWritableMap
|
|
11
|
+
import com.dynamsoft.reactnativelib.core.ImageSourceAdapterModuleImpl.Companion.nativeInstall
|
|
10
12
|
import com.facebook.react.bridge.Promise
|
|
11
13
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
12
14
|
import com.facebook.react.bridge.ReactMethod
|
|
13
15
|
import com.facebook.react.bridge.ReadableArray
|
|
14
|
-
import com.facebook.react.
|
|
16
|
+
import com.facebook.react.uimanager.IllegalViewOperationException
|
|
15
17
|
import com.facebook.react.uimanager.UIManagerHelper
|
|
16
18
|
import kotlinx.coroutines.CoroutineName
|
|
17
19
|
import kotlinx.coroutines.CoroutineScope
|
|
18
20
|
import kotlinx.coroutines.Dispatchers
|
|
21
|
+
import kotlinx.coroutines.isActive
|
|
19
22
|
import kotlinx.coroutines.launch
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import kotlin.coroutines.suspendCoroutine
|
|
23
|
+
import kotlinx.coroutines.withContext
|
|
24
|
+
import kotlinx.coroutines.withTimeoutOrNull
|
|
23
25
|
|
|
24
26
|
class ImageEditorViewModuleImpl(private val reactContext: ReactApplicationContext) {
|
|
25
27
|
companion object {
|
|
@@ -31,80 +33,76 @@ class ImageEditorViewModuleImpl(private val reactContext: ReactApplicationContex
|
|
|
31
33
|
|
|
32
34
|
@ReactMethod
|
|
33
35
|
fun setQuads(viewTag: Int, readableArray: ReadableArray, layerId: Int, promise: Promise) {
|
|
34
|
-
CoroutineScope(Dispatchers.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
for (i in 0 until readableArray.size()) {
|
|
39
|
-
drawingItems.add(QuadDrawingItem(readableArray.getMap(i).toQuad()))
|
|
40
|
-
}
|
|
41
|
-
imageEditorView.getDrawingLayer(layerId).drawingItems = drawingItems
|
|
42
|
-
promise.resolve(null)
|
|
43
|
-
} catch (e: Exception) {
|
|
44
|
-
Log.w(TAG, "setQuads: " + e.message)
|
|
36
|
+
CoroutineScope(Dispatchers.Default).launch(CoroutineName("setQuads")) {
|
|
37
|
+
val imageEditorView = findImageEditorView(viewTag)
|
|
38
|
+
if(imageEditorView == null) {
|
|
39
|
+
Log.e(TAG, "setQuads: Can't not find imageEditorView!(viewId = $viewTag)")
|
|
45
40
|
promise.resolve(null)
|
|
41
|
+
return@launch
|
|
42
|
+
}
|
|
43
|
+
val drawingItems = ArrayList<DrawingItem<*>>()
|
|
44
|
+
for (i in 0 until readableArray.size()) {
|
|
45
|
+
drawingItems.add(QuadDrawingItem(readableArray.getMap(i).toQuad()))
|
|
46
46
|
}
|
|
47
|
+
imageEditorView.getDrawingLayer(layerId).drawingItems = drawingItems
|
|
48
|
+
promise.resolve(null)
|
|
47
49
|
}
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
@ReactMethod
|
|
51
53
|
fun getSelectedQuad(viewTag: Int, promise: Promise) {
|
|
52
|
-
CoroutineScope(Dispatchers.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
54
|
+
CoroutineScope(Dispatchers.Default).launch(CoroutineName("getSelectedQuad")) {
|
|
55
|
+
val imageEditorView = findImageEditorView(viewTag)
|
|
56
|
+
if(imageEditorView == null) {
|
|
57
|
+
Log.e(TAG, "getSelectedQuad: Can't not find imageEditorView!(viewId = $viewTag)")
|
|
58
|
+
promise.resolve(null)
|
|
59
|
+
return@launch
|
|
60
|
+
}
|
|
61
|
+
val selectedDrawingItem = imageEditorView.selectedDrawingItem
|
|
62
|
+
if (selectedDrawingItem != null) {
|
|
63
|
+
promise.resolve((selectedDrawingItem as QuadDrawingItem).quad.toWritableMap())
|
|
64
|
+
} else {
|
|
63
65
|
promise.resolve(null)
|
|
64
66
|
}
|
|
65
67
|
}
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
69
|
-
fun install()
|
|
71
|
+
fun install(): Boolean {
|
|
70
72
|
reactContext.javaScriptContextHolder?.apply {
|
|
71
73
|
nativeInstall(get())
|
|
72
74
|
}
|
|
73
75
|
return true
|
|
74
76
|
}
|
|
75
77
|
|
|
76
|
-
private suspend fun findImageEditorView(viewId: Int): ImageEditorView =
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
reactContext,
|
|
83
|
-
viewId
|
|
84
|
-
)?.resolveView(viewId)
|
|
85
|
-
Log.d(TAG, "findCameraView: resolveView=$resolveView")
|
|
86
|
-
resolveView as ImageEditorView?
|
|
87
|
-
} else {
|
|
78
|
+
private suspend fun findImageEditorView(viewId: Int): ImageEditorView? = withTimeoutOrNull(300) {
|
|
79
|
+
while (true) {
|
|
80
|
+
val view = withContext(Dispatchers.Main) {
|
|
81
|
+
try {
|
|
82
|
+
UIManagerHelper.getUIManager(reactContext, viewId)?.resolveView(viewId) as? ImageEditorView
|
|
83
|
+
} catch (e: Exception) {
|
|
88
84
|
null
|
|
89
85
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
86
|
+
}
|
|
87
|
+
if (view != null) {
|
|
88
|
+
return@withTimeoutOrNull view
|
|
89
|
+
}
|
|
90
|
+
if (!isActive) {
|
|
91
|
+
break
|
|
96
92
|
}
|
|
97
93
|
}
|
|
94
|
+
return@withTimeoutOrNull null
|
|
95
|
+
}
|
|
98
96
|
|
|
99
97
|
//@Native
|
|
100
98
|
private fun setOriginalImageCalledInJSI(imageData: ImageData, editorViewTag: Int) {
|
|
101
|
-
CoroutineScope(Dispatchers.
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
Log.w(TAG, "setOriginalImageCalledInJSI: " + e.message)
|
|
99
|
+
CoroutineScope(Dispatchers.Default).launch(CoroutineName("setOriginalImageCalledInJSI")) {
|
|
100
|
+
val imageEditorView = findImageEditorView(editorViewTag)
|
|
101
|
+
if(imageEditorView == null) {
|
|
102
|
+
Log.e(TAG, "setOriginalImageCalledInJSI: Can't not find imageEditorView!(viewId = $editorViewTag)")
|
|
103
|
+
return@launch
|
|
107
104
|
}
|
|
105
|
+
imageEditorView?.originalImage = imageData
|
|
108
106
|
}
|
|
109
107
|
}
|
|
110
108
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
package com.dynamsoft.reactnativelib.dce
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import com.dynamsoft.dce.ImageEditorView
|
|
5
|
+
|
|
6
|
+
class RNImageEditorView(context: Context) : ImageEditorView(context) {
|
|
7
|
+
override fun requestLayout() {
|
|
8
|
+
super.requestLayout()
|
|
9
|
+
post(this::manuallyMeasureAndLayout)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
private fun manuallyMeasureAndLayout() {
|
|
13
|
+
measure(
|
|
14
|
+
MeasureSpec.makeMeasureSpec(measuredWidth, MeasureSpec.EXACTLY),
|
|
15
|
+
MeasureSpec.makeMeasureSpec(measuredHeight, MeasureSpec.EXACTLY)
|
|
16
|
+
)
|
|
17
|
+
layout(0, 0, measuredWidth, measuredHeight)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -18,6 +18,7 @@ fun DetectedQuadResultItem.toWritableMap(): WritableMap = Arguments.createMap().
|
|
|
18
18
|
merge((this@toWritableMap as CapturedResultItem).toSharedWritableMap())
|
|
19
19
|
putMap("location", location.toWritableMap())
|
|
20
20
|
putInt("confidenceAsDocumentBoundary", confidenceAsDocumentBoundary)
|
|
21
|
+
putInt("crossVerificationStatus", crossVerificationStatus)
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
|
|
@@ -36,6 +37,7 @@ fun DetectedQuadsResult.toWritableMap(): WritableMap = Arguments.createMap().app
|
|
|
36
37
|
fun NormalizedImageResultItem.toWritableMap(): WritableMap = Arguments.createMap().apply {
|
|
37
38
|
merge((this@toWritableMap as CapturedResultItem).toSharedWritableMap())
|
|
38
39
|
putMap("location", location.toWritableMap())
|
|
40
|
+
putInt("crossVerificationStatus", crossVerificationStatus)
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
fun Array<out NormalizedImageResultItem>.toWritableArray(): WritableArray = Arguments.createArray().apply {
|
|
@@ -6,6 +6,7 @@ import com.facebook.react.bridge.ReadableArray
|
|
|
6
6
|
import com.facebook.react.bridge.ReadableMap
|
|
7
7
|
import com.facebook.react.uimanager.SimpleViewManager
|
|
8
8
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
9
|
+
import com.facebook.react.uimanager.annotations.ReactProp
|
|
9
10
|
import com.facebook.react.viewmanagers.DynamsoftCameraViewManagerInterface
|
|
10
11
|
|
|
11
12
|
class CameraViewManager : SimpleViewManager<CameraView>(),
|
|
@@ -19,26 +20,31 @@ class CameraViewManager : SimpleViewManager<CameraView>(),
|
|
|
19
20
|
return impl.getName()
|
|
20
21
|
}
|
|
21
22
|
|
|
23
|
+
@ReactProp(name = "VisibleLayerIds")
|
|
22
24
|
override fun setVisibleLayerIds(view: CameraView?, value: ReadableArray?) {
|
|
23
25
|
if (value != null) {
|
|
24
26
|
view?.let { impl.setVisibleLayerIds(it, value) }
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
29
|
|
|
30
|
+
@ReactProp(name = "scanRegionMaskVisible")
|
|
28
31
|
override fun setScanRegionMaskVisible(view: CameraView?, value: Boolean) {
|
|
29
32
|
view?.let { impl.setScanRegionMaskVisible(it, value) }
|
|
30
33
|
}
|
|
31
34
|
|
|
35
|
+
@ReactProp(name = "scanLaserVisible")
|
|
32
36
|
override fun setScanLaserVisible(view: CameraView?, value: Boolean) {
|
|
33
37
|
view?.let { impl.setScanLaserVisible(it, value) }
|
|
34
38
|
}
|
|
35
39
|
|
|
40
|
+
@ReactProp(name = "torchButton")
|
|
36
41
|
override fun setTorchButton(view: CameraView?, value: ReadableMap?) {
|
|
37
42
|
if (value != null) {
|
|
38
43
|
view?.let { impl.setTorchButton(it, value) }
|
|
39
44
|
}
|
|
40
45
|
}
|
|
41
46
|
|
|
47
|
+
@ReactProp(name = "torchButtonVisible")
|
|
42
48
|
override fun setTorchButtonVisible(view: CameraView?, value: Boolean) {
|
|
43
49
|
view?.let { impl.setTorchButtonVisible(it, value) }
|
|
44
50
|
}
|
|
@@ -8,15 +8,13 @@ Pod::Spec.new do |s|
|
|
|
8
8
|
s.version = package["version"]
|
|
9
9
|
s.summary = package["description"]
|
|
10
10
|
s.homepage = package["homepage"]
|
|
11
|
-
s.license = "
|
|
12
|
-
# optional - use expanded license entry instead:
|
|
13
|
-
# s.license = { :type => "MIT", :file => "LICENSE" }
|
|
11
|
+
s.license = package["license"]
|
|
14
12
|
s.authors = { package["author"]["name"] => package["author"]["email"] }
|
|
15
13
|
s.platforms = { :ios => "11.0" }
|
|
16
|
-
s.source
|
|
14
|
+
s.source = { :http => "https://registry.npmjs.org/#{s.name}/-/#{s.name}-#{s.version}.tgz" }
|
|
17
15
|
s.source_files = "ios/**/*.{h,c,cc,cpp,m,mm,swift}"
|
|
18
16
|
s.requires_arc = true
|
|
19
17
|
s.dependency "React"
|
|
20
|
-
s.dependency "DynamsoftCaptureVisionBundle", "= 2.
|
|
18
|
+
s.dependency "DynamsoftCaptureVisionBundle", "= 2.6.1002"
|
|
21
19
|
end
|
|
22
20
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright © Dynamsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
#import <DynamsoftCaptureVisionRouter/DSCapturedResult.h>
|
|
6
|
+
#import <DynamsoftCore/DSQuadrilateral.h>
|
|
7
|
+
#import <jsi/jsi.h>
|
|
8
|
+
|
|
9
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
10
|
+
|
|
11
|
+
@interface DSCapturedResult (JSI)
|
|
12
|
+
|
|
13
|
+
- (facebook::jsi::Object)convertToJSIObject:(facebook::jsi::Runtime& )runtime;
|
|
14
|
+
|
|
15
|
+
@end
|
|
16
|
+
|
|
17
|
+
NS_ASSUME_NONNULL_END
|
|
18
|
+
|
|
19
|
+
DSQuadrilateral * _Nullable convertJSIValueToDSQuadrilateral(facebook::jsi::Runtime &runtime, const facebook::jsi::Object &value);
|