dynamsoft-capture-vision-react-native 3.4.1300 → 3.4.3010
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 +4 -4
- package/README.md +62 -62
- package/android/README.md +14 -14
- package/android/build.gradle +167 -163
- package/android/gradle.properties +20 -20
- package/android/settings.gradle +5 -5
- package/android/src/main/AndroidManifest.xml +6 -6
- package/android/src/main/AndroidManifest_noPackage.xml +5 -5
- package/android/src/main/cpp/CMakeLists.txt +21 -21
- package/android/src/main/cpp/ImgHO.cpp +94 -94
- package/android/src/main/cpp/ImgHO.h +34 -34
- package/android/src/main/cpp/JsiCore.cpp +296 -296
- package/android/src/main/cpp/JsiCore.h +51 -51
- package/android/src/main/cpp/JsiCvr.cpp +332 -332
- package/android/src/main/cpp/JsiCvr.h +54 -54
- package/android/src/main/cpp/JsiDbr.cpp +283 -283
- package/android/src/main/cpp/JsiDbr.h +26 -26
- package/android/src/main/cpp/JsiDce.cpp +59 -59
- package/android/src/main/cpp/JsiDce.h +17 -17
- package/android/src/main/cpp/JsiDcp.cpp +51 -51
- package/android/src/main/cpp/JsiDcp.h +31 -31
- package/android/src/main/cpp/JsiDdn.cpp +50 -50
- package/android/src/main/cpp/JsiDdn.h +28 -28
- package/android/src/main/cpp/JsiDlr.cpp +60 -60
- package/android/src/main/cpp/JsiDlr.h +26 -26
- package/android/src/main/cpp/JsiUtility.cpp +604 -604
- package/android/src/main/cpp/JsiUtility.h +26 -26
- package/android/src/main/cpp/RawBuffer.cpp +23 -23
- package/android/src/main/cpp/RawBuffer.h +24 -24
- package/android/src/main/cpp/android_log.h +14 -14
- package/android/src/main/dysJniLibsFor86/debug/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor86/debug/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor86/debug/x86/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor86/debug/x86_64/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor86/release/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor86/release/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor86/release/x86/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor86/release/x86_64/librn_dys.so +0 -0
- package/android/src/main/java/com/dynamsoft/reactnativelib/CVRModule.kt +137 -137
- package/android/src/main/java/com/dynamsoft/reactnativelib/CameraViewManager.kt +62 -62
- package/android/src/main/java/com/dynamsoft/reactnativelib/DCEModule.kt +125 -125
- package/android/src/main/java/com/dynamsoft/reactnativelib/DynamsoftBaseModule.kt +8 -8
- package/android/src/main/java/com/dynamsoft/reactnativelib/ISAModule.kt +73 -73
- package/android/src/main/java/com/dynamsoft/reactnativelib/ImageEditorViewManager.kt +14 -14
- package/android/src/main/java/com/dynamsoft/reactnativelib/ImageEditorViewModule.kt +35 -35
- package/android/src/main/java/com/dynamsoft/reactnativelib/ImageManagerModule.kt +15 -15
- package/android/src/main/java/com/dynamsoft/reactnativelib/LicenseModule.kt +29 -29
- package/android/src/main/java/com/dynamsoft/reactnativelib/MultiCrossFilterModule.kt +83 -83
- package/android/src/main/java/com/dynamsoft/reactnativelib/ReactNativeDcvPackage.kt +32 -32
- package/android/src/main/java/com/dynamsoft/reactnativelib/VersionsModule.kt +41 -41
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/Basic.kt +44 -44
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForCore.kt +50 -50
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForCvr.kt +129 -129
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForDBR.kt +157 -157
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForDCE.kt +110 -110
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForDCP.kt +49 -49
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForDDN.kt +85 -85
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForDLR.kt +72 -72
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ImageUtil.kt +58 -58
- package/android/src/main/java/com/dynamsoft/reactnativelib/core/ImageSourceAdapterModuleImpl.kt +120 -120
- package/android/src/main/java/com/dynamsoft/reactnativelib/cvr/CaptureVisionRouterModuleImpl.kt +306 -306
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/CameraEnhancerModuleImpl.kt +247 -247
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/CameraLifeCycleOwner.java +14 -14
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/CameraViewManagerImpl.kt +77 -77
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/ImageEditorViewManagerImpl.kt +15 -15
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/ImageEditorViewModuleImpl.kt +110 -110
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/RNCameraView.kt +20 -20
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/RNImageEditorView.kt +19 -19
- package/android/src/main/java/com/dynamsoft/reactnativelib/license/LicenseModuleImpl.kt +39 -39
- package/android/src/main/java/com/dynamsoft/reactnativelib/utility/ImageManagerModuleImpl.kt +120 -120
- package/android/src/main/java/com/dynamsoft/reactnativelib/utility/MultiCrossFilterModuleImpl.kt +111 -111
- package/app.plugin.js +21 -21
- package/dynamsoft-capture-vision-react-native.podspec +24 -24
- package/ios/CPP/DSImageData+HostObject.h +18 -18
- package/ios/CPP/DSImageData+HostObject.mm +38 -38
- package/ios/CPP/ImageDataHostObject.cpp +87 -87
- package/ios/CPP/ImageDataHostObject.hpp +35 -35
- package/ios/CPP/MutableRawBuffer.cpp +23 -23
- package/ios/CPP/MutableRawBuffer.hpp +23 -23
- package/ios/CPP/RNDynamsoft+JSI.h +22 -22
- package/ios/CPP/RNDynamsoft+JSI.mm +303 -303
- package/ios/CPP/RNDynamsoft+Json.h +93 -93
- package/ios/CPP/RNDynamsoft+Json.m +733 -733
- package/ios/CPP/YeetJSIUtils.h +56 -56
- package/ios/CPP/YeetJSIUtils.mm +208 -208
- package/ios/RNDynamsoftCameraView.h +31 -31
- package/ios/RNDynamsoftCameraView.m +108 -108
- package/ios/RNDynamsoftCameraViewManager.h +14 -14
- package/ios/RNDynamsoftCameraViewManager.m +195 -195
- package/ios/RNDynamsoftCaptureVisionRouter.h +18 -18
- package/ios/RNDynamsoftCaptureVisionRouter.mm +532 -532
- package/ios/RNDynamsoftImageEditorView.h +17 -17
- package/ios/RNDynamsoftImageEditorView.m +25 -25
- package/ios/RNDynamsoftImageEditorViewManager.h +14 -14
- package/ios/RNDynamsoftImageEditorViewManager.mm +183 -183
- package/ios/RNDynamsoftImageManager.h +14 -14
- package/ios/RNDynamsoftImageManager.mm +369 -369
- package/ios/RNDynamsoftImageSourceAdapter.h +19 -19
- package/ios/RNDynamsoftImageSourceAdapter.mm +255 -255
- package/ios/RNDynamsoftLicense.h +14 -14
- package/ios/RNDynamsoftLicense.m +62 -62
- package/ios/RNDynamsoftMultiCrossFilter.h +14 -14
- package/ios/RNDynamsoftMultiCrossFilter.m +145 -145
- package/ios/RNDynamsoftVersions.h +13 -13
- package/ios/RNDynamsoftVersions.m +27 -27
- package/package.json +48 -48
- package/src/NativeDynamsoftVersionsModule.tsx +20 -20
- package/src/VersionsModule.tsx +7 -7
- package/src/core/CapturedResultBase.tsx +18 -18
- package/src/core/CapturedResultItem.tsx +23 -23
- package/src/core/CoreModule.tsx +9 -9
- package/src/core/DSRect.tsx +29 -29
- package/src/core/EnumCaptureResultItemType.tsx +52 -52
- package/src/core/EnumColourChannelUsageType.tsx +26 -26
- package/src/core/EnumCrossVerificationStatus.tsx +46 -46
- package/src/core/EnumGrayscaleEnhancementMode.tsx +46 -46
- package/src/core/EnumGrayscaleTransformationMode.tsx +35 -35
- package/src/core/EnumImageFileFormat.tsx +6 -6
- package/src/core/EnumPixelFormat.tsx +53 -53
- package/src/core/ImageData.tsx +87 -87
- package/src/core/ImageSourceAdapter.tsx +160 -160
- package/src/core/NativeDynamsoftImageSourceAdapterModule.tsx +29 -29
- package/src/core/Point.tsx +13 -13
- package/src/core/Quadrilateral.tsx +12 -12
- package/src/core/index.tsx +18 -18
- package/src/cvr/CaptureVisionRouter.tsx +683 -683
- package/src/cvr/CaptureVisionRouterModule.tsx +9 -9
- package/src/cvr/CapturedResult.tsx +123 -123
- package/src/cvr/CapturedResultFilter.tsx +13 -13
- package/src/cvr/CapturedResultReceiver.tsx +71 -71
- package/src/cvr/EnumPresetTemplate.tsx +81 -81
- package/src/cvr/NativeDynamsoftCaptureVisionRouterModule.tsx +25 -25
- package/src/cvr/SimplifiedCaptureVisionSettings.tsx +61 -61
- package/src/cvr/index.tsx +11 -11
- package/src/dbr/BarcodeDetails.tsx +51 -51
- package/src/dbr/BarcodeReaderModule.tsx +9 -9
- package/src/dbr/BarcodeResultItem.tsx +65 -65
- package/src/dbr/DecodedBarcodesResult.tsx +14 -14
- package/src/dbr/ECISegment.tsx +23 -23
- package/src/dbr/EnumBarcodeFormat.tsx +112 -112
- package/src/dbr/EnumDeblurMode.tsx +29 -29
- package/src/dbr/EnumLocalizationMode.tsx +27 -27
- package/src/dbr/EnumQRCodeErrorCorrectionLevel.tsx +6 -6
- package/src/dbr/SimplifiedBarcodeReaderSettings.tsx +80 -80
- package/src/dbr/index.tsx +9 -9
- package/src/dce/CameraEnhancer.tsx +254 -254
- package/src/dce/CameraEnhancerModule.tsx +9 -9
- package/src/dce/CameraView.tsx +100 -100
- package/src/dce/DynamsoftCameraViewNativeComponent.ts +96 -96
- package/src/dce/DynamsoftImageEditorViewNativeComponent.ts +9 -9
- package/src/dce/EnumCameraPosition.tsx +25 -25
- package/src/dce/EnumDrawingLayerId.tsx +17 -17
- package/src/dce/EnumEnhancedFeatures.tsx +24 -24
- package/src/dce/EnumFocusMode.tsx +6 -6
- package/src/dce/EnumResolution.tsx +8 -8
- package/src/dce/EnumTorchState.tsx +10 -10
- package/src/dce/FeedBack.tsx +28 -28
- package/src/dce/ImageEditorView.tsx +131 -131
- package/src/dce/NativeDynamsoftCameraViewModule.tsx +47 -47
- package/src/dce/NativeDynamsoftImageEditorViewModule.ts +9 -9
- package/src/dce/index.tsx +13 -13
- package/src/dcp/CodeParserDedicatorModule.tsx +9 -9
- package/src/dcp/CodeParserModule.tsx +9 -9
- package/src/dcp/EnumMappingStatus.tsx +14 -14
- package/src/dcp/EnumValidationStatus.tsx +14 -14
- package/src/dcp/ParsedResult.tsx +14 -14
- package/src/dcp/ParsedResultItem.tsx +50 -50
- package/src/dcp/index.tsx +8 -8
- package/src/ddn/DeskewedImageResultItem.tsx +40 -40
- package/src/ddn/DetectedQuadResultItem.tsx +31 -31
- package/src/ddn/DocumentNormalizerModule.tsx +9 -9
- package/src/ddn/EnhancedImageResultItem.tsx +20 -20
- package/src/ddn/EnumImageColourMode.tsx +14 -14
- package/src/ddn/ProcessedDocumentResult.tsx +27 -27
- package/src/ddn/SimplifiedDocumentNormalizerSettings.tsx +65 -65
- package/src/ddn/index.tsx +11 -11
- package/src/dip/ImageProcessingModule.tsx +9 -9
- package/src/dip/index.tsx +1 -1
- package/src/dlr/CharacterResult.tsx +28 -28
- package/src/dlr/LabelRecognizerModule.tsx +9 -9
- package/src/dlr/RecognizedTextLinesResult.tsx +19 -19
- package/src/dlr/SimplifiedLabelRecognizerSettings.tsx +33 -33
- package/src/dlr/TextLineResultItem.tsx +41 -41
- package/src/dlr/index.tsx +8 -8
- package/src/index.tsx +13 -13
- package/src/license/LicenseManager.tsx +49 -49
- package/src/license/LicenseModule.tsx +9 -9
- package/src/license/NativeDynamsoftLicenseModule.tsx +7 -7
- package/src/license/index.tsx +7 -7
- package/src/utility/CrossVerificationCriteria.tsx +11 -11
- package/src/utility/EnumFilterType.tsx +5 -5
- package/src/utility/ImageManager.tsx +348 -348
- package/src/utility/MultiFrameResultCrossFilter.tsx +183 -183
- package/src/utility/NativeDynamsoftImageManagerModule.tsx +7 -7
- package/src/utility/NativeDynamsoftMultiCrossFilterModule.tsx +18 -18
- package/src/utility/UtilityModule.tsx +9 -9
- package/src/utility/index.tsx +4 -4
- package/android/.gitignore +0 -4
|
@@ -1,303 +1,303 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright © Dynamsoft Corporation. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
#import "RNDynamsoft+JSI.h"
|
|
6
|
-
#import "RNDynamsoft+Json.h"
|
|
7
|
-
#import "DSImageData+HostObject.h"
|
|
8
|
-
#import "YeetJSIUtils.h"
|
|
9
|
-
#import <DynamsoftCaptureVisionBundle/DynamsoftCaptureVisionBundle.h>
|
|
10
|
-
|
|
11
|
-
NSArray<NSNumber *> *CGAffineTransformToArray(CGAffineTransform transform) {
|
|
12
|
-
return @[@(transform.a), @(transform.b), @(transform.c), @(transform.d), @(transform.tx), @(transform.ty)];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
@implementation NSData (DSNumber)
|
|
16
|
-
|
|
17
|
-
- (nullable NSArray<NSNumber *> *)toNumberArray {
|
|
18
|
-
if (!self) return nil;
|
|
19
|
-
|
|
20
|
-
const uint8_t *bytes = (const uint8_t *)self.bytes;
|
|
21
|
-
NSUInteger length = self.length;
|
|
22
|
-
|
|
23
|
-
NSMutableArray *result = [NSMutableArray arrayWithCapacity:length];
|
|
24
|
-
for (NSUInteger i = 0; i < length; i++) {
|
|
25
|
-
[result addObject:@(bytes[i])];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return result;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
@end
|
|
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
|
-
|
|
47
|
-
@implementation DSCapturedResultItem (JSI)
|
|
48
|
-
|
|
49
|
-
- (Object)convertToJSIObject:(Runtime& )runtime {
|
|
50
|
-
Object obj = Object(runtime);
|
|
51
|
-
obj.setProperty(runtime, "type", convertNSNumberToJSINumber(runtime, @(self.type)));
|
|
52
|
-
obj.setProperty(runtime, "targetROIDefName", convertNSStringToJSIString(runtime, self.targetROIDefName));
|
|
53
|
-
obj.setProperty(runtime, "taskName", convertNSStringToJSIString(runtime, self.taskName));
|
|
54
|
-
switch (self.type) {
|
|
55
|
-
case DSCapturedResultItemTypeOriginalImage:
|
|
56
|
-
{
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
break;
|
|
60
|
-
case DSCapturedResultItemTypeBarcode:
|
|
61
|
-
{
|
|
62
|
-
DSBarcodeResultItem *item = (DSBarcodeResultItem *)self;
|
|
63
|
-
obj.setProperty(runtime, "format", BigInt::fromUint64(runtime, item.format));
|
|
64
|
-
obj.setProperty(runtime, "_formatNumberString", convertNSStringToJSIString(runtime, [NSNumber numberWithUnsignedInteger:item.format].stringValue));
|
|
65
|
-
obj.setProperty(runtime, "formatString", convertNSStringToJSIString(runtime, item.formatString));
|
|
66
|
-
obj.setProperty(runtime, "text", convertNSStringToJSIString(runtime, item.text));
|
|
67
|
-
obj.setProperty(runtime, "bytes", convertNSStringToJSIString(runtime, [item.bytes base64EncodedStringWithOptions:0]));
|
|
68
|
-
obj.setProperty(runtime, "location", convertNSDictionaryToJSIObject(runtime, [item.location toJson]));
|
|
69
|
-
obj.setProperty(runtime, "confidence", convertNSNumberToJSINumber(runtime, @(item.confidence)));
|
|
70
|
-
obj.setProperty(runtime, "angle", convertNSNumberToJSINumber(runtime, @(item.angle)));
|
|
71
|
-
obj.setProperty(runtime, "moduleSize", convertNSNumberToJSINumber(runtime, @(item.moduleSize)));
|
|
72
|
-
obj.setProperty(runtime, "isDPM", convertNSNumberToJSIBoolean(runtime, @(item.isDPM)));
|
|
73
|
-
obj.setProperty(runtime, "isMirrored", convertNSNumberToJSIBoolean(runtime, @(item.isMirrored)));
|
|
74
|
-
if (item.details) {
|
|
75
|
-
if (item.format == DSBarcodeFormatQRCode) {
|
|
76
|
-
DSQRCodeDetails *qrDetails = (DSQRCodeDetails *)item.details;
|
|
77
|
-
NSMutableDictionary *qrDict = [NSMutableDictionary dictionaryWithDictionary:@{
|
|
78
|
-
@"rows": @(qrDetails.rows),
|
|
79
|
-
@"columns": @(qrDetails.columns),
|
|
80
|
-
@"errorCorrectionLevel": @(qrDetails.errorCorrectionLevel),
|
|
81
|
-
@"version": @(qrDetails.version),
|
|
82
|
-
@"model": @(qrDetails.model),
|
|
83
|
-
@"mode": @(qrDetails.mode),
|
|
84
|
-
@"page": @(qrDetails.page),
|
|
85
|
-
@"totalPage": @(qrDetails.totalPage),
|
|
86
|
-
@"parityData": @(qrDetails.parityData),
|
|
87
|
-
@"dataMaskPattern": @(qrDetails.dataMaskPattern)
|
|
88
|
-
}];
|
|
89
|
-
|
|
90
|
-
if (qrDetails.codewords) {
|
|
91
|
-
qrDict[@"codewords"] = [qrDetails.codewords toNumberArray];
|
|
92
|
-
}
|
|
93
|
-
obj.setProperty(runtime, "qrCodeDetails", convertNSDictionaryToJSIObject(runtime, [qrDict copy]));
|
|
94
|
-
} else if (item.format == DSBarcodeFormatAztec) {
|
|
95
|
-
DSAztecDetails *aztecDetails = (DSAztecDetails *)item.details;
|
|
96
|
-
NSDictionary *aztecDict = @{
|
|
97
|
-
@"rows": @(aztecDetails.rows),
|
|
98
|
-
@"columns": @(aztecDetails.columns),
|
|
99
|
-
@"layerNumber": @(aztecDetails.layerNumber)
|
|
100
|
-
};
|
|
101
|
-
obj.setProperty(runtime, "aztecDetails", convertNSDictionaryToJSIObject(runtime, [aztecDict copy]));
|
|
102
|
-
} else if (item.format == DSBarcodeFormatDataMatrix) {
|
|
103
|
-
DSDataMatrixDetails *dmDetails = (DSDataMatrixDetails *)item.details;
|
|
104
|
-
NSDictionary *dmDict = @{
|
|
105
|
-
@"rows": @(dmDetails.rows),
|
|
106
|
-
@"columns": @(dmDetails.columns),
|
|
107
|
-
@"dataRegionRows": @(dmDetails.dataRegionRows),
|
|
108
|
-
@"dataRegionColumns": @(dmDetails.dataRegionColumns),
|
|
109
|
-
@"dataRegionNumber": @(dmDetails.dataRegionNumber)
|
|
110
|
-
};
|
|
111
|
-
obj.setProperty(runtime, "dataMatrixDetails", convertNSDictionaryToJSIObject(runtime, [dmDict copy]));
|
|
112
|
-
} else if ((item.format & DSBarcodeFormatOneD) != 0) {
|
|
113
|
-
DSOneDCodeDetails *onedDetails = (DSOneDCodeDetails *)item.details;
|
|
114
|
-
NSMutableDictionary *onedDict = [NSMutableDictionary dictionary];
|
|
115
|
-
|
|
116
|
-
if (onedDetails.startCharsBytes) {
|
|
117
|
-
onedDict[@"startCharsBytes"] = [onedDetails.startCharsBytes toNumberArray];
|
|
118
|
-
}
|
|
119
|
-
if (onedDetails.stopCharsBytes) {
|
|
120
|
-
onedDict[@"stopCharsBytes"] = [onedDetails.stopCharsBytes toNumberArray];
|
|
121
|
-
}
|
|
122
|
-
if (onedDetails.checkDigitBytes) {
|
|
123
|
-
onedDict[@"checkDigitBytes"] = [onedDetails.checkDigitBytes toNumberArray];
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
onedDict[@"startPatternRange_lower"] = @(onedDetails.startPatternRange.minimum);
|
|
127
|
-
onedDict[@"middlePatternRange_lower"] = @(onedDetails.middlePatternRange.minimum);
|
|
128
|
-
onedDict[@"endPatternRange_lower"] = @(onedDetails.endPatternRange.minimum);
|
|
129
|
-
onedDict[@"startPatternRange_upper"] = @(onedDetails.startPatternRange.maximum);
|
|
130
|
-
onedDict[@"middlePatternRange_upper"] = @(onedDetails.middlePatternRange.maximum);
|
|
131
|
-
onedDict[@"endPatternRange_upper"] = @(onedDetails.endPatternRange.maximum);
|
|
132
|
-
|
|
133
|
-
obj.setProperty(runtime, "oneDCodeDetails", convertNSDictionaryToJSIObject(runtime, [onedDict copy]));
|
|
134
|
-
} else if (item.format == DSBarcodeFormatPDF417) {
|
|
135
|
-
DSPDF417Details *pdf417Details = (DSPDF417Details *)item.details;
|
|
136
|
-
NSMutableDictionary *pdf417Dict = [NSMutableDictionary dictionaryWithDictionary:@{
|
|
137
|
-
@"rows": @(pdf417Details.rows),
|
|
138
|
-
@"columns": @(pdf417Details.columns),
|
|
139
|
-
@"errorCorrectionLevel": @(pdf417Details.errorCorrectionLevel),
|
|
140
|
-
@"hasLeftRowIndicator": @(pdf417Details.hasLeftRowIndicator),
|
|
141
|
-
@"hasRightRowIndicator": @(pdf417Details.hasRightRowIndicator)
|
|
142
|
-
}];
|
|
143
|
-
|
|
144
|
-
if (pdf417Details.codewords) {
|
|
145
|
-
pdf417Dict[@"codewords"] = pdf417Details.codewords;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
obj.setProperty(runtime, "pdf417Details", convertNSDictionaryToJSIObject(runtime, [pdf417Dict copy]));
|
|
149
|
-
}
|
|
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
|
-
}
|
|
161
|
-
}
|
|
162
|
-
break;
|
|
163
|
-
case DSCapturedResultItemTypeTextLine:
|
|
164
|
-
{
|
|
165
|
-
DSTextLineResultItem *item = (DSTextLineResultItem *)self;
|
|
166
|
-
obj.setProperty(runtime, "text", convertNSStringToJSIString(runtime, item.text));
|
|
167
|
-
obj.setProperty(runtime, "rawText", convertNSStringToJSIString(runtime, item.rawText));
|
|
168
|
-
obj.setProperty(runtime, "location", convertNSDictionaryToJSIObject(runtime, [item.location toJson]));
|
|
169
|
-
obj.setProperty(runtime, "confidence",convertNSNumberToJSINumber(runtime, @(item.confidence)));
|
|
170
|
-
NSUInteger count = item.charResult.count;
|
|
171
|
-
if (count > 0) {
|
|
172
|
-
jsi::Array array = jsi::Array(runtime, count);
|
|
173
|
-
for (size_t i = 0; i < count; i++) {
|
|
174
|
-
array.setValueAtIndex(runtime, i, convertNSDictionaryToJSIObject(runtime, [[item.charResult objectAtIndex:i] toJson]));
|
|
175
|
-
}
|
|
176
|
-
obj.setProperty(runtime, "characterResults", array);
|
|
177
|
-
} else {
|
|
178
|
-
obj.setProperty(runtime, "characterResults", jsi::Value::null());
|
|
179
|
-
}
|
|
180
|
-
obj.setProperty(runtime, "specificationName", convertNSStringToJSIString(runtime, item.specificationName));
|
|
181
|
-
}
|
|
182
|
-
break;
|
|
183
|
-
case DSCapturedResultItemTypeDetectedQuad:
|
|
184
|
-
{
|
|
185
|
-
DSDetectedQuadResultItem *item = (DSDetectedQuadResultItem *)self;
|
|
186
|
-
obj.setProperty(runtime, "location", convertNSDictionaryToJSIObject(runtime, [item.location toJson]));
|
|
187
|
-
obj.setProperty(runtime, "confidenceAsDocumentBoundary",convertNSNumberToJSINumber(runtime, @(item.confidenceAsDocumentBoundary)));
|
|
188
|
-
}
|
|
189
|
-
break;
|
|
190
|
-
case DSCapturedResultItemTypeDeskewedImage:
|
|
191
|
-
{
|
|
192
|
-
DSDeskewedImageResultItem *item = (DSDeskewedImageResultItem *)self;
|
|
193
|
-
if (item.imageData) {
|
|
194
|
-
ImageDataHostObject hostObject = [item.imageData hostObject];
|
|
195
|
-
Object object = Object::createFromHostObject(runtime, std::make_shared<ImageDataHostObject>(hostObject));
|
|
196
|
-
obj.setProperty(runtime, "imageData", object);
|
|
197
|
-
} else {
|
|
198
|
-
obj.setProperty(runtime, "imageData", jsi::Value::null());
|
|
199
|
-
}
|
|
200
|
-
obj.setProperty(runtime, "sourceDeskewQuad", convertNSDictionaryToJSIObject(runtime, [item.sourceDeskewQuad toJson]));
|
|
201
|
-
obj.setProperty(runtime, "crossVerificationStatus", convertNSNumberToJSINumber(runtime, @(item.crossVerificationStatus)));
|
|
202
|
-
obj.setProperty(runtime, "originalToLocalMatrix", convertNSArrayToJSIArray(runtime, CGAffineTransformToArray(item.originalToLocalMatrix)));
|
|
203
|
-
}
|
|
204
|
-
break;
|
|
205
|
-
case DSCapturedResultItemTypeEnhancedImage:
|
|
206
|
-
{
|
|
207
|
-
DSEnhancedImageResultItem *item = (DSEnhancedImageResultItem *)self;
|
|
208
|
-
if (item.imageData) {
|
|
209
|
-
ImageDataHostObject hostObject = [item.imageData hostObject];
|
|
210
|
-
Object object = Object::createFromHostObject(runtime, std::make_shared<ImageDataHostObject>(hostObject));
|
|
211
|
-
obj.setProperty(runtime, "imageData", object);
|
|
212
|
-
} else {
|
|
213
|
-
obj.setProperty(runtime, "imageData", jsi::Value::null());
|
|
214
|
-
}
|
|
215
|
-
obj.setProperty(runtime, "originalToLocalMatrix", convertNSArrayToJSIArray(runtime, CGAffineTransformToArray(item.originalToLocalMatrix)));
|
|
216
|
-
break;
|
|
217
|
-
}
|
|
218
|
-
case DSCapturedResultItemTypeParsedResult:
|
|
219
|
-
{
|
|
220
|
-
DSParsedResultItem *item = (DSParsedResultItem *)self;
|
|
221
|
-
NSDictionary<NSString *, NSString *> *parsedFields = item.parsedFields;
|
|
222
|
-
NSMutableDictionary *mutableDictionary = [NSMutableDictionary dictionaryWithDictionary:parsedFields];
|
|
223
|
-
for (NSString *key in [parsedFields allKeys]) {
|
|
224
|
-
[mutableDictionary setValue:@{ @"value":[parsedFields valueForKey:key],
|
|
225
|
-
@"mappingStatus":@([item getFieldMappingStatus:key]),
|
|
226
|
-
@"validationStatus":@([item getFieldValidationStatus:key]) } forKey:key];
|
|
227
|
-
}
|
|
228
|
-
obj.setProperty(runtime, "parsedFields", convertNSDictionaryToJSIObject(runtime, [mutableDictionary copy]));
|
|
229
|
-
obj.setProperty(runtime, "jsonString", convertNSStringToJSIString(runtime, item.jsonString));
|
|
230
|
-
obj.setProperty(runtime, "codeType", convertNSStringToJSIString(runtime, item.codeType));
|
|
231
|
-
}
|
|
232
|
-
break;
|
|
233
|
-
}
|
|
234
|
-
return obj;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
@end
|
|
238
|
-
|
|
239
|
-
@implementation DSCapturedResult (JSI)
|
|
240
|
-
|
|
241
|
-
- (Object)convertToJSIObject:(Runtime& )runtime {
|
|
242
|
-
Object obj = Object(runtime);
|
|
243
|
-
obj.setProperty(runtime, "originalImageHashId", convertNSStringToJSIString(runtime, self.originalImageHashId));
|
|
244
|
-
obj.setProperty(runtime, "errorMessage", convertNSStringToJSIString(runtime, self.errorMessage));
|
|
245
|
-
obj.setProperty(runtime, "errorCode", convertNSNumberToJSINumber(runtime, @(self.errorCode)));
|
|
246
|
-
obj.setProperty(runtime, "rotationTransformMatrix", convertNSArrayToJSIArray(runtime, CGAffineTransformToArray(self.rotationTransformMatrix)));
|
|
247
|
-
int count = (int)self.items.count;
|
|
248
|
-
if (count > 0) {
|
|
249
|
-
jsi::Array array = jsi::Array(runtime, count);
|
|
250
|
-
for (size_t i = 0; i < count; i++) {
|
|
251
|
-
array.setValueAtIndex(runtime, i, [[self.items objectAtIndex:i] convertToJSIObject:runtime]);
|
|
252
|
-
}
|
|
253
|
-
obj.setProperty(runtime, "items", array);
|
|
254
|
-
} else {
|
|
255
|
-
obj.setProperty(runtime, "items", jsi::Value::null());
|
|
256
|
-
}
|
|
257
|
-
return obj;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
@end
|
|
261
|
-
|
|
262
|
-
DSQuadrilateral * convertJSIValueToDSQuadrilateral(
|
|
263
|
-
jsi::Runtime &runtime,
|
|
264
|
-
const jsi::Object &value)
|
|
265
|
-
{
|
|
266
|
-
if (value.hasProperty(runtime, "points") && value.getProperty(runtime, "points").isObject() && value.getProperty(runtime, "points").getObject(runtime).isArray(runtime)) {
|
|
267
|
-
auto jsiPoints = value.getProperty(runtime, "points").getObject(runtime).getArray(runtime);
|
|
268
|
-
size_t size = jsiPoints.size(runtime);
|
|
269
|
-
NSMutableArray *points = [NSMutableArray array];
|
|
270
|
-
for (size_t i = 0; i < size; i++) {
|
|
271
|
-
auto jsiPoint = jsiPoints.getValueAtIndex(runtime, i).getObject(runtime);
|
|
272
|
-
if (jsiPoint.hasProperty(runtime, "x") && jsiPoint.hasProperty(runtime, "y")) {
|
|
273
|
-
double x = jsiPoint.getProperty(runtime, "x").getNumber();
|
|
274
|
-
double y = jsiPoint.getProperty(runtime, "y").getNumber();
|
|
275
|
-
CGPoint point = CGPointMake(x, y);
|
|
276
|
-
[points addObject:[NSValue valueWithCGPoint:point]];
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
if (points.count == 4) {
|
|
280
|
-
return [[DSQuadrilateral alloc] initWithPointArray:[points copy]];
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
return nil;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
DSRect * convertJSIValueToDSRect(
|
|
287
|
-
jsi::Runtime &runtime,
|
|
288
|
-
const jsi::Object &value)
|
|
289
|
-
{
|
|
290
|
-
if (value.hasProperty(runtime, "top") &&
|
|
291
|
-
value.hasProperty(runtime, "bottom") &&
|
|
292
|
-
value.hasProperty(runtime, "right") &&
|
|
293
|
-
value.hasProperty(runtime, "left") &&
|
|
294
|
-
value.hasProperty(runtime, "measuredInPercentage")) {
|
|
295
|
-
double top = value.getProperty(runtime, "top").getNumber();
|
|
296
|
-
double bottom = value.getProperty(runtime, "bottom").getNumber();
|
|
297
|
-
double right = value.getProperty(runtime, "right").getNumber();
|
|
298
|
-
double left = value.getProperty(runtime, "left").getNumber();
|
|
299
|
-
BOOL measuredInPercentage = value.getProperty(runtime, "measuredInPercentage").getBool();
|
|
300
|
-
return [[DSRect alloc] initWithLeft:left top:top right:right bottom:bottom measuredInPercentage:measuredInPercentage];
|
|
301
|
-
}
|
|
302
|
-
return nil;
|
|
303
|
-
}
|
|
1
|
+
/*
|
|
2
|
+
* Copyright © Dynamsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
#import "RNDynamsoft+JSI.h"
|
|
6
|
+
#import "RNDynamsoft+Json.h"
|
|
7
|
+
#import "DSImageData+HostObject.h"
|
|
8
|
+
#import "YeetJSIUtils.h"
|
|
9
|
+
#import <DynamsoftCaptureVisionBundle/DynamsoftCaptureVisionBundle.h>
|
|
10
|
+
|
|
11
|
+
NSArray<NSNumber *> *CGAffineTransformToArray(CGAffineTransform transform) {
|
|
12
|
+
return @[@(transform.a), @(transform.b), @(transform.c), @(transform.d), @(transform.tx), @(transform.ty)];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@implementation NSData (DSNumber)
|
|
16
|
+
|
|
17
|
+
- (nullable NSArray<NSNumber *> *)toNumberArray {
|
|
18
|
+
if (!self) return nil;
|
|
19
|
+
|
|
20
|
+
const uint8_t *bytes = (const uint8_t *)self.bytes;
|
|
21
|
+
NSUInteger length = self.length;
|
|
22
|
+
|
|
23
|
+
NSMutableArray *result = [NSMutableArray arrayWithCapacity:length];
|
|
24
|
+
for (NSUInteger i = 0; i < length; i++) {
|
|
25
|
+
[result addObject:@(bytes[i])];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@end
|
|
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
|
+
|
|
47
|
+
@implementation DSCapturedResultItem (JSI)
|
|
48
|
+
|
|
49
|
+
- (Object)convertToJSIObject:(Runtime& )runtime {
|
|
50
|
+
Object obj = Object(runtime);
|
|
51
|
+
obj.setProperty(runtime, "type", convertNSNumberToJSINumber(runtime, @(self.type)));
|
|
52
|
+
obj.setProperty(runtime, "targetROIDefName", convertNSStringToJSIString(runtime, self.targetROIDefName));
|
|
53
|
+
obj.setProperty(runtime, "taskName", convertNSStringToJSIString(runtime, self.taskName));
|
|
54
|
+
switch (self.type) {
|
|
55
|
+
case DSCapturedResultItemTypeOriginalImage:
|
|
56
|
+
{
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
break;
|
|
60
|
+
case DSCapturedResultItemTypeBarcode:
|
|
61
|
+
{
|
|
62
|
+
DSBarcodeResultItem *item = (DSBarcodeResultItem *)self;
|
|
63
|
+
obj.setProperty(runtime, "format", BigInt::fromUint64(runtime, item.format));
|
|
64
|
+
obj.setProperty(runtime, "_formatNumberString", convertNSStringToJSIString(runtime, [NSNumber numberWithUnsignedInteger:item.format].stringValue));
|
|
65
|
+
obj.setProperty(runtime, "formatString", convertNSStringToJSIString(runtime, item.formatString));
|
|
66
|
+
obj.setProperty(runtime, "text", convertNSStringToJSIString(runtime, item.text));
|
|
67
|
+
obj.setProperty(runtime, "bytes", convertNSStringToJSIString(runtime, [item.bytes base64EncodedStringWithOptions:0]));
|
|
68
|
+
obj.setProperty(runtime, "location", convertNSDictionaryToJSIObject(runtime, [item.location toJson]));
|
|
69
|
+
obj.setProperty(runtime, "confidence", convertNSNumberToJSINumber(runtime, @(item.confidence)));
|
|
70
|
+
obj.setProperty(runtime, "angle", convertNSNumberToJSINumber(runtime, @(item.angle)));
|
|
71
|
+
obj.setProperty(runtime, "moduleSize", convertNSNumberToJSINumber(runtime, @(item.moduleSize)));
|
|
72
|
+
obj.setProperty(runtime, "isDPM", convertNSNumberToJSIBoolean(runtime, @(item.isDPM)));
|
|
73
|
+
obj.setProperty(runtime, "isMirrored", convertNSNumberToJSIBoolean(runtime, @(item.isMirrored)));
|
|
74
|
+
if (item.details) {
|
|
75
|
+
if (item.format == DSBarcodeFormatQRCode) {
|
|
76
|
+
DSQRCodeDetails *qrDetails = (DSQRCodeDetails *)item.details;
|
|
77
|
+
NSMutableDictionary *qrDict = [NSMutableDictionary dictionaryWithDictionary:@{
|
|
78
|
+
@"rows": @(qrDetails.rows),
|
|
79
|
+
@"columns": @(qrDetails.columns),
|
|
80
|
+
@"errorCorrectionLevel": @(qrDetails.errorCorrectionLevel),
|
|
81
|
+
@"version": @(qrDetails.version),
|
|
82
|
+
@"model": @(qrDetails.model),
|
|
83
|
+
@"mode": @(qrDetails.mode),
|
|
84
|
+
@"page": @(qrDetails.page),
|
|
85
|
+
@"totalPage": @(qrDetails.totalPage),
|
|
86
|
+
@"parityData": @(qrDetails.parityData),
|
|
87
|
+
@"dataMaskPattern": @(qrDetails.dataMaskPattern)
|
|
88
|
+
}];
|
|
89
|
+
|
|
90
|
+
if (qrDetails.codewords) {
|
|
91
|
+
qrDict[@"codewords"] = [qrDetails.codewords toNumberArray];
|
|
92
|
+
}
|
|
93
|
+
obj.setProperty(runtime, "qrCodeDetails", convertNSDictionaryToJSIObject(runtime, [qrDict copy]));
|
|
94
|
+
} else if (item.format == DSBarcodeFormatAztec) {
|
|
95
|
+
DSAztecDetails *aztecDetails = (DSAztecDetails *)item.details;
|
|
96
|
+
NSDictionary *aztecDict = @{
|
|
97
|
+
@"rows": @(aztecDetails.rows),
|
|
98
|
+
@"columns": @(aztecDetails.columns),
|
|
99
|
+
@"layerNumber": @(aztecDetails.layerNumber)
|
|
100
|
+
};
|
|
101
|
+
obj.setProperty(runtime, "aztecDetails", convertNSDictionaryToJSIObject(runtime, [aztecDict copy]));
|
|
102
|
+
} else if (item.format == DSBarcodeFormatDataMatrix) {
|
|
103
|
+
DSDataMatrixDetails *dmDetails = (DSDataMatrixDetails *)item.details;
|
|
104
|
+
NSDictionary *dmDict = @{
|
|
105
|
+
@"rows": @(dmDetails.rows),
|
|
106
|
+
@"columns": @(dmDetails.columns),
|
|
107
|
+
@"dataRegionRows": @(dmDetails.dataRegionRows),
|
|
108
|
+
@"dataRegionColumns": @(dmDetails.dataRegionColumns),
|
|
109
|
+
@"dataRegionNumber": @(dmDetails.dataRegionNumber)
|
|
110
|
+
};
|
|
111
|
+
obj.setProperty(runtime, "dataMatrixDetails", convertNSDictionaryToJSIObject(runtime, [dmDict copy]));
|
|
112
|
+
} else if ((item.format & DSBarcodeFormatOneD) != 0) {
|
|
113
|
+
DSOneDCodeDetails *onedDetails = (DSOneDCodeDetails *)item.details;
|
|
114
|
+
NSMutableDictionary *onedDict = [NSMutableDictionary dictionary];
|
|
115
|
+
|
|
116
|
+
if (onedDetails.startCharsBytes) {
|
|
117
|
+
onedDict[@"startCharsBytes"] = [onedDetails.startCharsBytes toNumberArray];
|
|
118
|
+
}
|
|
119
|
+
if (onedDetails.stopCharsBytes) {
|
|
120
|
+
onedDict[@"stopCharsBytes"] = [onedDetails.stopCharsBytes toNumberArray];
|
|
121
|
+
}
|
|
122
|
+
if (onedDetails.checkDigitBytes) {
|
|
123
|
+
onedDict[@"checkDigitBytes"] = [onedDetails.checkDigitBytes toNumberArray];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
onedDict[@"startPatternRange_lower"] = @(onedDetails.startPatternRange.minimum);
|
|
127
|
+
onedDict[@"middlePatternRange_lower"] = @(onedDetails.middlePatternRange.minimum);
|
|
128
|
+
onedDict[@"endPatternRange_lower"] = @(onedDetails.endPatternRange.minimum);
|
|
129
|
+
onedDict[@"startPatternRange_upper"] = @(onedDetails.startPatternRange.maximum);
|
|
130
|
+
onedDict[@"middlePatternRange_upper"] = @(onedDetails.middlePatternRange.maximum);
|
|
131
|
+
onedDict[@"endPatternRange_upper"] = @(onedDetails.endPatternRange.maximum);
|
|
132
|
+
|
|
133
|
+
obj.setProperty(runtime, "oneDCodeDetails", convertNSDictionaryToJSIObject(runtime, [onedDict copy]));
|
|
134
|
+
} else if (item.format == DSBarcodeFormatPDF417) {
|
|
135
|
+
DSPDF417Details *pdf417Details = (DSPDF417Details *)item.details;
|
|
136
|
+
NSMutableDictionary *pdf417Dict = [NSMutableDictionary dictionaryWithDictionary:@{
|
|
137
|
+
@"rows": @(pdf417Details.rows),
|
|
138
|
+
@"columns": @(pdf417Details.columns),
|
|
139
|
+
@"errorCorrectionLevel": @(pdf417Details.errorCorrectionLevel),
|
|
140
|
+
@"hasLeftRowIndicator": @(pdf417Details.hasLeftRowIndicator),
|
|
141
|
+
@"hasRightRowIndicator": @(pdf417Details.hasRightRowIndicator)
|
|
142
|
+
}];
|
|
143
|
+
|
|
144
|
+
if (pdf417Details.codewords) {
|
|
145
|
+
pdf417Dict[@"codewords"] = pdf417Details.codewords;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
obj.setProperty(runtime, "pdf417Details", convertNSDictionaryToJSIObject(runtime, [pdf417Dict copy]));
|
|
149
|
+
}
|
|
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
|
+
}
|
|
161
|
+
}
|
|
162
|
+
break;
|
|
163
|
+
case DSCapturedResultItemTypeTextLine:
|
|
164
|
+
{
|
|
165
|
+
DSTextLineResultItem *item = (DSTextLineResultItem *)self;
|
|
166
|
+
obj.setProperty(runtime, "text", convertNSStringToJSIString(runtime, item.text));
|
|
167
|
+
obj.setProperty(runtime, "rawText", convertNSStringToJSIString(runtime, item.rawText));
|
|
168
|
+
obj.setProperty(runtime, "location", convertNSDictionaryToJSIObject(runtime, [item.location toJson]));
|
|
169
|
+
obj.setProperty(runtime, "confidence",convertNSNumberToJSINumber(runtime, @(item.confidence)));
|
|
170
|
+
NSUInteger count = item.charResult.count;
|
|
171
|
+
if (count > 0) {
|
|
172
|
+
jsi::Array array = jsi::Array(runtime, count);
|
|
173
|
+
for (size_t i = 0; i < count; i++) {
|
|
174
|
+
array.setValueAtIndex(runtime, i, convertNSDictionaryToJSIObject(runtime, [[item.charResult objectAtIndex:i] toJson]));
|
|
175
|
+
}
|
|
176
|
+
obj.setProperty(runtime, "characterResults", array);
|
|
177
|
+
} else {
|
|
178
|
+
obj.setProperty(runtime, "characterResults", jsi::Value::null());
|
|
179
|
+
}
|
|
180
|
+
obj.setProperty(runtime, "specificationName", convertNSStringToJSIString(runtime, item.specificationName));
|
|
181
|
+
}
|
|
182
|
+
break;
|
|
183
|
+
case DSCapturedResultItemTypeDetectedQuad:
|
|
184
|
+
{
|
|
185
|
+
DSDetectedQuadResultItem *item = (DSDetectedQuadResultItem *)self;
|
|
186
|
+
obj.setProperty(runtime, "location", convertNSDictionaryToJSIObject(runtime, [item.location toJson]));
|
|
187
|
+
obj.setProperty(runtime, "confidenceAsDocumentBoundary",convertNSNumberToJSINumber(runtime, @(item.confidenceAsDocumentBoundary)));
|
|
188
|
+
}
|
|
189
|
+
break;
|
|
190
|
+
case DSCapturedResultItemTypeDeskewedImage:
|
|
191
|
+
{
|
|
192
|
+
DSDeskewedImageResultItem *item = (DSDeskewedImageResultItem *)self;
|
|
193
|
+
if (item.imageData) {
|
|
194
|
+
ImageDataHostObject hostObject = [item.imageData hostObject];
|
|
195
|
+
Object object = Object::createFromHostObject(runtime, std::make_shared<ImageDataHostObject>(hostObject));
|
|
196
|
+
obj.setProperty(runtime, "imageData", object);
|
|
197
|
+
} else {
|
|
198
|
+
obj.setProperty(runtime, "imageData", jsi::Value::null());
|
|
199
|
+
}
|
|
200
|
+
obj.setProperty(runtime, "sourceDeskewQuad", convertNSDictionaryToJSIObject(runtime, [item.sourceDeskewQuad toJson]));
|
|
201
|
+
obj.setProperty(runtime, "crossVerificationStatus", convertNSNumberToJSINumber(runtime, @(item.crossVerificationStatus)));
|
|
202
|
+
obj.setProperty(runtime, "originalToLocalMatrix", convertNSArrayToJSIArray(runtime, CGAffineTransformToArray(item.originalToLocalMatrix)));
|
|
203
|
+
}
|
|
204
|
+
break;
|
|
205
|
+
case DSCapturedResultItemTypeEnhancedImage:
|
|
206
|
+
{
|
|
207
|
+
DSEnhancedImageResultItem *item = (DSEnhancedImageResultItem *)self;
|
|
208
|
+
if (item.imageData) {
|
|
209
|
+
ImageDataHostObject hostObject = [item.imageData hostObject];
|
|
210
|
+
Object object = Object::createFromHostObject(runtime, std::make_shared<ImageDataHostObject>(hostObject));
|
|
211
|
+
obj.setProperty(runtime, "imageData", object);
|
|
212
|
+
} else {
|
|
213
|
+
obj.setProperty(runtime, "imageData", jsi::Value::null());
|
|
214
|
+
}
|
|
215
|
+
obj.setProperty(runtime, "originalToLocalMatrix", convertNSArrayToJSIArray(runtime, CGAffineTransformToArray(item.originalToLocalMatrix)));
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
case DSCapturedResultItemTypeParsedResult:
|
|
219
|
+
{
|
|
220
|
+
DSParsedResultItem *item = (DSParsedResultItem *)self;
|
|
221
|
+
NSDictionary<NSString *, NSString *> *parsedFields = item.parsedFields;
|
|
222
|
+
NSMutableDictionary *mutableDictionary = [NSMutableDictionary dictionaryWithDictionary:parsedFields];
|
|
223
|
+
for (NSString *key in [parsedFields allKeys]) {
|
|
224
|
+
[mutableDictionary setValue:@{ @"value":[parsedFields valueForKey:key],
|
|
225
|
+
@"mappingStatus":@([item getFieldMappingStatus:key]),
|
|
226
|
+
@"validationStatus":@([item getFieldValidationStatus:key]) } forKey:key];
|
|
227
|
+
}
|
|
228
|
+
obj.setProperty(runtime, "parsedFields", convertNSDictionaryToJSIObject(runtime, [mutableDictionary copy]));
|
|
229
|
+
obj.setProperty(runtime, "jsonString", convertNSStringToJSIString(runtime, item.jsonString));
|
|
230
|
+
obj.setProperty(runtime, "codeType", convertNSStringToJSIString(runtime, item.codeType));
|
|
231
|
+
}
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
return obj;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
@end
|
|
238
|
+
|
|
239
|
+
@implementation DSCapturedResult (JSI)
|
|
240
|
+
|
|
241
|
+
- (Object)convertToJSIObject:(Runtime& )runtime {
|
|
242
|
+
Object obj = Object(runtime);
|
|
243
|
+
obj.setProperty(runtime, "originalImageHashId", convertNSStringToJSIString(runtime, self.originalImageHashId));
|
|
244
|
+
obj.setProperty(runtime, "errorMessage", convertNSStringToJSIString(runtime, self.errorMessage));
|
|
245
|
+
obj.setProperty(runtime, "errorCode", convertNSNumberToJSINumber(runtime, @(self.errorCode)));
|
|
246
|
+
obj.setProperty(runtime, "rotationTransformMatrix", convertNSArrayToJSIArray(runtime, CGAffineTransformToArray(self.rotationTransformMatrix)));
|
|
247
|
+
int count = (int)self.items.count;
|
|
248
|
+
if (count > 0) {
|
|
249
|
+
jsi::Array array = jsi::Array(runtime, count);
|
|
250
|
+
for (size_t i = 0; i < count; i++) {
|
|
251
|
+
array.setValueAtIndex(runtime, i, [[self.items objectAtIndex:i] convertToJSIObject:runtime]);
|
|
252
|
+
}
|
|
253
|
+
obj.setProperty(runtime, "items", array);
|
|
254
|
+
} else {
|
|
255
|
+
obj.setProperty(runtime, "items", jsi::Value::null());
|
|
256
|
+
}
|
|
257
|
+
return obj;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
@end
|
|
261
|
+
|
|
262
|
+
DSQuadrilateral * convertJSIValueToDSQuadrilateral(
|
|
263
|
+
jsi::Runtime &runtime,
|
|
264
|
+
const jsi::Object &value)
|
|
265
|
+
{
|
|
266
|
+
if (value.hasProperty(runtime, "points") && value.getProperty(runtime, "points").isObject() && value.getProperty(runtime, "points").getObject(runtime).isArray(runtime)) {
|
|
267
|
+
auto jsiPoints = value.getProperty(runtime, "points").getObject(runtime).getArray(runtime);
|
|
268
|
+
size_t size = jsiPoints.size(runtime);
|
|
269
|
+
NSMutableArray *points = [NSMutableArray array];
|
|
270
|
+
for (size_t i = 0; i < size; i++) {
|
|
271
|
+
auto jsiPoint = jsiPoints.getValueAtIndex(runtime, i).getObject(runtime);
|
|
272
|
+
if (jsiPoint.hasProperty(runtime, "x") && jsiPoint.hasProperty(runtime, "y")) {
|
|
273
|
+
double x = jsiPoint.getProperty(runtime, "x").getNumber();
|
|
274
|
+
double y = jsiPoint.getProperty(runtime, "y").getNumber();
|
|
275
|
+
CGPoint point = CGPointMake(x, y);
|
|
276
|
+
[points addObject:[NSValue valueWithCGPoint:point]];
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (points.count == 4) {
|
|
280
|
+
return [[DSQuadrilateral alloc] initWithPointArray:[points copy]];
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
return nil;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
DSRect * convertJSIValueToDSRect(
|
|
287
|
+
jsi::Runtime &runtime,
|
|
288
|
+
const jsi::Object &value)
|
|
289
|
+
{
|
|
290
|
+
if (value.hasProperty(runtime, "top") &&
|
|
291
|
+
value.hasProperty(runtime, "bottom") &&
|
|
292
|
+
value.hasProperty(runtime, "right") &&
|
|
293
|
+
value.hasProperty(runtime, "left") &&
|
|
294
|
+
value.hasProperty(runtime, "measuredInPercentage")) {
|
|
295
|
+
double top = value.getProperty(runtime, "top").getNumber();
|
|
296
|
+
double bottom = value.getProperty(runtime, "bottom").getNumber();
|
|
297
|
+
double right = value.getProperty(runtime, "right").getNumber();
|
|
298
|
+
double left = value.getProperty(runtime, "left").getNumber();
|
|
299
|
+
BOOL measuredInPercentage = value.getProperty(runtime, "measuredInPercentage").getBool();
|
|
300
|
+
return [[DSRect alloc] initWithLeft:left top:top right:right bottom:bottom measuredInPercentage:measuredInPercentage];
|
|
301
|
+
}
|
|
302
|
+
return nil;
|
|
303
|
+
}
|