dynamsoft-capture-vision-react-native 2.6.1015 → 3.0.3100
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 +2 -2
- package/README.md +7 -9
- package/android/build.gradle +29 -42
- package/android/src/{oldarch → main/java}/com/dynamsoft/reactnativelib/CVRModule.kt +4 -4
- package/android/src/main/java/com/dynamsoft/reactnativelib/ReactNativeDcvPackage.kt +13 -85
- package/android/src/{oldarch → main/java}/com/dynamsoft/reactnativelib/VersionsModule.kt +2 -2
- package/android/src/main/java/com/dynamsoft/reactnativelib/cvr/CaptureVisionRouterModuleImpl.kt +23 -25
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/CameraEnhancerModuleImpl.kt +2 -2
- package/android/src/main/java/com/dynamsoft/reactnativelib/license/LicenseModuleImpl.kt +1 -1
- package/android/src/main/java/com/dynamsoft/reactnativelib/utility/ImageManagerModuleImpl.kt +19 -4
- package/android/src/main/java/com/dynamsoft/reactnativelib/utils/ForCore.kt +14 -0
- package/android/src/main/java/com/dynamsoft/reactnativelib/utils/ForCvr.kt +12 -7
- package/android/src/main/java/com/dynamsoft/reactnativelib/utils/ForDBR.kt +1 -7
- package/android/src/main/java/com/dynamsoft/reactnativelib/utils/ForDCE.kt +2 -2
- package/android/src/main/java/com/dynamsoft/reactnativelib/utils/ForDDN.kt +27 -19
- package/android/src/main/jniLibs/debug/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/jniLibs/debug/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/jniLibs/debug/x86/librn_dys.so +0 -0
- package/android/src/main/jniLibs/debug/x86_64/librn_dys.so +0 -0
- package/android/src/main/jniLibs/release/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/jniLibs/release/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/jniLibs/release/x86/librn_dys.so +0 -0
- package/android/src/main/jniLibs/release/x86_64/librn_dys.so +0 -0
- package/dynamsoft-capture-vision-react-native.podspec +9 -7
- package/ios/CPP/DSImageData+HostObject.h +1 -1
- package/ios/CPP/RNDynamsoft+JSI.h +2 -2
- package/ios/CPP/RNDynamsoft+JSI.mm +18 -10
- package/ios/CPP/RNDynamsoft+Json.h +2 -13
- package/ios/CPP/RNDynamsoft+Json.m +48 -39
- package/ios/CPP/YeetJSIUtils.h +3 -1
- package/ios/CPP/YeetJSIUtils.mm +5 -0
- package/ios/RNDynamsoftCameraView.m +1 -1
- package/ios/RNDynamsoftCameraViewManager.m +18 -6
- package/ios/RNDynamsoftCaptureVisionRouter.mm +76 -45
- package/ios/RNDynamsoftImageEditorView.m +1 -1
- package/ios/RNDynamsoftImageEditorViewManager.mm +36 -13
- package/ios/RNDynamsoftImageManager.mm +33 -4
- package/ios/RNDynamsoftImageSourceAdapter.mm +1 -1
- package/ios/RNDynamsoftLicense.m +1 -1
- package/ios/RNDynamsoftMultiCrossFilter.m +9 -9
- package/ios/RNDynamsoftVersions.m +1 -13
- package/package.json +3 -11
- package/src/core/CapturedResultBase.tsx +18 -0
- package/src/core/EnumCaptureResultItemType.tsx +12 -6
- package/src/core/EnumCrossVerificationStatus.tsx +6 -6
- package/src/core/ImageData.tsx +1 -1
- package/src/core/index.tsx +1 -0
- package/src/cvr/CaptureVisionRouter.tsx +47 -51
- package/src/cvr/CapturedResult.tsx +24 -46
- package/src/cvr/CapturedResultReceiver.tsx +12 -19
- package/src/cvr/NativeDynamsoftCaptureVisionRouterModule.tsx +2 -2
- package/src/cvr/SimplifiedCaptureVisionSettings.tsx +4 -4
- package/src/dbr/DecodedBarcodesResult.tsx +3 -17
- package/src/dce/DynamsoftCameraViewNativeComponent.ts +2 -2
- package/src/dcp/ParsedResult.tsx +3 -14
- package/src/ddn/DeskewedImageResultItem.tsx +40 -0
- package/src/ddn/DetectedQuadResultItem.tsx +3 -1
- package/src/ddn/EnhancedImageResultItem.tsx +20 -0
- package/src/ddn/ProcessedDocumentResult.tsx +27 -0
- package/src/ddn/SimplifiedDocumentNormalizerSettings.tsx +18 -3
- package/src/ddn/index.tsx +3 -3
- package/src/dlr/RecognizedTextLinesResult.tsx +2 -16
- package/src/index.tsx +0 -1
- package/src/utility/ImageManager.tsx +66 -45
- package/android/src/main/java/com/dynamsoft/reactnativelib/rtu/BarcodeScannerModuleImpl.kt +0 -80
- package/android/src/main/java/com/dynamsoft/reactnativelib/rtu/MRZScannerModuleImpl.kt +0 -77
- package/android/src/main/java/com/dynamsoft/reactnativelib/rtu/ScannerInterface.kt +0 -47
- package/android/src/main/jniLibs/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/jniLibs/x86/librn_dys.so +0 -0
- package/android/src/main/jniLibs/x86_64/librn_dys.so +0 -0
- package/android/src/newarch/com/dynamsoft/reactnativelib/BarcodeScannerModule.kt +0 -22
- package/android/src/newarch/com/dynamsoft/reactnativelib/CVRModule.kt +0 -91
- package/android/src/newarch/com/dynamsoft/reactnativelib/CameraViewManager.kt +0 -52
- package/android/src/newarch/com/dynamsoft/reactnativelib/DCEModule.kt +0 -91
- package/android/src/newarch/com/dynamsoft/reactnativelib/ISAModule.kt +0 -60
- package/android/src/newarch/com/dynamsoft/reactnativelib/ImageEditorViewManager.kt +0 -16
- package/android/src/newarch/com/dynamsoft/reactnativelib/ImageEditorViewModule.kt +0 -24
- package/android/src/newarch/com/dynamsoft/reactnativelib/ImageManagerModule.kt +0 -12
- package/android/src/newarch/com/dynamsoft/reactnativelib/LicenseModule.kt +0 -14
- package/android/src/newarch/com/dynamsoft/reactnativelib/MRZScannerModule.kt +0 -22
- package/android/src/newarch/com/dynamsoft/reactnativelib/MultiCrossFilterModule.kt +0 -58
- package/android/src/newarch/com/dynamsoft/reactnativelib/VersionsModule.kt +0 -41
- package/android/src/oldarch/com/dynamsoft/reactnativelib/BarcodeScannerModule.kt +0 -24
- package/android/src/oldarch/com/dynamsoft/reactnativelib/MRZScannerModule.kt +0 -24
- package/ios/RNDynamsoftBarcodeScanner.h +0 -14
- package/ios/RNDynamsoftBarcodeScanner.m +0 -169
- package/ios/RNDynamsoftMRZScanner.h +0 -14
- package/ios/RNDynamsoftMRZScanner.m +0 -140
- package/src/ddn/DetectedQuadsResult.tsx +0 -31
- package/src/ddn/NormalizedImageResultItem.tsx +0 -32
- package/src/ddn/NormalizedImagesResult.tsx +0 -27
- package/src/rtu/BarcodeScanConfig.tsx +0 -104
- package/src/rtu/BarcodeScanResult.tsx +0 -31
- package/src/rtu/BarcodeScanner.tsx +0 -112
- package/src/rtu/EnumResultState.tsx +0 -21
- package/src/rtu/MRZScanConfig.tsx +0 -67
- package/src/rtu/MRZScanResult.tsx +0 -84
- package/src/rtu/MRZScanner.tsx +0 -90
- package/src/rtu/NativeDynamsoftBarcodeScannerModule.tsx +0 -6
- package/src/rtu/NativeDynamsoftMRZScannerModule.tsx +0 -6
- package/src/rtu/index.tsx +0 -7
- /package/android/src/main/{withNamespace/AndroidManifest.xml → AndroidManifest.xml} +0 -0
- /package/android/src/main/{withoutNamespace/AndroidManifest.xml → AndroidManifest_noPackage.xml} +0 -0
- /package/android/src/{oldarch → main/java}/com/dynamsoft/reactnativelib/CameraViewManager.kt +0 -0
- /package/android/src/{oldarch → main/java}/com/dynamsoft/reactnativelib/DCEModule.kt +0 -0
- /package/android/src/{oldarch → main/java}/com/dynamsoft/reactnativelib/ISAModule.kt +0 -0
- /package/android/src/{oldarch → main/java}/com/dynamsoft/reactnativelib/ImageEditorViewManager.kt +0 -0
- /package/android/src/{oldarch → main/java}/com/dynamsoft/reactnativelib/ImageEditorViewModule.kt +0 -0
- /package/android/src/{oldarch → main/java}/com/dynamsoft/reactnativelib/ImageManagerModule.kt +0 -0
- /package/android/src/{oldarch → main/java}/com/dynamsoft/reactnativelib/LicenseModule.kt +0 -0
- /package/android/src/{oldarch → main/java}/com/dynamsoft/reactnativelib/MultiCrossFilterModule.kt +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
package com.dynamsoft.reactnative.basicutils
|
|
2
2
|
|
|
3
3
|
import com.dynamsoft.core.basic_structures.CapturedResultItem
|
|
4
|
+
import com.dynamsoft.ddn.DeskewedImageResultItem
|
|
4
5
|
import com.dynamsoft.ddn.DetectedQuadResultItem
|
|
5
|
-
import com.dynamsoft.ddn.
|
|
6
|
-
import com.dynamsoft.ddn.
|
|
7
|
-
import com.dynamsoft.ddn.NormalizedImagesResult
|
|
6
|
+
import com.dynamsoft.ddn.EnhancedImageResultItem
|
|
7
|
+
import com.dynamsoft.ddn.ProcessedDocumentResult
|
|
8
8
|
import com.dynamsoft.ddn.SimplifiedDocumentNormalizerSettings
|
|
9
9
|
import com.dynamsoft.reactnativelib.utils.toIntArray
|
|
10
10
|
import com.dynamsoft.reactnativelib.utils.toWritableArray
|
|
@@ -14,6 +14,13 @@ import com.facebook.react.bridge.WritableArray
|
|
|
14
14
|
import com.facebook.react.bridge.WritableMap
|
|
15
15
|
|
|
16
16
|
|
|
17
|
+
fun ProcessedDocumentResult.toWritableMap(): WritableMap = Arguments.createMap().apply {
|
|
18
|
+
merge(this@toWritableMap.toSharedWritableMap())
|
|
19
|
+
putArray("deskewedImageResultItems", deskewedImageResultItems.toWritableArray())
|
|
20
|
+
putArray("detectedQuadResultItems", detectedQuadResultItems.toWritableArray())
|
|
21
|
+
putArray("enhancedImageResultItems", enhancedImageResultItems.toWritableArray())
|
|
22
|
+
}
|
|
23
|
+
|
|
17
24
|
fun DetectedQuadResultItem.toWritableMap(): WritableMap = Arguments.createMap().apply {
|
|
18
25
|
merge((this@toWritableMap as CapturedResultItem).toSharedWritableMap())
|
|
19
26
|
putMap("location", location.toWritableMap())
|
|
@@ -26,33 +33,29 @@ fun Array<out DetectedQuadResultItem>.toWritableArray(): WritableArray = Argumen
|
|
|
26
33
|
forEach { pushMap(it.toWritableMap()) }
|
|
27
34
|
}
|
|
28
35
|
|
|
29
|
-
fun DetectedQuadsResult.toWritableMap(): WritableMap = Arguments.createMap().apply {
|
|
30
|
-
putInt("errorCode", errorCode)
|
|
31
|
-
putString("originalImageHashId", originalImageHashId)
|
|
32
|
-
putString("errorMessage", errorMessage)
|
|
33
|
-
putArray("items", items.toWritableArray())
|
|
34
|
-
putArray("rotationTransformMatrix",FloatArray(9).apply { rotationTransformMatrix.getValues(this) }.toWritableArray())
|
|
35
|
-
}
|
|
36
36
|
|
|
37
|
-
fun
|
|
37
|
+
fun DeskewedImageResultItem.toWritableMap(): WritableMap = Arguments.createMap().apply {
|
|
38
38
|
merge((this@toWritableMap as CapturedResultItem).toSharedWritableMap())
|
|
39
|
-
putMap("
|
|
39
|
+
putMap("sourceDeskewQuad", sourceDeskewQuad.toWritableMap())
|
|
40
40
|
putInt("crossVerificationStatus", crossVerificationStatus)
|
|
41
|
+
putArray("originalToLocalMatrix", FloatArray(9).apply { originalToLocalMatrix.getValues(this) }.toWritableArray())
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
fun Array<out
|
|
44
|
+
fun Array<out DeskewedImageResultItem>.toWritableArray(): WritableArray = Arguments.createArray().apply {
|
|
44
45
|
forEach { pushMap(it.toWritableMap()) }
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
fun
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
fun EnhancedImageResultItem.toWritableMap(): WritableMap = Arguments.createMap().apply {
|
|
49
|
+
merge((this@toWritableMap as CapturedResultItem).toSharedWritableMap())
|
|
50
|
+
putArray("originalToLocalMatrix", FloatArray(9).apply { originalToLocalMatrix.getValues(this) }.toWritableArray())
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
fun Array<out EnhancedImageResultItem>.toWritableArray(): WritableArray = Arguments.createArray().apply {
|
|
54
|
+
forEach { pushMap(it.toWritableMap()) }
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
|
|
58
|
+
|
|
56
59
|
fun SimplifiedDocumentNormalizerSettings.toWritableMap(): WritableMap = Arguments.createMap().apply {
|
|
57
60
|
putArray("grayscaleTransformationModes", grayscaleTransformationModes.toWritableArray())
|
|
58
61
|
putArray("grayscaleEnhancementModes", grayscaleEnhancementModes.toWritableArray())
|
|
@@ -62,6 +65,8 @@ fun SimplifiedDocumentNormalizerSettings.toWritableMap(): WritableMap = Argument
|
|
|
62
65
|
putInt("contrast", contrast)
|
|
63
66
|
putInt("maxThreadsInOneTask", maxThreadsInOneTask)
|
|
64
67
|
putInt("scaleDownThreshold", scaleDownThreshold)
|
|
68
|
+
putInt("minQuadrilateralAreaRatio", minQuadrilateralAreaRatio)
|
|
69
|
+
putInt("expectedDocumentsCount", expectedDocumentsCount)
|
|
65
70
|
}
|
|
66
71
|
|
|
67
72
|
fun SimplifiedDocumentNormalizerSettings.updateFromReadableMap(newSettings: ReadableMap) {
|
|
@@ -77,4 +82,7 @@ fun SimplifiedDocumentNormalizerSettings.updateFromReadableMap(newSettings: Read
|
|
|
77
82
|
|
|
78
83
|
grayscaleEnhancementModes = if (newSettings.hasKey("grayscaleEnhancementModes"))
|
|
79
84
|
newSettings.getArray("grayscaleEnhancementModes")?.toIntArray() else grayscaleEnhancementModes
|
|
85
|
+
|
|
86
|
+
minQuadrilateralAreaRatio = if (newSettings.hasKey("minQuadrilateralAreaRatio")) newSettings.getInt("minQuadrilateralAreaRatio") else minQuadrilateralAreaRatio
|
|
87
|
+
expectedDocumentsCount = if (newSettings.hasKey("expectedDocumentsCount")) newSettings.getInt("expectedDocumentsCount") else expectedDocumentsCount
|
|
80
88
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
require "json"
|
|
3
2
|
|
|
4
3
|
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
@@ -10,13 +9,16 @@ Pod::Spec.new do |s|
|
|
|
10
9
|
s.homepage = package["homepage"]
|
|
11
10
|
s.license = package["license"]
|
|
12
11
|
s.authors = { package["author"]["name"] => package["author"]["email"] }
|
|
13
|
-
|
|
14
|
-
s.
|
|
12
|
+
|
|
13
|
+
s.platforms = { :ios => "13.0" }
|
|
14
|
+
s.source = { :http => "https://registry.npmjs.org/#{s.name}/-/#{s.name}-#{s.version}.tgz" }
|
|
15
|
+
|
|
15
16
|
s.source_files = "ios/**/*.{h,hpp,c,cc,cpp,m,mm,swift}"
|
|
17
|
+
s.private_header_files = "ios/**/*.h"
|
|
16
18
|
s.requires_arc = true
|
|
17
|
-
|
|
18
|
-
s.dependency "DynamsoftCaptureVisionBundle", "
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
|
|
20
|
+
s.dependency "DynamsoftCaptureVisionBundle", ">= 3.0.3000", "< 4.0"
|
|
21
|
+
|
|
22
|
+
install_modules_dependencies(s)
|
|
21
23
|
end
|
|
22
24
|
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Copyright © Dynamsoft Corporation. All rights reserved.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
#import <
|
|
6
|
-
#import <
|
|
5
|
+
#import <DynamsoftCaptureVisionBundle/DSCapturedResult.h>
|
|
6
|
+
#import <DynamsoftCaptureVisionBundle/DSQuadrilateral.h>
|
|
7
7
|
#import <jsi/jsi.h>
|
|
8
8
|
|
|
9
9
|
NS_ASSUME_NONNULL_BEGIN
|
|
@@ -6,12 +6,7 @@
|
|
|
6
6
|
#import "RNDynamsoft+Json.h"
|
|
7
7
|
#import "DSImageData+HostObject.h"
|
|
8
8
|
#import "YeetJSIUtils.h"
|
|
9
|
-
#import <
|
|
10
|
-
#import <DynamsoftCaptureVisionRouter/DynamsoftCaptureVisionRouter.h>
|
|
11
|
-
#import <DynamsoftBarcodeReader/DynamsoftBarcodeReader.h>
|
|
12
|
-
#import <DynamsoftLabelRecognizer/DynamsoftLabelRecognizer.h>
|
|
13
|
-
#import <DynamsoftDocumentNormalizer/DynamsoftDocumentNormalizer.h>
|
|
14
|
-
#import <DynamsoftCodeParser/DynamsoftCodeParser.h>
|
|
9
|
+
#import <DynamsoftCaptureVisionBundle/DynamsoftCaptureVisionBundle.h>
|
|
15
10
|
|
|
16
11
|
NSArray<NSNumber *> *CGAffineTransformToArray(CGAffineTransform transform) {
|
|
17
12
|
return @[@(transform.a), @(transform.b), @(transform.c), @(transform.d), @(transform.tx), @(transform.ty)];
|
|
@@ -67,17 +62,30 @@ NSArray<NSNumber *> *CGAffineTransformToArray(CGAffineTransform transform) {
|
|
|
67
62
|
obj.setProperty(runtime, "confidenceAsDocumentBoundary",convertNSNumberToJSINumber(runtime, @(item.confidenceAsDocumentBoundary)));
|
|
68
63
|
}
|
|
69
64
|
break;
|
|
70
|
-
case
|
|
65
|
+
case DSCapturedResultItemTypeDeskewedImage:
|
|
71
66
|
{
|
|
72
|
-
|
|
67
|
+
DSDeskewedImageResultItem *item = (DSDeskewedImageResultItem *)self;
|
|
73
68
|
if (item.imageData) {
|
|
74
69
|
ImageDataHostObject hostObject = [item.imageData hostObject];
|
|
75
70
|
Object object = Object::createFromHostObject(runtime, std::make_shared<ImageDataHostObject>(hostObject));
|
|
76
71
|
obj.setProperty(runtime, "imageData", object);
|
|
77
72
|
}
|
|
78
|
-
obj.setProperty(runtime, "
|
|
73
|
+
obj.setProperty(runtime, "sourceDeskewQuad", convertNSDictionaryToJSIObject(runtime, [item.sourceDeskewQuad toJson]));
|
|
74
|
+
obj.setProperty(runtime, "crossVerificationStatus", convertNSNumberToJSINumber(runtime, @(item.crossVerificationStatus)));
|
|
75
|
+
obj.setProperty(runtime, "originalToLocalMatrix", convertNSArrayToJSIArray(runtime, CGAffineTransformToArray(item.originalToLocalMatrix)));
|
|
76
|
+
}
|
|
77
|
+
break;
|
|
78
|
+
case DSCapturedResultItemTypeEnhancedImage:
|
|
79
|
+
{
|
|
80
|
+
DSEnhancedImageResultItem *item = (DSEnhancedImageResultItem *)self;
|
|
81
|
+
if (item.imageData) {
|
|
82
|
+
ImageDataHostObject hostObject = [item.imageData hostObject];
|
|
83
|
+
Object object = Object::createFromHostObject(runtime, std::make_shared<ImageDataHostObject>(hostObject));
|
|
84
|
+
obj.setProperty(runtime, "imageData", object);
|
|
79
85
|
}
|
|
86
|
+
obj.setProperty(runtime, "originalToLocalMatrix", convertNSArrayToJSIArray(runtime, CGAffineTransformToArray(item.originalToLocalMatrix)));
|
|
80
87
|
break;
|
|
88
|
+
}
|
|
81
89
|
case DSCapturedResultItemTypeParsedResult:
|
|
82
90
|
{
|
|
83
91
|
DSParsedResultItem *item = (DSParsedResultItem *)self;
|
|
@@ -88,7 +96,7 @@ NSArray<NSNumber *> *CGAffineTransformToArray(CGAffineTransform transform) {
|
|
|
88
96
|
@"mappingStatus":@([item getFieldMappingStatus:key]),
|
|
89
97
|
@"validationStatus":@([item getFieldValidationStatus:key]) } forKey:key];
|
|
90
98
|
}
|
|
91
|
-
obj.setProperty(runtime, "", convertNSDictionaryToJSIObject(runtime, [mutableDictionary copy]));
|
|
99
|
+
obj.setProperty(runtime, "parsedFields", convertNSDictionaryToJSIObject(runtime, [mutableDictionary copy]));
|
|
92
100
|
obj.setProperty(runtime, "jsonString", convertNSStringToJSIString(runtime, item.jsonString));
|
|
93
101
|
obj.setProperty(runtime, "codeType", convertNSStringToJSIString(runtime, item.codeType));
|
|
94
102
|
}
|
|
@@ -2,12 +2,7 @@
|
|
|
2
2
|
* Copyright © Dynamsoft Corporation. All rights reserved.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
#import <
|
|
6
|
-
#import <DynamsoftCaptureVisionRouter/DynamsoftCaptureVisionRouter.h>
|
|
7
|
-
#import <DynamsoftBarcodeReader/DynamsoftBarcodeReader.h>
|
|
8
|
-
#import <DynamsoftLabelRecognizer/DynamsoftLabelRecognizer.h>
|
|
9
|
-
#import <DynamsoftDocumentNormalizer/DynamsoftDocumentNormalizer.h>
|
|
10
|
-
#import <DynamsoftCodeParser/DynamsoftCodeParser.h>
|
|
5
|
+
#import <DynamsoftCaptureVisionBundle/DynamsoftCaptureVisionBundle.h>
|
|
11
6
|
|
|
12
7
|
NS_ASSUME_NONNULL_BEGIN
|
|
13
8
|
|
|
@@ -75,13 +70,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
75
70
|
|
|
76
71
|
@end
|
|
77
72
|
|
|
78
|
-
@interface
|
|
79
|
-
|
|
80
|
-
- (NSObject *)toJson;
|
|
81
|
-
|
|
82
|
-
@end
|
|
83
|
-
|
|
84
|
-
@interface DSNormalizedImagesResult (Json)
|
|
73
|
+
@interface DSProcessedDocumentResult (Json)
|
|
85
74
|
|
|
86
75
|
- (NSObject *)toJson;
|
|
87
76
|
|
|
@@ -72,9 +72,9 @@ void runOnMainThread(void (^block)(void))
|
|
|
72
72
|
@implementation DSSimplifiedCaptureVisionSettings (Json)
|
|
73
73
|
|
|
74
74
|
- (void)updateWithDicitionary:(NSDictionary *)dictionary {
|
|
75
|
-
NSNumber *
|
|
76
|
-
if (
|
|
77
|
-
self.
|
|
75
|
+
NSNumber *outputOriginalImage = [dictionary valueForKey:@"outputOriginalImage"];
|
|
76
|
+
if (outputOriginalImage) {
|
|
77
|
+
self.outputOriginalImage = outputOriginalImage.boolValue;
|
|
78
78
|
}
|
|
79
79
|
NSDictionary *roi = [dictionary valueForKey:@"roi"];
|
|
80
80
|
if (roi) {
|
|
@@ -112,7 +112,7 @@ void runOnMainThread(void (^block)(void))
|
|
|
112
112
|
|
|
113
113
|
- (NSObject *)toJson {
|
|
114
114
|
if (self) {
|
|
115
|
-
NSDictionary *dictionary = @{@"
|
|
115
|
+
NSDictionary *dictionary = @{@"outputOriginalImage":@(self.outputOriginalImage),
|
|
116
116
|
@"roi":self.roi ? [self.roi toJson] : [NSNull null],
|
|
117
117
|
@"roiMeasuredInPercentage":@(self.roiMeasuredInPercentage),
|
|
118
118
|
@"maxParallelTasks":@(self.maxParallelTasks),
|
|
@@ -134,7 +134,8 @@ void runOnMainThread(void (^block)(void))
|
|
|
134
134
|
- (void)updateWithDicitionary:(NSDictionary *)dictionary {
|
|
135
135
|
NSString *_barcodeFormatIdsNumberString = [dictionary valueForKey:@"_barcodeFormatIdsNumberString"];
|
|
136
136
|
if (_barcodeFormatIdsNumberString) {
|
|
137
|
-
|
|
137
|
+
NSUInteger unsignedIntegerValue = strtoull([_barcodeFormatIdsNumberString UTF8String], NULL, 10);
|
|
138
|
+
self.barcodeFormatIds = unsignedIntegerValue;
|
|
138
139
|
}
|
|
139
140
|
NSNumber *expectedBarcodesCount = [dictionary valueForKey:@"expectedBarcodesCount"];
|
|
140
141
|
if (expectedBarcodesCount) {
|
|
@@ -377,17 +378,27 @@ void runOnMainThread(void (^block)(void))
|
|
|
377
378
|
};
|
|
378
379
|
}
|
|
379
380
|
break;
|
|
380
|
-
case
|
|
381
|
+
case DSCapturedResultItemTypeDeskewedImage:
|
|
381
382
|
{
|
|
382
|
-
|
|
383
|
+
DSDeskewedImageResultItem *item = (DSDeskewedImageResultItem *)self;
|
|
383
384
|
dictionary = @{ @"type":@(item.type),
|
|
384
385
|
@"targetROIDefName":item.targetROIDefName,
|
|
385
386
|
@"taskName":item.taskName,
|
|
386
|
-
@"
|
|
387
|
-
@"crossVerificationStatus":@(item.crossVerificationStatus)
|
|
387
|
+
@"sourceDeskewQuad":[item.sourceDeskewQuad toJson],
|
|
388
|
+
@"crossVerificationStatus":@(item.crossVerificationStatus),
|
|
389
|
+
@"originalToLocalMatrix":CGAffineTransformToArray(item.originalToLocalMatrix)
|
|
388
390
|
};
|
|
389
391
|
}
|
|
390
392
|
break;
|
|
393
|
+
case DSCapturedResultItemTypeEnhancedImage: {
|
|
394
|
+
DSEnhancedImageResultItem *item = (DSEnhancedImageResultItem *)self;
|
|
395
|
+
dictionary = @{ @"type":@(item.type),
|
|
396
|
+
@"targetROIDefName":item.targetROIDefName,
|
|
397
|
+
@"taskName":item.taskName,
|
|
398
|
+
@"originalToLocalMatrix":CGAffineTransformToArray(item.originalToLocalMatrix)
|
|
399
|
+
};
|
|
400
|
+
break;
|
|
401
|
+
}
|
|
391
402
|
case DSCapturedResultItemTypeParsedResult:
|
|
392
403
|
{
|
|
393
404
|
DSParsedResultItem *item = (DSParsedResultItem *)self;
|
|
@@ -475,56 +486,54 @@ void runOnMainThread(void (^block)(void))
|
|
|
475
486
|
|
|
476
487
|
@end
|
|
477
488
|
|
|
478
|
-
@implementation
|
|
489
|
+
@implementation DSProcessedDocumentResult (Json)
|
|
479
490
|
|
|
480
491
|
- (NSObject *)toJson {
|
|
481
492
|
if (self) {
|
|
482
|
-
id
|
|
483
|
-
if (self.
|
|
493
|
+
id detectedQuadResultItems;
|
|
494
|
+
if (self.detectedQuadResultItems.count > 0) {
|
|
484
495
|
NSMutableArray *array = [NSMutableArray array];
|
|
485
|
-
for (DSDetectedQuadResultItem *item in self.
|
|
496
|
+
for (DSDetectedQuadResultItem *item in self.detectedQuadResultItems) {
|
|
486
497
|
NSDictionary *obj = [item toJson];
|
|
487
498
|
if (obj) {
|
|
488
499
|
[array addObject:obj];
|
|
489
500
|
}
|
|
490
501
|
}
|
|
491
|
-
|
|
502
|
+
detectedQuadResultItems = [array copy];
|
|
492
503
|
} else {
|
|
493
|
-
|
|
504
|
+
detectedQuadResultItems = [NSNull null];
|
|
494
505
|
}
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
@"rotationTransformMatrix":CGAffineTransformToArray(self.rotationTransformMatrix),
|
|
498
|
-
@"errorCode":@(self.errorCode),
|
|
499
|
-
@"errorMessage":self.errorMessage ? self.errorMessage : [NSNull null]
|
|
500
|
-
};
|
|
501
|
-
return dictionary;
|
|
502
|
-
} else {
|
|
503
|
-
return [NSNull null];
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
@end
|
|
508
|
-
|
|
509
|
-
@implementation DSNormalizedImagesResult (Json)
|
|
510
|
-
|
|
511
|
-
- (NSObject *)toJson {
|
|
512
|
-
if (self) {
|
|
513
|
-
id items;
|
|
514
|
-
if (self.items.count > 0) {
|
|
506
|
+
id deskewedImageResultItems;
|
|
507
|
+
if (self.deskewedImageResultItems.count > 0) {
|
|
515
508
|
NSMutableArray *array = [NSMutableArray array];
|
|
516
|
-
for (
|
|
509
|
+
for (DSDeskewedImageResultItem *item in self.deskewedImageResultItems) {
|
|
517
510
|
NSDictionary *obj = [item toJson];
|
|
518
511
|
if (obj) {
|
|
519
512
|
[array addObject:obj];
|
|
520
513
|
}
|
|
521
514
|
}
|
|
522
|
-
|
|
515
|
+
deskewedImageResultItems = [array copy];
|
|
523
516
|
} else {
|
|
524
|
-
|
|
517
|
+
deskewedImageResultItems = [NSNull null];
|
|
525
518
|
}
|
|
519
|
+
id enhancedImageResultItems;
|
|
520
|
+
if (self.enhancedImageResultItems.count > 0) {
|
|
521
|
+
NSMutableArray *array = [NSMutableArray array];
|
|
522
|
+
for (DSEnhancedImageResultItem *item in self.enhancedImageResultItems) {
|
|
523
|
+
NSDictionary *obj = [item toJson];
|
|
524
|
+
if (obj) {
|
|
525
|
+
[array addObject:obj];
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
enhancedImageResultItems = [array copy];
|
|
529
|
+
} else {
|
|
530
|
+
enhancedImageResultItems = [NSNull null];
|
|
531
|
+
}
|
|
532
|
+
|
|
526
533
|
NSDictionary *dictionary = @{@"originalImageHashId":self.originalImageHashId,
|
|
527
|
-
@"
|
|
534
|
+
@"detectedQuadResultItems":detectedQuadResultItems,
|
|
535
|
+
@"deskewedImageResultItems":deskewedImageResultItems,
|
|
536
|
+
@"enhancedImageResultItems":enhancedImageResultItems,
|
|
528
537
|
@"rotationTransformMatrix":CGAffineTransformToArray(self.rotationTransformMatrix),
|
|
529
538
|
@"errorCode":@(self.errorCode),
|
|
530
539
|
@"errorMessage":self.errorMessage ? self.errorMessage : [NSNull null]
|
package/ios/CPP/YeetJSIUtils.h
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
#import <jsi/jsi.h>
|
|
7
7
|
#import <React/RCTBridgeModule.h>
|
|
8
8
|
#include "ImageDataHostObject.hpp"
|
|
9
|
-
#import <
|
|
9
|
+
#import <DynamsoftCaptureVisionBundle/DSImageData.h>
|
|
10
10
|
|
|
11
11
|
using namespace facebook;
|
|
12
12
|
/**
|
|
@@ -34,6 +34,8 @@ RCTResponseSenderBlock convertJSIFunctionToCallback(
|
|
|
34
34
|
jsi::Runtime &runtime,
|
|
35
35
|
const jsi::Function &value);
|
|
36
36
|
|
|
37
|
+
NSData* convertArrayBufferToNSData(jsi::Runtime &runtime, const jsi::ArrayBuffer &buffer);
|
|
38
|
+
|
|
37
39
|
struct Promise {
|
|
38
40
|
Promise(jsi::Runtime &rt, jsi::Function resolve, jsi::Function reject);
|
|
39
41
|
|
package/ios/CPP/YeetJSIUtils.mm
CHANGED
|
@@ -149,6 +149,11 @@ RCTResponseSenderBlock convertJSIFunctionToCallback(
|
|
|
149
149
|
};
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
+
NSData* convertArrayBufferToNSData(jsi::Runtime &runtime, const jsi::ArrayBuffer &buffer) {
|
|
153
|
+
return [NSData dataWithBytes:buffer.data(runtime)
|
|
154
|
+
length:buffer.size(runtime)];
|
|
155
|
+
}
|
|
156
|
+
|
|
152
157
|
Promise::Promise(jsi::Runtime &rt, jsi::Function resolve, jsi::Function reject)
|
|
153
158
|
: runtime_(rt), resolve_(std::move(resolve)), reject_(std::move(reject)) {}
|
|
154
159
|
|
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
#import "RNDynamsoftCameraViewManager.h"
|
|
6
6
|
#import "RNDynamsoftCameraView.h"
|
|
7
|
-
#import <
|
|
8
|
-
#import <DynamsoftCore/DynamsoftCore.h>
|
|
7
|
+
#import <DynamsoftCaptureVisionBundle/DynamsoftCaptureVisionBundle.h>
|
|
9
8
|
#import <React/RCTUIManager.h>
|
|
10
9
|
#import "RNDynamsoftImageSourceAdapter.h"
|
|
11
10
|
|
|
@@ -60,11 +59,24 @@ RCT_EXPORT_METHOD(close) {
|
|
|
60
59
|
}
|
|
61
60
|
|
|
62
61
|
RCT_EXPORT_METHOD(setCameraView:(nonnull NSNumber *)tag) {
|
|
62
|
+
[self trySetCameraViewWithTag:tag attempt:1];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
- (void)trySetCameraViewWithTag:(nonnull NSNumber *)tag attempt:(NSInteger)attempt {
|
|
66
|
+
const NSInteger maxAttempts = 10;
|
|
67
|
+
const NSTimeInterval retryDelay = 0.1; // 100ms
|
|
68
|
+
|
|
63
69
|
[self.bridge.uiManager addUIBlock:
|
|
64
70
|
^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
65
71
|
id view = viewRegistry[tag];
|
|
66
72
|
if (!view || ![view isKindOfClass:[RNDynamsoftCameraView class]]) {
|
|
67
|
-
|
|
73
|
+
if (attempt < maxAttempts) {
|
|
74
|
+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(retryDelay * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
75
|
+
[self trySetCameraViewWithTag:tag attempt:attempt + 1];
|
|
76
|
+
});
|
|
77
|
+
} else {
|
|
78
|
+
RCTLogError(@"Cannot find RNDynamsoftCameraView with tag #%@ after %ld attempts", tag, (long)attempt);
|
|
79
|
+
}
|
|
68
80
|
} else {
|
|
69
81
|
self.dce.cameraView = ((RNDynamsoftCameraView *)view).cameraView;
|
|
70
82
|
}
|
|
@@ -87,7 +99,7 @@ RCT_EXPORT_METHOD(setFocus:(CGFloat)x y:(CGFloat)y mode:(NSInteger)mode) {
|
|
|
87
99
|
}
|
|
88
100
|
|
|
89
101
|
RCT_EXPORT_METHOD(getFocusMode:(RCTPromiseResolveBlock)resolve
|
|
90
|
-
rejecter:(RCTPromiseRejectBlock)reject)
|
|
102
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
91
103
|
{
|
|
92
104
|
resolve(@([self.dce getFocusMode]));
|
|
93
105
|
}
|
|
@@ -110,9 +122,9 @@ RCT_EXPORT_METHOD(disableEnhancedFeatures:(NSInteger)features) {
|
|
|
110
122
|
[self.dce disableEnhancedFeatures:features];
|
|
111
123
|
}
|
|
112
124
|
|
|
113
|
-
RCT_EXPORT_METHOD(setScanRegion:(NSDictionary *)region
|
|
125
|
+
RCT_EXPORT_METHOD(setScanRegion:(NSDictionary *)region
|
|
114
126
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
115
|
-
rejecter: (RCTPromiseRejectBlock)reject)
|
|
127
|
+
rejecter: (RCTPromiseRejectBlock)reject)
|
|
116
128
|
{
|
|
117
129
|
if (region) {
|
|
118
130
|
NSNumber *top = [region valueForKey:@"top"];
|