dynamsoft-capture-vision-react-native 3.4.1000-beta.1 → 3.4.1100
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/android/src/main/java/com/dynamsoft/reactnativelib/CVRModule.kt +10 -2
- package/android/src/main/java/com/dynamsoft/reactnativelib/DCEModule.kt +5 -2
- package/android/src/main/java/com/dynamsoft/reactnativelib/LicenseModule.kt +11 -0
- package/android/src/main/java/com/dynamsoft/reactnativelib/cvr/CaptureVisionRouterModuleImpl.kt +37 -23
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/CameraEnhancerModuleImpl.kt +41 -25
- package/android/src/main/java/com/dynamsoft/reactnativelib/license/LicenseModuleImpl.kt +10 -0
- package/dynamsoft-capture-vision-react-native.podspec +1 -1
- package/ios/RNDynamsoftCameraViewManager.m +8 -1
- package/ios/RNDynamsoftCaptureVisionRouter.mm +10 -1
- package/ios/RNDynamsoftLicense.m +11 -0
- package/package.json +1 -16
- package/src/cvr/CaptureVisionRouter.tsx +11 -2
- package/src/dce/CameraEnhancer.tsx +10 -0
- package/src/license/LicenseManager.tsx +16 -0
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
package com.dynamsoft.reactnativelib
|
|
2
2
|
|
|
3
|
-
import com.dynamsoft.cvr.CaptureVisionRouter
|
|
4
|
-
import com.dynamsoft.cvr.CaptureVisionRouterException
|
|
5
3
|
import com.dynamsoft.reactnativelib.cvr.CaptureVisionRouterModuleImpl
|
|
6
4
|
import com.facebook.react.bridge.Promise
|
|
7
5
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
@@ -14,6 +12,16 @@ class CVRModule(reactApplicationContext: ReactApplicationContext) : ReactContext
|
|
|
14
12
|
|
|
15
13
|
override fun getName(): String = impl.getName()
|
|
16
14
|
|
|
15
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
16
|
+
fun createInstance(): Boolean {
|
|
17
|
+
return impl.createInstance()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
21
|
+
fun destroyInstance(): Boolean {
|
|
22
|
+
return impl.destroyInstance()
|
|
23
|
+
}
|
|
24
|
+
|
|
17
25
|
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
18
26
|
fun install(): Boolean {
|
|
19
27
|
return impl.install()
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
package com.dynamsoft.reactnativelib
|
|
2
2
|
|
|
3
|
-
import com.dynamsoft.dce.Feedback
|
|
4
3
|
import com.dynamsoft.reactnativelib.dce.CameraEnhancerModuleImpl
|
|
5
4
|
import com.facebook.react.bridge.Promise
|
|
6
5
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
7
6
|
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
8
7
|
import com.facebook.react.bridge.ReactMethod
|
|
9
8
|
import com.facebook.react.bridge.ReadableMap
|
|
10
|
-
import com.facebook.react.bridge.WritableMap
|
|
11
9
|
|
|
12
10
|
class DCEModule(reactApplicationContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactApplicationContext) {
|
|
13
11
|
val impl = CameraEnhancerModuleImpl(reactApplicationContext)
|
|
@@ -19,6 +17,11 @@ class DCEModule(reactApplicationContext: ReactApplicationContext) : ReactContext
|
|
|
19
17
|
return impl.createInstance()
|
|
20
18
|
}
|
|
21
19
|
|
|
20
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
21
|
+
fun destroyInstance(id: String): Boolean {
|
|
22
|
+
return impl.destroyInstance(id)
|
|
23
|
+
}
|
|
24
|
+
|
|
22
25
|
@ReactMethod
|
|
23
26
|
fun requestCameraPermission() {
|
|
24
27
|
impl.requestCameraPermission()
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package com.dynamsoft.reactnativelib
|
|
2
2
|
|
|
3
|
+
import com.dynamsoft.license.LicenseManager
|
|
3
4
|
import com.dynamsoft.reactnativelib.license.LicenseModuleImpl
|
|
4
5
|
import com.facebook.react.bridge.Promise
|
|
5
6
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
@@ -15,4 +16,14 @@ class LicenseModule(reactApplicationContext: ReactApplicationContext) : ReactCon
|
|
|
15
16
|
fun initLicense(license: String, promise: Promise) {
|
|
16
17
|
impl.initLicense(license, promise)
|
|
17
18
|
}
|
|
19
|
+
|
|
20
|
+
@ReactMethod
|
|
21
|
+
fun setDeviceFriendlyName(deviceFriendlyName: String) {
|
|
22
|
+
impl.setDeviceFriendlyName(deviceFriendlyName)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@ReactMethod
|
|
26
|
+
fun getDeviceUUID(promise: Promise) {
|
|
27
|
+
impl.getDeviceUUID(promise)
|
|
28
|
+
}
|
|
18
29
|
}
|
package/android/src/main/java/com/dynamsoft/reactnativelib/cvr/CaptureVisionRouterModuleImpl.kt
CHANGED
|
@@ -12,7 +12,6 @@ import com.dynamsoft.ddn.EnhancedImageResultItem
|
|
|
12
12
|
import com.dynamsoft.ddn.ProcessedDocumentResult
|
|
13
13
|
import com.dynamsoft.dlr.RecognizedTextLinesResult
|
|
14
14
|
import com.dynamsoft.reactnativelib.basicutils.toWritableMap
|
|
15
|
-
import com.dynamsoft.reactnativelib.basicutils.toWritableMap
|
|
16
15
|
import com.dynamsoft.reactnativelib.core.ImageSourceAdapterModuleImpl
|
|
17
16
|
import com.dynamsoft.reactnativelib.basicutils.updateFromReadableMap
|
|
18
17
|
import com.facebook.react.bridge.*
|
|
@@ -38,7 +37,7 @@ class CaptureVisionRouterModuleImpl(private val reactContext: ReactApplicationCo
|
|
|
38
37
|
private var ifStopCapturing = false
|
|
39
38
|
private var currentDeskewedImages: Array<ImageData>? = null
|
|
40
39
|
private var currentEnhancedImages: Array<ImageData>? = null
|
|
41
|
-
private
|
|
40
|
+
private var cvr: CaptureVisionRouter? = null
|
|
42
41
|
private val emitter by lazy { reactContext.getJSModule(RCTDeviceEventEmitter::class.java) }
|
|
43
42
|
|
|
44
43
|
private var continueCRR = false
|
|
@@ -94,6 +93,21 @@ class CaptureVisionRouterModuleImpl(private val reactContext: ReactApplicationCo
|
|
|
94
93
|
|
|
95
94
|
fun getName() = NAME
|
|
96
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?.input = null
|
|
105
|
+
cvr?.removeAllResultReceivers()
|
|
106
|
+
cvr?.stopCapturing()
|
|
107
|
+
cvr = null
|
|
108
|
+
return true
|
|
109
|
+
}
|
|
110
|
+
|
|
97
111
|
@ReactMethod
|
|
98
112
|
fun continueCRR() {
|
|
99
113
|
continueCRR = true
|
|
@@ -102,7 +116,7 @@ class CaptureVisionRouterModuleImpl(private val reactContext: ReactApplicationCo
|
|
|
102
116
|
@ReactMethod
|
|
103
117
|
fun addListener(type: String?) {
|
|
104
118
|
crrRemoved = false
|
|
105
|
-
crrMap[type]?.let { cvr
|
|
119
|
+
crrMap[type]?.let { cvr?.addResultReceiver(it) }
|
|
106
120
|
}
|
|
107
121
|
|
|
108
122
|
@ReactMethod
|
|
@@ -112,31 +126,31 @@ class CaptureVisionRouterModuleImpl(private val reactContext: ReactApplicationCo
|
|
|
112
126
|
|
|
113
127
|
@ReactMethod
|
|
114
128
|
fun removeListener(type: String?) {
|
|
115
|
-
crrMap[type]?.let { cvr
|
|
129
|
+
crrMap[type]?.let { cvr?.removeResultReceiver(it) }
|
|
116
130
|
}
|
|
117
131
|
|
|
118
132
|
@ReactMethod
|
|
119
133
|
fun removeAllResultListeners() {
|
|
120
134
|
crrRemoved = true
|
|
121
135
|
crrMap.forEach {
|
|
122
|
-
cvr
|
|
136
|
+
cvr?.removeResultReceiver(it.value)
|
|
123
137
|
}
|
|
124
138
|
}
|
|
125
139
|
|
|
126
140
|
@ReactMethod
|
|
127
141
|
fun addFilter(filterId: String?) {
|
|
128
|
-
cvr
|
|
142
|
+
cvr?.addResultFilter(filterMap[filterId])
|
|
129
143
|
}
|
|
130
144
|
|
|
131
145
|
@ReactMethod
|
|
132
146
|
fun removeFilter(filterId: String?) {
|
|
133
|
-
cvr
|
|
147
|
+
cvr?.removeResultFilter(filterMap[filterId])
|
|
134
148
|
}
|
|
135
149
|
|
|
136
150
|
@ReactMethod
|
|
137
151
|
fun startCapturing(template: String, promise: Promise) {
|
|
138
152
|
ifStopCapturing = false
|
|
139
|
-
cvr
|
|
153
|
+
cvr?.startCapturing(template, object : CompletionListener {
|
|
140
154
|
override fun onSuccess() {
|
|
141
155
|
Log.i(TAG, "onSuccess: startCapturing($template)")
|
|
142
156
|
promise.resolve(null)
|
|
@@ -152,19 +166,19 @@ class CaptureVisionRouterModuleImpl(private val reactContext: ReactApplicationCo
|
|
|
152
166
|
@ReactMethod
|
|
153
167
|
fun stopCapturing(promise: Promise) {
|
|
154
168
|
ifStopCapturing = true
|
|
155
|
-
cvr
|
|
169
|
+
cvr?.stopCapturing()
|
|
156
170
|
promise.resolve(null)
|
|
157
171
|
}
|
|
158
172
|
|
|
159
173
|
@ReactMethod
|
|
160
174
|
fun setInput(inputId: String) {
|
|
161
|
-
ImageSourceAdapterModuleImpl.mapISA[inputId]?.apply { cvr
|
|
175
|
+
ImageSourceAdapterModuleImpl.mapISA[inputId]?.apply { cvr?.input = this }
|
|
162
176
|
}
|
|
163
177
|
|
|
164
178
|
@ReactMethod
|
|
165
179
|
fun resetSettings(promise: Promise) {
|
|
166
180
|
try {
|
|
167
|
-
cvr
|
|
181
|
+
cvr?.resetSettings()
|
|
168
182
|
promise.resolve(true)
|
|
169
183
|
} catch (e: CaptureVisionRouterException) {
|
|
170
184
|
promise.reject(e.errorCode.toString(), e.message)
|
|
@@ -174,7 +188,7 @@ class CaptureVisionRouterModuleImpl(private val reactContext: ReactApplicationCo
|
|
|
174
188
|
@ReactMethod
|
|
175
189
|
fun getSimplifiedSettings(template: String, promise: Promise) {
|
|
176
190
|
try {
|
|
177
|
-
promise.resolve(cvr
|
|
191
|
+
promise.resolve(cvr?.getSimplifiedSettings(template)?.toWritableMap())
|
|
178
192
|
} catch (e: CaptureVisionRouterException) {
|
|
179
193
|
promise.reject(e.errorCode.toString(), e.message)
|
|
180
194
|
}
|
|
@@ -183,9 +197,9 @@ class CaptureVisionRouterModuleImpl(private val reactContext: ReactApplicationCo
|
|
|
183
197
|
@ReactMethod
|
|
184
198
|
fun updateSettings(settings: ReadableMap, template: String, promise: Promise) {
|
|
185
199
|
try {
|
|
186
|
-
cvr
|
|
200
|
+
cvr?.getSimplifiedSettings(template)?.apply {
|
|
187
201
|
updateFromReadableMap(settings)
|
|
188
|
-
cvr
|
|
202
|
+
cvr?.updateSettings(template, this)
|
|
189
203
|
}
|
|
190
204
|
promise.resolve(null)
|
|
191
205
|
} catch (e: CaptureVisionRouterException) {
|
|
@@ -196,7 +210,7 @@ class CaptureVisionRouterModuleImpl(private val reactContext: ReactApplicationCo
|
|
|
196
210
|
@ReactMethod
|
|
197
211
|
fun initSettings(content: String, promise: Promise) {
|
|
198
212
|
try {
|
|
199
|
-
cvr
|
|
213
|
+
cvr?.initSettings(content)
|
|
200
214
|
promise.resolve(null)
|
|
201
215
|
} catch (e: CaptureVisionRouterException) {
|
|
202
216
|
promise.reject(e.errorCode.toString(), e.message)
|
|
@@ -206,7 +220,7 @@ class CaptureVisionRouterModuleImpl(private val reactContext: ReactApplicationCo
|
|
|
206
220
|
@ReactMethod
|
|
207
221
|
fun initSettingsFromFile(path: String, promise: Promise) {
|
|
208
222
|
try {
|
|
209
|
-
cvr
|
|
223
|
+
cvr?.initSettingsFromFile(path)
|
|
210
224
|
promise.resolve(null)
|
|
211
225
|
} catch (e: CaptureVisionRouterException) {
|
|
212
226
|
promise.reject(e.errorCode.toString(), e.message)
|
|
@@ -216,7 +230,7 @@ class CaptureVisionRouterModuleImpl(private val reactContext: ReactApplicationCo
|
|
|
216
230
|
@ReactMethod
|
|
217
231
|
fun outputSettingsToFile(template: String, path: String, includeDefaultValues: Boolean, promise: Promise) {
|
|
218
232
|
try {
|
|
219
|
-
cvr
|
|
233
|
+
cvr?.outputSettingsToFile(template, path, includeDefaultValues)
|
|
220
234
|
promise.resolve(null)
|
|
221
235
|
} catch (e: CaptureVisionRouterException) {
|
|
222
236
|
promise.reject(e.errorCode.toString(), e.message)
|
|
@@ -226,7 +240,7 @@ class CaptureVisionRouterModuleImpl(private val reactContext: ReactApplicationCo
|
|
|
226
240
|
@ReactMethod
|
|
227
241
|
fun outputSettings(template: String, includeDefaultValues: Boolean, promise: Promise) {
|
|
228
242
|
try {
|
|
229
|
-
promise.resolve(cvr
|
|
243
|
+
promise.resolve(cvr?.outputSettings(template, includeDefaultValues))
|
|
230
244
|
} catch (e: CaptureVisionRouterException) {
|
|
231
245
|
promise.reject(e.errorCode.toString(), e.message)
|
|
232
246
|
}
|
|
@@ -235,7 +249,7 @@ class CaptureVisionRouterModuleImpl(private val reactContext: ReactApplicationCo
|
|
|
235
249
|
@ReactMethod
|
|
236
250
|
fun switchCapturingTemplate(template: String, promise: Promise) {
|
|
237
251
|
try {
|
|
238
|
-
cvr
|
|
252
|
+
cvr?.switchCapturingTemplate(template)
|
|
239
253
|
promise.resolve(null)
|
|
240
254
|
} catch (e: CaptureVisionRouterException) {
|
|
241
255
|
promise.reject(e.errorCode.toString(), e.message)
|
|
@@ -262,22 +276,22 @@ class CaptureVisionRouterModuleImpl(private val reactContext: ReactApplicationCo
|
|
|
262
276
|
|
|
263
277
|
//@Native
|
|
264
278
|
private fun captureImageDataCalledInJSI(imageData: ImageData, template: String): CapturedResult {
|
|
265
|
-
return cvr
|
|
279
|
+
return cvr?.capture(imageData, template) ?: CapturedResult()
|
|
266
280
|
}
|
|
267
281
|
|
|
268
282
|
//@Native
|
|
269
283
|
private fun captureFileCalledInJSI(filePath: String, template: String): CapturedResult {
|
|
270
|
-
return cvr
|
|
284
|
+
return cvr?.capture(filePath, template) ?: CapturedResult()
|
|
271
285
|
}
|
|
272
286
|
|
|
273
287
|
//@Native
|
|
274
288
|
private fun captureFileBytesCalledInJSI(fileBytes: ByteArray, template: String): CapturedResult {
|
|
275
|
-
return cvr
|
|
289
|
+
return cvr?.capture(fileBytes, template) ?: CapturedResult()
|
|
276
290
|
}
|
|
277
291
|
|
|
278
292
|
//@Native
|
|
279
293
|
private fun getOriginalImageCalledInJSI(imageHashId: String): ImageData {
|
|
280
|
-
var originalImage = cvr
|
|
294
|
+
var originalImage = cvr?.intermediateResultManager?.getOriginalImage(imageHashId)
|
|
281
295
|
if (originalImage == null) {
|
|
282
296
|
originalImage = ImageData()
|
|
283
297
|
originalImage.bytes = ByteArray(0)
|
|
@@ -11,9 +11,9 @@ import com.dynamsoft.dce.EnumFocusMode
|
|
|
11
11
|
import com.dynamsoft.dce.EnumResolution
|
|
12
12
|
import com.dynamsoft.dce.Feedback
|
|
13
13
|
import com.dynamsoft.dce.utils.PermissionUtil
|
|
14
|
-
import com.dynamsoft.reactnativelib.core.ImageSourceAdapterModuleImpl.Companion.mapISA
|
|
15
14
|
import com.dynamsoft.reactnativelib.basicutils.toScanRegion
|
|
16
15
|
import com.dynamsoft.reactnativelib.basicutils.toWritableMap
|
|
16
|
+
import com.dynamsoft.reactnativelib.core.ImageSourceAdapterModuleImpl.Companion.mapISA
|
|
17
17
|
import com.facebook.react.bridge.Arguments
|
|
18
18
|
import com.facebook.react.bridge.LifecycleEventListener
|
|
19
19
|
import com.facebook.react.bridge.Promise
|
|
@@ -39,9 +39,7 @@ class CameraEnhancerModuleImpl(private val reactContext: ReactApplicationContext
|
|
|
39
39
|
|
|
40
40
|
private var ifOpenCalled = false
|
|
41
41
|
private var cameraLifecycleOwner = CameraLifeCycleOwner()
|
|
42
|
-
private var camera: CameraEnhancer =
|
|
43
|
-
mapISA[this.toString()] = this
|
|
44
|
-
}
|
|
42
|
+
private var camera: CameraEnhancer? = null
|
|
45
43
|
private var currentCameraViewId: Int? = null
|
|
46
44
|
|
|
47
45
|
init {
|
|
@@ -77,23 +75,40 @@ class CameraEnhancerModuleImpl(private val reactContext: ReactApplicationContext
|
|
|
77
75
|
|
|
78
76
|
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
79
77
|
fun createInstance(): String {
|
|
78
|
+
if(camera == null) {
|
|
79
|
+
camera = CameraEnhancer(cameraLifecycleOwner).apply {
|
|
80
|
+
mapISA[this.toString()] = this
|
|
81
|
+
}
|
|
82
|
+
}
|
|
80
83
|
return camera.toString()
|
|
81
84
|
}
|
|
82
85
|
|
|
86
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
87
|
+
fun destroyInstance(id: String): Boolean {
|
|
88
|
+
if(camera?.toString() == id) {
|
|
89
|
+
camera?.close()
|
|
90
|
+
camera?.cameraView = null
|
|
91
|
+
currentCameraViewId = null
|
|
92
|
+
camera = null
|
|
93
|
+
}
|
|
94
|
+
mapISA.remove(id)
|
|
95
|
+
return true
|
|
96
|
+
}
|
|
97
|
+
|
|
83
98
|
@ReactMethod
|
|
84
99
|
fun open() {
|
|
85
100
|
ifOpenCalled = true
|
|
86
|
-
if (currentCameraViewId != null && (camera
|
|
87
|
-
findAndSetCameraView(currentCameraViewId!!) { camera
|
|
101
|
+
if (currentCameraViewId != null && (camera?.cameraView == null || camera?.cameraView?.id != currentCameraViewId)) {
|
|
102
|
+
findAndSetCameraView(currentCameraViewId!!) { camera?.open() }
|
|
88
103
|
} else {
|
|
89
|
-
camera
|
|
104
|
+
camera?.open()
|
|
90
105
|
}
|
|
91
106
|
}
|
|
92
107
|
|
|
93
108
|
@ReactMethod
|
|
94
109
|
fun close() {
|
|
95
110
|
ifOpenCalled = false
|
|
96
|
-
camera
|
|
111
|
+
camera?.close()
|
|
97
112
|
}
|
|
98
113
|
|
|
99
114
|
@ReactMethod
|
|
@@ -107,78 +122,78 @@ class CameraEnhancerModuleImpl(private val reactContext: ReactApplicationContext
|
|
|
107
122
|
|
|
108
123
|
@ReactMethod
|
|
109
124
|
fun selectCamera(@EnumCameraPosition position: Int) {
|
|
110
|
-
camera
|
|
125
|
+
camera?.selectCamera(position)
|
|
111
126
|
}
|
|
112
127
|
|
|
113
128
|
@ReactMethod
|
|
114
129
|
fun getCameraPosition(promise: Promise) {
|
|
115
|
-
promise.resolve(camera
|
|
130
|
+
promise.resolve(camera?.cameraPosition)
|
|
116
131
|
}
|
|
117
132
|
|
|
118
133
|
@ReactMethod
|
|
119
134
|
fun setFocus(x: Float, y: Float, @EnumFocusMode focusMode: Int) {
|
|
120
|
-
camera
|
|
135
|
+
camera?.setFocus(PointF(x, y), focusMode)
|
|
121
136
|
}
|
|
122
137
|
|
|
123
138
|
@ReactMethod
|
|
124
139
|
fun getFocusMode(promise: Promise) {
|
|
125
|
-
promise.resolve(camera
|
|
140
|
+
promise.resolve(camera?.focusMode)
|
|
126
141
|
}
|
|
127
142
|
|
|
128
143
|
@ReactMethod
|
|
129
144
|
fun setZoomFactor(factor: Float) {
|
|
130
|
-
camera
|
|
145
|
+
camera?.zoomFactor = factor
|
|
131
146
|
}
|
|
132
147
|
|
|
133
148
|
@ReactMethod
|
|
134
149
|
fun getZoomFactor(promise: Promise) {
|
|
135
|
-
promise.resolve(camera
|
|
150
|
+
promise.resolve(camera?.zoomFactor)
|
|
136
151
|
}
|
|
137
152
|
|
|
138
153
|
@ReactMethod
|
|
139
154
|
fun enableEnhancedFeatures(features: Int) {
|
|
140
|
-
camera
|
|
155
|
+
camera?.enableEnhancedFeatures(features)
|
|
141
156
|
}
|
|
142
157
|
|
|
143
158
|
@ReactMethod
|
|
144
159
|
fun disableEnhancedFeatures(features: Int) {
|
|
145
|
-
camera
|
|
160
|
+
camera?.disableEnhancedFeatures(features)
|
|
146
161
|
}
|
|
147
162
|
|
|
148
163
|
@ReactMethod
|
|
149
164
|
fun setScanRegion(region: ReadableMap?) {
|
|
150
|
-
camera
|
|
165
|
+
camera?.scanRegion = region?.toScanRegion()
|
|
151
166
|
}
|
|
152
167
|
|
|
153
168
|
@ReactMethod
|
|
154
169
|
fun getScanRegion(promise: Promise) {
|
|
155
|
-
promise.resolve(camera
|
|
170
|
+
promise.resolve(camera?.scanRegion?.toWritableMap())
|
|
156
171
|
}
|
|
157
172
|
|
|
158
173
|
@ReactMethod
|
|
159
174
|
fun turnOnTorch() {
|
|
160
|
-
camera
|
|
175
|
+
camera?.turnOnTorch()
|
|
161
176
|
}
|
|
162
177
|
|
|
163
178
|
@ReactMethod
|
|
164
179
|
fun turnOffTorch() {
|
|
165
|
-
camera
|
|
180
|
+
camera?.turnOffTorch()
|
|
166
181
|
}
|
|
167
182
|
|
|
168
183
|
|
|
169
184
|
@ReactMethod
|
|
170
185
|
fun setResolution(resolution: Int) {
|
|
171
186
|
if(resolution == 4) {
|
|
172
|
-
camera
|
|
187
|
+
camera?.setResolution(EnumResolution.RESOLUTION_4K)
|
|
173
188
|
} else if(resolution == 5) {
|
|
174
|
-
camera
|
|
189
|
+
camera?.setResolution(EnumResolution.RESOLUTION_MAX)
|
|
175
190
|
} else {
|
|
176
|
-
camera
|
|
191
|
+
camera?.setResolution(resolution)
|
|
177
192
|
}
|
|
178
193
|
}
|
|
179
194
|
@ReactMethod
|
|
180
195
|
fun getResolution(promise: Promise) {
|
|
181
|
-
val resolution = camera
|
|
196
|
+
val resolution = camera?.resolution ?: Size(0,0)
|
|
182
197
|
promise.resolve(Arguments.createMap().apply {
|
|
183
198
|
putInt("width", resolution.width)
|
|
184
199
|
putInt("height", resolution.height)
|
|
@@ -203,7 +218,8 @@ class CameraEnhancerModuleImpl(private val reactContext: ReactApplicationContext
|
|
|
203
218
|
return@launch
|
|
204
219
|
}
|
|
205
220
|
MainScope().launch {
|
|
206
|
-
|
|
221
|
+
Log.e(TAG, "findAndSetCameraView: before setCameraView $camera ${cameraView.id}", )
|
|
222
|
+
camera?.cameraView = cameraView
|
|
207
223
|
afterSetCameraView()
|
|
208
224
|
}
|
|
209
225
|
}
|
|
@@ -26,4 +26,14 @@ class LicenseModuleImpl(private val reactContext: ReactApplicationContext) {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
+
|
|
30
|
+
@ReactMethod
|
|
31
|
+
fun setDeviceFriendlyName(deviceFriendlyName: String) {
|
|
32
|
+
LicenseManager.setDeviceFriendlyName(deviceFriendlyName)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@ReactMethod
|
|
36
|
+
fun getDeviceUUID(promise: Promise) {
|
|
37
|
+
promise.resolve(LicenseManager.getDeviceUUID())
|
|
38
|
+
}
|
|
29
39
|
}
|
|
@@ -17,7 +17,7 @@ Pod::Spec.new do |s|
|
|
|
17
17
|
s.private_header_files = "ios/**/*.h"
|
|
18
18
|
s.requires_arc = true
|
|
19
19
|
|
|
20
|
-
s.dependency "DynamsoftCaptureVisionBundle", ">= 3.4.
|
|
20
|
+
s.dependency "DynamsoftCaptureVisionBundle", ">= 3.4.1100", "< 4.0"
|
|
21
21
|
|
|
22
22
|
install_modules_dependencies(s)
|
|
23
23
|
end
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
@end
|
|
16
16
|
|
|
17
17
|
@implementation RNDynamsoftCameraViewManager {
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
RCT_EXPORT_MODULE(DynamsoftCameraView)
|
|
@@ -52,6 +52,13 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(createInstance) {
|
|
|
52
52
|
return key;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(destroyInstance:(NSString *)key) {
|
|
56
|
+
self.dce = nil;
|
|
57
|
+
RNDynamsoftImageSourceAdapter *rnAdapter = [self.bridge moduleForClass:[RNDynamsoftImageSourceAdapter class]];
|
|
58
|
+
[rnAdapter.isaDictionary removeObjectForKey:key];
|
|
59
|
+
return @true;
|
|
60
|
+
}
|
|
61
|
+
|
|
55
62
|
RCT_EXPORT_METHOD(open) {
|
|
56
63
|
[self.dce open];
|
|
57
64
|
}
|
|
@@ -40,7 +40,6 @@ RCT_EXPORT_MODULE(DynamsoftCaptureVisionRouterModule)
|
|
|
40
40
|
{
|
|
41
41
|
self = [super init];
|
|
42
42
|
if (self) {
|
|
43
|
-
_cvr = [[DSCaptureVisionRouter alloc] init];
|
|
44
43
|
semaphore = dispatch_semaphore_create(0);
|
|
45
44
|
}
|
|
46
45
|
return self;
|
|
@@ -51,6 +50,16 @@ RCT_EXPORT_MODULE(DynamsoftCaptureVisionRouterModule)
|
|
|
51
50
|
_cvr = nil;
|
|
52
51
|
}
|
|
53
52
|
|
|
53
|
+
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(createInstance) {
|
|
54
|
+
self.cvr = [[DSCaptureVisionRouter alloc] init];
|
|
55
|
+
return @true;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(destroyInstance) {
|
|
59
|
+
self.cvr = nil;
|
|
60
|
+
return @true;
|
|
61
|
+
}
|
|
62
|
+
|
|
54
63
|
RCT_EXPORT_METHOD(setGlobalIntraOpNumThreads:(NSInteger)intraOpNumThreads) {
|
|
55
64
|
[DSCaptureVisionRouter setGlobalIntraOpNumThreads:intraOpNumThreads];
|
|
56
65
|
}
|
package/ios/RNDynamsoftLicense.m
CHANGED
|
@@ -47,4 +47,15 @@ RCT_EXPORT_METHOD(initLicense:(NSString *)license
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
RCT_EXPORT_METHOD(setDeviceFriendlyName:(NSString *)name) {
|
|
51
|
+
[DSLicenseManager setDeviceFriendlyName:name];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
RCT_EXPORT_METHOD(getDeviceUUID:(RCTPromiseResolveBlock)resolve
|
|
55
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
56
|
+
{
|
|
57
|
+
NSString *uuid = [DSLicenseManager getDeviceUUID];
|
|
58
|
+
resolve(uuid);
|
|
59
|
+
}
|
|
60
|
+
|
|
50
61
|
@end
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dynamsoft-capture-vision-react-native",
|
|
3
3
|
"title": "Dynamsoft Capture Vision React Native",
|
|
4
|
-
"version": "3.4.
|
|
4
|
+
"version": "3.4.1100",
|
|
5
5
|
"description": "The Dynamsoft Capture Vision React Native SDK provides a wrapper for building barcode scanning, document scanning and MRZ scanning applications with React Native.",
|
|
6
6
|
"homepage": "https://github.com/Dynamsoft/capture-vision-react-native-samples",
|
|
7
7
|
"main": "src/index.tsx",
|
|
@@ -44,20 +44,5 @@
|
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"react": ">=16.8.1",
|
|
46
46
|
"react-native": ">=0.71.0-rc.0 <1.0.x"
|
|
47
|
-
},
|
|
48
|
-
"devDependencies": {
|
|
49
|
-
"@babel/preset-env": "^7.1.6",
|
|
50
|
-
"@react-native-community/cli": "13.6.4",
|
|
51
|
-
"@react-native/typescript-config": "0.75.2",
|
|
52
|
-
"@tsconfig/react-native": "3.0.0",
|
|
53
|
-
"@types/jest": "29.5.5",
|
|
54
|
-
"@types/react": "18.2.20",
|
|
55
|
-
"@types/react-native": "0.72.4",
|
|
56
|
-
"jest": "^29.7.0",
|
|
57
|
-
"prettier": "3.0.3",
|
|
58
|
-
"react": "18.3.1",
|
|
59
|
-
"react-native": "0.75.2",
|
|
60
|
-
"typedoc": "^0.27.7",
|
|
61
|
-
"typescript": "5.2.2"
|
|
62
47
|
}
|
|
63
48
|
}
|
|
@@ -30,7 +30,7 @@ const installMethods = () => {
|
|
|
30
30
|
/**
|
|
31
31
|
* The singleton instance of CaptureVisionRouter.
|
|
32
32
|
* */
|
|
33
|
-
let cvr: CaptureVisionRouter
|
|
33
|
+
let cvr: CaptureVisionRouter | null = null;
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* The CaptureVisionRouter class defines how a user interacts with image-processing and semantic-processing products in their applications.
|
|
@@ -40,9 +40,9 @@ let cvr: CaptureVisionRouter
|
|
|
40
40
|
* */
|
|
41
41
|
export class CaptureVisionRouter {
|
|
42
42
|
private constructor() {
|
|
43
|
+
CvrModule.createInstance();
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
|
|
46
46
|
/**
|
|
47
47
|
* Get the singleton instance of CaptureVisionRouter.
|
|
48
48
|
* <p>
|
|
@@ -59,6 +59,15 @@ export class CaptureVisionRouter {
|
|
|
59
59
|
return cvr = new CaptureVisionRouter();
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Destroys the CaptureVisionRouter instance and releases all associated resources.
|
|
64
|
+
* After calling this method, the instance will be set to null and cannot be used anymore.
|
|
65
|
+
* Only call this method when you want to completely dispose the CaptureVisionRouter instance, otherwise just call {@link CaptureVisionRouter.stopCapturing} to stop the capturing process.
|
|
66
|
+
*/
|
|
67
|
+
dispose() {
|
|
68
|
+
CvrModule.destroyInstance();
|
|
69
|
+
cvr = null;
|
|
70
|
+
}
|
|
62
71
|
|
|
63
72
|
/**
|
|
64
73
|
* Sets the global number of threads used internally for model execution.
|
|
@@ -57,6 +57,16 @@ export class CameraEnhancer extends ImageSourceAdapter {
|
|
|
57
57
|
return dce = new CameraEnhancer();
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
/**
|
|
61
|
+
* Destroys the CameraEnhancer instance and releases all associated resources.
|
|
62
|
+
* After calling this method, the instance will be set to null and cannot be used anymore.
|
|
63
|
+
* Only call this method when you want to completely dispose the CameraEnhancer instance, otherwise just call {@link CameraEnhancer.close} to stop the camera and release the video stream.
|
|
64
|
+
*/
|
|
65
|
+
dispose() {
|
|
66
|
+
DynamsoftCameraEnhancerModule.destroyInstance(this.isaId);
|
|
67
|
+
dce = null;
|
|
68
|
+
}
|
|
69
|
+
|
|
60
70
|
/**Opens the currently selected camera and starts the video stream.*/
|
|
61
71
|
open() {
|
|
62
72
|
DynamsoftCameraEnhancerModule.open();
|
|
@@ -30,4 +30,20 @@ export class LicenseManager {
|
|
|
30
30
|
static initLicense(license: string): Promise<void> {
|
|
31
31
|
return DynamsoftLicenseModule.initLicense(license)
|
|
32
32
|
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Sets a friendly name for the device, which can be used for easier identification in license management.
|
|
36
|
+
* @param name - The friendly name to be set for the device.
|
|
37
|
+
* */
|
|
38
|
+
static setDeviceFriendlyName(name: string) {
|
|
39
|
+
DynamsoftLicenseModule.setDeviceFriendlyName(name)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Retrieves the unique identifier (UUID) of the device, which is often used in license management to associate licenses with specific devices.
|
|
44
|
+
* @return Promise<string> - A promise that resolves with the device UUID as a string.
|
|
45
|
+
* */
|
|
46
|
+
static getDeviceUUID(): Promise<string> {
|
|
47
|
+
return DynamsoftLicenseModule.getDeviceUUID()
|
|
48
|
+
}
|
|
33
49
|
}
|