dynamsoft-capture-vision-react-native 3.2.5002 → 3.4.1000

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.
Files changed (61) hide show
  1. package/android/build.gradle +1 -1
  2. package/android/src/main/cpp/JsiCore.cpp +19 -7
  3. package/android/src/main/cpp/JsiCvr.cpp +19 -14
  4. package/android/src/main/cpp/JsiDbr.cpp +62 -2
  5. package/android/src/main/dysJniLibs/debug/arm64-v8a/librn_dys.so +0 -0
  6. package/android/src/main/dysJniLibs/debug/armeabi-v7a/librn_dys.so +0 -0
  7. package/android/src/main/dysJniLibs/debug/x86/librn_dys.so +0 -0
  8. package/android/src/main/dysJniLibs/debug/x86_64/librn_dys.so +0 -0
  9. package/android/src/main/dysJniLibs/release/arm64-v8a/librn_dys.so +0 -0
  10. package/android/src/main/dysJniLibs/release/armeabi-v7a/librn_dys.so +0 -0
  11. package/android/src/main/dysJniLibs/release/x86/librn_dys.so +0 -0
  12. package/android/src/main/dysJniLibs/release/x86_64/librn_dys.so +0 -0
  13. package/android/src/main/dysJniLibsFor81/debug/arm64-v8a/librn_dys.so +0 -0
  14. package/android/src/main/dysJniLibsFor81/debug/armeabi-v7a/librn_dys.so +0 -0
  15. package/android/src/main/dysJniLibsFor81/debug/x86/librn_dys.so +0 -0
  16. package/android/src/main/dysJniLibsFor81/debug/x86_64/librn_dys.so +0 -0
  17. package/android/src/main/dysJniLibsFor81/release/arm64-v8a/librn_dys.so +0 -0
  18. package/android/src/main/dysJniLibsFor81/release/armeabi-v7a/librn_dys.so +0 -0
  19. package/android/src/main/dysJniLibsFor81/release/x86/librn_dys.so +0 -0
  20. package/android/src/main/dysJniLibsFor81/release/x86_64/librn_dys.so +0 -0
  21. package/android/src/main/dysJniLibsFor82/debug/arm64-v8a/librn_dys.so +0 -0
  22. package/android/src/main/dysJniLibsFor82/debug/armeabi-v7a/librn_dys.so +0 -0
  23. package/android/src/main/dysJniLibsFor82/debug/x86/librn_dys.so +0 -0
  24. package/android/src/main/dysJniLibsFor82/debug/x86_64/librn_dys.so +0 -0
  25. package/android/src/main/dysJniLibsFor82/release/arm64-v8a/librn_dys.so +0 -0
  26. package/android/src/main/dysJniLibsFor82/release/armeabi-v7a/librn_dys.so +0 -0
  27. package/android/src/main/dysJniLibsFor82/release/x86/librn_dys.so +0 -0
  28. package/android/src/main/dysJniLibsFor82/release/x86_64/librn_dys.so +0 -0
  29. package/android/src/main/java/com/dynamsoft/reactnativelib/CVRModule.kt +10 -2
  30. package/android/src/main/java/com/dynamsoft/reactnativelib/DCEModule.kt +5 -2
  31. package/android/src/main/java/com/dynamsoft/reactnativelib/MultiCrossFilterModule.kt +11 -0
  32. package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForDBR.kt +15 -0
  33. package/android/src/main/java/com/dynamsoft/reactnativelib/cvr/CaptureVisionRouterModuleImpl.kt +37 -23
  34. package/android/src/main/java/com/dynamsoft/reactnativelib/dce/CameraEnhancerModuleImpl.kt +42 -24
  35. package/android/src/main/java/com/dynamsoft/reactnativelib/utility/MultiCrossFilterModuleImpl.kt +28 -2
  36. package/dynamsoft-capture-vision-react-native.podspec +1 -1
  37. package/ios/CPP/ImageDataHostObject.cpp +1 -1
  38. package/ios/CPP/RNDynamsoft+JSI.mm +34 -1
  39. package/ios/CPP/RNDynamsoft+Json.m +25 -0
  40. package/ios/RNDynamsoftCameraViewManager.m +8 -1
  41. package/ios/RNDynamsoftCaptureVisionRouter.mm +21 -6
  42. package/ios/RNDynamsoftImageEditorViewManager.mm +11 -5
  43. package/ios/RNDynamsoftImageManager.h +2 -1
  44. package/ios/RNDynamsoftImageManager.mm +11 -5
  45. package/ios/RNDynamsoftImageSourceAdapter.h +2 -1
  46. package/ios/RNDynamsoftImageSourceAdapter.mm +12 -6
  47. package/ios/RNDynamsoftMultiCrossFilter.m +39 -0
  48. package/package.json +1 -16
  49. package/src/core/ImageData.tsx +4 -1
  50. package/src/core/ImageSourceAdapter.tsx +6 -0
  51. package/src/cvr/CaptureVisionRouter.tsx +37 -12
  52. package/src/dbr/BarcodeResultItem.tsx +9 -0
  53. package/src/dbr/ECISegment.tsx +24 -0
  54. package/src/dbr/index.tsx +1 -0
  55. package/src/dce/CameraEnhancer.tsx +10 -0
  56. package/src/dce/EnumResolution.tsx +1 -0
  57. package/src/dce/ImageEditorView.tsx +3 -0
  58. package/src/utility/CrossVerificationCriteria.tsx +12 -0
  59. package/src/utility/ImageManager.tsx +39 -0
  60. package/src/utility/MultiFrameResultCrossFilter.tsx +23 -0
  61. package/src/utility/index.tsx +1 -0
@@ -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 val cvr = CaptureVisionRouter()
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.addResultReceiver(it) }
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.removeResultReceiver(it) }
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.removeResultReceiver(it.value)
136
+ cvr?.removeResultReceiver(it.value)
123
137
  }
124
138
  }
125
139
 
126
140
  @ReactMethod
127
141
  fun addFilter(filterId: String?) {
128
- cvr.addResultFilter(filterMap[filterId])
142
+ cvr?.addResultFilter(filterMap[filterId])
129
143
  }
130
144
 
131
145
  @ReactMethod
132
146
  fun removeFilter(filterId: String?) {
133
- cvr.removeResultFilter(filterMap[filterId])
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.startCapturing(template, object : CompletionListener {
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.stopCapturing()
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.input = this }
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.resetSettings()
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.getSimplifiedSettings(template).toWritableMap())
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.getSimplifiedSettings(template).apply {
200
+ cvr?.getSimplifiedSettings(template)?.apply {
187
201
  updateFromReadableMap(settings)
188
- cvr.updateSettings(template, this)
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.initSettings(content)
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.initSettingsFromFile(path)
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.outputSettingsToFile(template, path, includeDefaultValues)
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.outputSettings(template, includeDefaultValues))
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.switchCapturingTemplate(template)
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.capture(imageData, template)
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.capture(filePath, template)
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.capture(fileBytes, template)
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.intermediateResultManager.getOriginalImage(imageHashId)
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 = CameraEnhancer(cameraLifecycleOwner).apply {
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.cameraView == null || camera.cameraView?.id != currentCameraViewId)) {
87
- findAndSetCameraView(currentCameraViewId!!) { camera.open() }
101
+ if (currentCameraViewId != null && (camera?.cameraView == null || camera?.cameraView?.id != currentCameraViewId)) {
102
+ findAndSetCameraView(currentCameraViewId!!) { camera?.open() }
88
103
  } else {
89
- camera.open()
104
+ camera?.open()
90
105
  }
91
106
  }
92
107
 
93
108
  @ReactMethod
94
109
  fun close() {
95
110
  ifOpenCalled = false
96
- camera.close()
111
+ camera?.close()
97
112
  }
98
113
 
99
114
  @ReactMethod
@@ -107,76 +122,78 @@ class CameraEnhancerModuleImpl(private val reactContext: ReactApplicationContext
107
122
 
108
123
  @ReactMethod
109
124
  fun selectCamera(@EnumCameraPosition position: Int) {
110
- camera.selectCamera(position)
125
+ camera?.selectCamera(position)
111
126
  }
112
127
 
113
128
  @ReactMethod
114
129
  fun getCameraPosition(promise: Promise) {
115
- promise.resolve(camera.cameraPosition)
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.setFocus(PointF(x, y), focusMode)
135
+ camera?.setFocus(PointF(x, y), focusMode)
121
136
  }
122
137
 
123
138
  @ReactMethod
124
139
  fun getFocusMode(promise: Promise) {
125
- promise.resolve(camera.focusMode)
140
+ promise.resolve(camera?.focusMode)
126
141
  }
127
142
 
128
143
  @ReactMethod
129
144
  fun setZoomFactor(factor: Float) {
130
- camera.zoomFactor = factor
145
+ camera?.zoomFactor = factor
131
146
  }
132
147
 
133
148
  @ReactMethod
134
149
  fun getZoomFactor(promise: Promise) {
135
- promise.resolve(camera.zoomFactor)
150
+ promise.resolve(camera?.zoomFactor)
136
151
  }
137
152
 
138
153
  @ReactMethod
139
154
  fun enableEnhancedFeatures(features: Int) {
140
- camera.enableEnhancedFeatures(features)
155
+ camera?.enableEnhancedFeatures(features)
141
156
  }
142
157
 
143
158
  @ReactMethod
144
159
  fun disableEnhancedFeatures(features: Int) {
145
- camera.disableEnhancedFeatures(features)
160
+ camera?.disableEnhancedFeatures(features)
146
161
  }
147
162
 
148
163
  @ReactMethod
149
164
  fun setScanRegion(region: ReadableMap?) {
150
- camera.scanRegion = region?.toScanRegion()
165
+ camera?.scanRegion = region?.toScanRegion()
151
166
  }
152
167
 
153
168
  @ReactMethod
154
169
  fun getScanRegion(promise: Promise) {
155
- promise.resolve(camera.scanRegion?.toWritableMap())
170
+ promise.resolve(camera?.scanRegion?.toWritableMap())
156
171
  }
157
172
 
158
173
  @ReactMethod
159
174
  fun turnOnTorch() {
160
- camera.turnOnTorch()
175
+ camera?.turnOnTorch()
161
176
  }
162
177
 
163
178
  @ReactMethod
164
179
  fun turnOffTorch() {
165
- camera.turnOffTorch()
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.setResolution(EnumResolution.RESOLUTION_4K)
187
+ camera?.setResolution(EnumResolution.RESOLUTION_4K)
188
+ } else if(resolution == 5) {
189
+ camera?.setResolution(EnumResolution.RESOLUTION_MAX)
173
190
  } else {
174
- camera.setResolution(resolution)
191
+ camera?.setResolution(resolution)
175
192
  }
176
193
  }
177
194
  @ReactMethod
178
195
  fun getResolution(promise: Promise) {
179
- val resolution = camera.resolution ?: Size(0,0)
196
+ val resolution = camera?.resolution ?: Size(0,0)
180
197
  promise.resolve(Arguments.createMap().apply {
181
198
  putInt("width", resolution.width)
182
199
  putInt("height", resolution.height)
@@ -201,7 +218,8 @@ class CameraEnhancerModuleImpl(private val reactContext: ReactApplicationContext
201
218
  return@launch
202
219
  }
203
220
  MainScope().launch {
204
- camera.cameraView = cameraView
221
+ Log.e(TAG, "findAndSetCameraView: before setCameraView $camera ${cameraView.id}", )
222
+ camera?.cameraView = cameraView
205
223
  afterSetCameraView()
206
224
  }
207
225
  }
@@ -1,10 +1,13 @@
1
1
  package com.dynamsoft.reactnativelib.utility
2
2
 
3
3
  import com.dynamsoft.reactnativelib.cvr.filterMap
4
+ import com.dynamsoft.utility.CrossVerificationCriteria
4
5
  import com.dynamsoft.utility.MultiFrameResultCrossFilter
6
+ import com.facebook.react.bridge.Arguments
5
7
  import com.facebook.react.bridge.Promise
6
8
  import com.facebook.react.bridge.ReactApplicationContext
7
9
  import com.facebook.react.bridge.ReactMethod
10
+ import com.facebook.react.bridge.ReadableMap
8
11
 
9
12
  class MultiCrossFilterModuleImpl(context: ReactApplicationContext) {
10
13
  companion object {
@@ -13,8 +16,8 @@ class MultiCrossFilterModuleImpl(context: ReactApplicationContext) {
13
16
 
14
17
  fun getName() = NAME
15
18
 
16
- private fun getMultiCrossFilterById(filterId: String) : MultiFrameResultCrossFilter? {
17
- return if(filterMap[filterId] is MultiFrameResultCrossFilter) {
19
+ private fun getMultiCrossFilterById(filterId: String): MultiFrameResultCrossFilter? {
20
+ return if (filterMap[filterId] is MultiFrameResultCrossFilter) {
18
21
  filterMap[filterId] as MultiFrameResultCrossFilter
19
22
  } else {
20
23
  null
@@ -82,4 +85,27 @@ class MultiCrossFilterModuleImpl(context: ReactApplicationContext) {
82
85
  fun setMaxOverlappingFrames(filterId: String, resultItemTypes: Int, maxFrameToCheck: Int) {
83
86
  getMultiCrossFilterById(filterId)?.setMaxOverlappingFrames(resultItemTypes, maxFrameToCheck)
84
87
  }
88
+
89
+ @ReactMethod
90
+ fun setResultCrossVerificationCriteria(filterId: String, resultItemTypes: Int, criteria: ReadableMap) {
91
+ getMultiCrossFilterById(filterId)?.setResultCrossVerificationCriteria(resultItemTypes, criteria.run {
92
+ CrossVerificationCriteria(
93
+ criteria.getInt("frameWindow"),
94
+ criteria.getInt("minConsistentFrames"),
95
+ )
96
+ })
97
+ }
98
+
99
+ @ReactMethod
100
+ fun getResultCrossVerificationCriteria(filterId: String, resultItemType: Int, promise: Promise) {
101
+ val criteria = getMultiCrossFilterById(filterId)?.getResultCrossVerificationCriteria(resultItemType)
102
+ if (criteria != null) {
103
+ promise.resolve(Arguments.createMap().apply {
104
+ putInt("frameWindow", criteria.frameWindow)
105
+ putInt("minConsistentFrames", criteria.minConsistentFrames)
106
+ })
107
+ } else {
108
+ promise.resolve(null)
109
+ }
110
+ }
85
111
  }
@@ -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.2.5000", "< 4.0"
20
+ s.dependency "DynamsoftCaptureVisionBundle", ">= 3.4.1000", "< 4.0"
21
21
 
22
22
  install_modules_dependencies(s)
23
23
  end
@@ -47,7 +47,7 @@ Value ImageDataHostObject::get(Runtime &runtime, const PropNameID &propName) {
47
47
  return arrayBuffer;
48
48
  }
49
49
  if (name == "release") {
50
- auto release = [=](Runtime & runtime, const Value& thisValue, const Value* arguments, size_t count) -> Value {
50
+ auto release = [=, this](Runtime & runtime, const Value& thisValue, const Value* arguments, size_t count) -> Value {
51
51
  if(buffer != nullptr) {
52
52
  delete[] buffer;
53
53
  buffer = nullptr;
@@ -30,6 +30,20 @@ NSArray<NSNumber *> *CGAffineTransformToArray(CGAffineTransform transform) {
30
30
 
31
31
  @end
32
32
 
33
+ @implementation DSECISegment (JSI)
34
+
35
+ - (nullable NSDictionary *)toJson {
36
+ if (!self) return nil;
37
+ return @{
38
+ @"eciValue" : @(self.eciValue),
39
+ @"charsetEncoding" : self.charsetEncoding,
40
+ @"startIndex" : @(self.startIndex),
41
+ @"length" : @(self.length)
42
+ };
43
+ }
44
+
45
+ @end
46
+
33
47
  @implementation DSCapturedResultItem (JSI)
34
48
 
35
49
  - (Object)convertToJSIObject:(Runtime& )runtime {
@@ -50,6 +64,7 @@ NSArray<NSNumber *> *CGAffineTransformToArray(CGAffineTransform transform) {
50
64
  obj.setProperty(runtime, "_formatNumberString", convertNSStringToJSIString(runtime, [NSNumber numberWithUnsignedInteger:item.format].stringValue));
51
65
  obj.setProperty(runtime, "formatString", convertNSStringToJSIString(runtime, item.formatString));
52
66
  obj.setProperty(runtime, "text", convertNSStringToJSIString(runtime, item.text));
67
+ obj.setProperty(runtime, "bytes", convertNSStringToJSIString(runtime, [item.bytes base64EncodedStringWithOptions:0]));
53
68
  obj.setProperty(runtime, "location", convertNSDictionaryToJSIObject(runtime, [item.location toJson]));
54
69
  obj.setProperty(runtime, "confidence", convertNSNumberToJSINumber(runtime, @(item.confidence)));
55
70
  obj.setProperty(runtime, "angle", convertNSNumberToJSINumber(runtime, @(item.angle)));
@@ -133,6 +148,16 @@ NSArray<NSNumber *> *CGAffineTransformToArray(CGAffineTransform transform) {
133
148
  obj.setProperty(runtime, "pdf417Details", convertNSDictionaryToJSIObject(runtime, [pdf417Dict copy]));
134
149
  }
135
150
  }
151
+ NSArray<DSECISegment *> *eciSegments = item.eciSegments;
152
+ if (eciSegments && eciSegments.count > 0) {
153
+ NSMutableArray<NSDictionary *> *mutableArray = [NSMutableArray arrayWithCapacity:eciSegments.count];
154
+ for (DSECISegment *eci in eciSegments) {
155
+ [mutableArray addObject:[eci toJson]];
156
+ }
157
+ obj.setProperty(runtime, "eciSegments", convertNSArrayToJSIArray(runtime, [mutableArray copy]));
158
+ } else {
159
+ obj.setProperty(runtime, "eciSegments", jsi::Value::null());
160
+ }
136
161
  }
137
162
  break;
138
163
  case DSCapturedResultItemTypeTextLine:
@@ -142,13 +167,15 @@ NSArray<NSNumber *> *CGAffineTransformToArray(CGAffineTransform transform) {
142
167
  obj.setProperty(runtime, "rawText", convertNSStringToJSIString(runtime, item.rawText));
143
168
  obj.setProperty(runtime, "location", convertNSDictionaryToJSIObject(runtime, [item.location toJson]));
144
169
  obj.setProperty(runtime, "confidence",convertNSNumberToJSINumber(runtime, @(item.confidence)));
145
- int count = item.charResult.count;
170
+ NSUInteger count = item.charResult.count;
146
171
  if (count > 0) {
147
172
  jsi::Array array = jsi::Array(runtime, count);
148
173
  for (size_t i = 0; i < count; i++) {
149
174
  array.setValueAtIndex(runtime, i, convertNSDictionaryToJSIObject(runtime, [[item.charResult objectAtIndex:i] toJson]));
150
175
  }
151
176
  obj.setProperty(runtime, "characterResults", array);
177
+ } else {
178
+ obj.setProperty(runtime, "characterResults", jsi::Value::null());
152
179
  }
153
180
  obj.setProperty(runtime, "specificationName", convertNSStringToJSIString(runtime, item.specificationName));
154
181
  }
@@ -167,6 +194,8 @@ NSArray<NSNumber *> *CGAffineTransformToArray(CGAffineTransform transform) {
167
194
  ImageDataHostObject hostObject = [item.imageData hostObject];
168
195
  Object object = Object::createFromHostObject(runtime, std::make_shared<ImageDataHostObject>(hostObject));
169
196
  obj.setProperty(runtime, "imageData", object);
197
+ } else {
198
+ obj.setProperty(runtime, "imageData", jsi::Value::null());
170
199
  }
171
200
  obj.setProperty(runtime, "sourceDeskewQuad", convertNSDictionaryToJSIObject(runtime, [item.sourceDeskewQuad toJson]));
172
201
  obj.setProperty(runtime, "crossVerificationStatus", convertNSNumberToJSINumber(runtime, @(item.crossVerificationStatus)));
@@ -180,6 +209,8 @@ NSArray<NSNumber *> *CGAffineTransformToArray(CGAffineTransform transform) {
180
209
  ImageDataHostObject hostObject = [item.imageData hostObject];
181
210
  Object object = Object::createFromHostObject(runtime, std::make_shared<ImageDataHostObject>(hostObject));
182
211
  obj.setProperty(runtime, "imageData", object);
212
+ } else {
213
+ obj.setProperty(runtime, "imageData", jsi::Value::null());
183
214
  }
184
215
  obj.setProperty(runtime, "originalToLocalMatrix", convertNSArrayToJSIArray(runtime, CGAffineTransformToArray(item.originalToLocalMatrix)));
185
216
  break;
@@ -220,6 +251,8 @@ NSArray<NSNumber *> *CGAffineTransformToArray(CGAffineTransform transform) {
220
251
  array.setValueAtIndex(runtime, i, [[self.items objectAtIndex:i] convertToJSIObject:runtime]);
221
252
  }
222
253
  obj.setProperty(runtime, "items", array);
254
+ } else {
255
+ obj.setProperty(runtime, "items", jsi::Value::null());
223
256
  }
224
257
  return obj;
225
258
  }
@@ -334,6 +334,20 @@ void runOnMainThread(void (^block)(void))
334
334
 
335
335
  @end
336
336
 
337
+ @implementation DSECISegment (JSI)
338
+
339
+ - (nullable NSDictionary *)toJson {
340
+ if (!self) return nil;
341
+ return @{
342
+ @"eciValue" : @(self.eciValue),
343
+ @"charsetEncoding" : self.charsetEncoding,
344
+ @"startIndex" : @(self.startIndex),
345
+ @"length" : @(self.length)
346
+ };
347
+ }
348
+
349
+ @end
350
+
337
351
  @implementation DSCapturedResultItem (Json)
338
352
 
339
353
  - (nullable NSDictionary *)toJson {
@@ -352,6 +366,7 @@ void runOnMainThread(void (^block)(void))
352
366
  @"_formatNumberString": [NSNumber numberWithUnsignedInteger:item.format].stringValue,
353
367
  @"formatString":item.formatString,
354
368
  @"text":item.text,
369
+ @"bytes":[item.bytes base64EncodedStringWithOptions:0],
355
370
  @"location":[item.location toJson],
356
371
  @"confidence":@(item.confidence),
357
372
  @"angle":@(item.angle),
@@ -437,6 +452,16 @@ void runOnMainThread(void (^block)(void))
437
452
  mutableDictionary[@"pdf417Details"] = pdf417Dict;
438
453
  }
439
454
  }
455
+ NSArray<DSECISegment *> *eciSegments = item.eciSegments;
456
+ if (eciSegments && eciSegments.count > 0) {
457
+ NSMutableArray<NSDictionary *> *mutableArray = [NSMutableArray arrayWithCapacity:eciSegments.count];
458
+ for (DSECISegment *eci in eciSegments) {
459
+ [mutableArray addObject:[eci toJson]];
460
+ }
461
+ mutableDictionary[@"eciSegments"] = [mutableArray copy];
462
+ } else {
463
+ mutableDictionary[@"eciSegments"] = [NSNull null];
464
+ }
440
465
  dictionary = [mutableDictionary copy];
441
466
  }
442
467
  break;
@@ -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
  }
@@ -359,17 +368,23 @@ RCT_EXPORT_METHOD(removeFilter:(NSString *)key) {
359
368
  // --- RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install) ---
360
369
  RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install)
361
370
  {
362
- RCTBridge* bridge = [RCTBridge currentBridge];
363
- RCTCxxBridge* cxxBridge = (RCTCxxBridge*)bridge;
364
- if (cxxBridge == nil) {
371
+ RCTBridge *bridge = self.bridge;
372
+
373
+ if ([bridge respondsToSelector:NSSelectorFromString(@"parentBridge")]) {
374
+ bridge = [bridge valueForKey:@"parentBridge"];
375
+ }
376
+
377
+ RCTCxxBridge *cxxBridge = (RCTCxxBridge *)bridge;
378
+ if (cxxBridge == nil || cxxBridge.runtime == nil) {
365
379
  return @false;
366
380
  }
381
+
367
382
  auto jsiRuntime = (jsi::Runtime*) cxxBridge.runtime;
368
383
  if (jsiRuntime == nil) {
369
384
  return @false;
370
385
  }
371
386
 
372
- install(*(facebook::jsi::Runtime *)jsiRuntime, self);
387
+ install(*(facebook::jsi::Runtime *)cxxBridge.runtime, self);
373
388
  return @true;
374
389
  }
375
390
 
@@ -377,7 +392,7 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install)
377
392
  static void installHostFunction(
378
393
  jsi::Runtime &jsiRuntime,
379
394
  const char* name,
380
- size_t argCount,
395
+ unsigned int argCount,
381
396
  HostFunctionType hostFunction) {
382
397
 
383
398
  auto func = Function::createFromHostFunction(