dynamsoft-capture-vision-react-native 3.4.1300 → 3.4.3000
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/dysJniLibs/debug/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibs/debug/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibs/debug/x86/librn_dys.so +0 -0
- package/android/src/main/dysJniLibs/debug/x86_64/librn_dys.so +0 -0
- package/android/src/main/dysJniLibs/release/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibs/release/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibs/release/x86/librn_dys.so +0 -0
- package/android/src/main/dysJniLibs/release/x86_64/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor81/debug/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor81/debug/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor81/debug/x86/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor81/debug/x86_64/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor81/release/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor81/release/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor81/release/x86/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor81/release/x86_64/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor82/debug/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor82/debug/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor82/debug/x86/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor82/debug/x86_64/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor82/release/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor82/release/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor82/release/x86/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor82/release/x86_64/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor86/debug/arm64-v8a/librn_dys.so +3 -0
- package/android/src/main/dysJniLibsFor86/debug/armeabi-v7a/librn_dys.so +3 -0
- package/android/src/main/dysJniLibsFor86/debug/x86/librn_dys.so +3 -0
- package/android/src/main/dysJniLibsFor86/debug/x86_64/librn_dys.so +3 -0
- package/android/src/main/dysJniLibsFor86/release/arm64-v8a/librn_dys.so +3 -0
- package/android/src/main/dysJniLibsFor86/release/armeabi-v7a/librn_dys.so +3 -0
- package/android/src/main/dysJniLibsFor86/release/x86/librn_dys.so +3 -0
- package/android/src/main/dysJniLibsFor86/release/x86_64/librn_dys.so +3 -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,733 +1,733 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright © Dynamsoft Corporation. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
#import "RNDynamsoft+Json.h"
|
|
6
|
-
|
|
7
|
-
NSArray<NSNumber *> *CGAffineTransformToArray(CGAffineTransform transform) {
|
|
8
|
-
return @[@(transform.a), @(transform.b), @(transform.c), @(transform.d), @(transform.tx), @(transform.ty)];
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
void runOnMainThread(void (^block)(void))
|
|
12
|
-
{
|
|
13
|
-
if ([NSThread isMainThread]) {
|
|
14
|
-
block();
|
|
15
|
-
} else {
|
|
16
|
-
dispatch_async(dispatch_get_main_queue(), block);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
@implementation DSQuadrilateral (Json)
|
|
21
|
-
|
|
22
|
-
+ (nullable DSQuadrilateral *)quadrilateralWithDictionary:(NSDictionary *)dictionary {
|
|
23
|
-
if (dictionary) {
|
|
24
|
-
NSArray *array = [dictionary valueForKey:@"points"];
|
|
25
|
-
NSMutableArray *points = [NSMutableArray array];
|
|
26
|
-
for (id object in array) {
|
|
27
|
-
if ([object isKindOfClass:NSDictionary.class]) {
|
|
28
|
-
NSNumber *x = [object valueForKey:@"x"];
|
|
29
|
-
NSNumber *y = [object valueForKey:@"y"];
|
|
30
|
-
CGPoint point = CGPointMake(x.floatValue, y.floatValue);
|
|
31
|
-
[points addObject:[NSValue valueWithCGPoint:point]];
|
|
32
|
-
} else {
|
|
33
|
-
return nil;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return [[DSQuadrilateral alloc] initWithPointArray:[points copy]];
|
|
37
|
-
} else {
|
|
38
|
-
return nil;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
- (NSDictionary *)toJson {
|
|
43
|
-
NSMutableArray *array = [NSMutableArray array];
|
|
44
|
-
for (NSValue *value in self.points) {
|
|
45
|
-
CGPoint point = value.CGPointValue;
|
|
46
|
-
[array addObject:@{@"x":@(point.x), @"y":@(point.y)}];
|
|
47
|
-
}
|
|
48
|
-
NSDictionary *dictionary = @{@"points":[array copy]};
|
|
49
|
-
return dictionary;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
@end
|
|
53
|
-
|
|
54
|
-
@implementation DSCharacterResult (Json)
|
|
55
|
-
|
|
56
|
-
- (NSDictionary *)toJson {
|
|
57
|
-
unichar h = self.characterH;
|
|
58
|
-
unichar m = self.characterM;
|
|
59
|
-
unichar l = self.characterL;
|
|
60
|
-
return @{ @"characterH":[NSString stringWithCharacters:&h length:1],
|
|
61
|
-
@"characterM":[NSString stringWithCharacters:&m length:1],
|
|
62
|
-
@"characterL":[NSString stringWithCharacters:&l length:1],
|
|
63
|
-
@"location":self.location ? [self.location toJson] : [NSNull null],
|
|
64
|
-
@"characterHConfidence":@(self.characterHConfidence),
|
|
65
|
-
@"characterMConfidence":@(self.characterMConfidence),
|
|
66
|
-
@"characterLConfidence":@(self.characterLConfidence)
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
@end
|
|
71
|
-
|
|
72
|
-
@implementation DSSimplifiedCaptureVisionSettings (Json)
|
|
73
|
-
|
|
74
|
-
- (void)updateWithDicitionary:(NSDictionary *)dictionary {
|
|
75
|
-
NSNumber *outputOriginalImage = [dictionary valueForKey:@"outputOriginalImage"];
|
|
76
|
-
if (outputOriginalImage) {
|
|
77
|
-
self.outputOriginalImage = outputOriginalImage.boolValue;
|
|
78
|
-
}
|
|
79
|
-
NSDictionary *roi = [dictionary valueForKey:@"roi"];
|
|
80
|
-
if (roi) {
|
|
81
|
-
self.roi = [DSQuadrilateral quadrilateralWithDictionary:roi];
|
|
82
|
-
}
|
|
83
|
-
NSNumber *roiMeasuredInPercentage = [dictionary valueForKey:@"roiMeasuredInPercentage"];
|
|
84
|
-
if (roiMeasuredInPercentage) {
|
|
85
|
-
self.roiMeasuredInPercentage = roiMeasuredInPercentage.boolValue;
|
|
86
|
-
}
|
|
87
|
-
NSNumber *maxParallelTasks = [dictionary valueForKey:@"maxParallelTasks"];
|
|
88
|
-
if (maxParallelTasks) {
|
|
89
|
-
self.maxParallelTasks = maxParallelTasks.integerValue;
|
|
90
|
-
}
|
|
91
|
-
NSNumber *timeout = [dictionary valueForKey:@"timeout"];
|
|
92
|
-
if (timeout) {
|
|
93
|
-
self.timeout = timeout.integerValue;
|
|
94
|
-
}
|
|
95
|
-
NSNumber *minImageCaptureInterval = [dictionary valueForKey:@"minImageCaptureInterval"];
|
|
96
|
-
if (minImageCaptureInterval) {
|
|
97
|
-
self.minImageCaptureInterval = minImageCaptureInterval.integerValue;
|
|
98
|
-
}
|
|
99
|
-
NSDictionary *barcodeSettings = [dictionary valueForKey:@"barcodeSettings"];
|
|
100
|
-
if (barcodeSettings) {
|
|
101
|
-
[self.barcodeSettings updateWithDicitionary:barcodeSettings];
|
|
102
|
-
}
|
|
103
|
-
NSDictionary *labelSettings = [dictionary valueForKey:@"labelSettings"];
|
|
104
|
-
if (labelSettings) {
|
|
105
|
-
[self.labelSettings updateWithDicitionary:labelSettings];
|
|
106
|
-
}
|
|
107
|
-
NSDictionary *documentSettings = [dictionary valueForKey:@"documentSettings"];
|
|
108
|
-
if (documentSettings) {
|
|
109
|
-
[self.documentSettings updateWithDicitionary:documentSettings];
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
- (NSObject *)toJson {
|
|
114
|
-
if (self) {
|
|
115
|
-
NSDictionary *dictionary = @{@"outputOriginalImage":@(self.outputOriginalImage),
|
|
116
|
-
@"roi":self.roi ? [self.roi toJson] : [NSNull null],
|
|
117
|
-
@"roiMeasuredInPercentage":@(self.roiMeasuredInPercentage),
|
|
118
|
-
@"maxParallelTasks":@(self.maxParallelTasks),
|
|
119
|
-
@"timeout":@(self.timeout),
|
|
120
|
-
@"minImageCaptureInterval":@(self.minImageCaptureInterval),
|
|
121
|
-
@"barcodeSettings": [self.barcodeSettings toJson],
|
|
122
|
-
@"labelSettings":[self.labelSettings toJson],
|
|
123
|
-
@"documentSettings":[self.documentSettings toJson] };
|
|
124
|
-
return dictionary;
|
|
125
|
-
} else {
|
|
126
|
-
return [NSNull null];
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
@end
|
|
131
|
-
|
|
132
|
-
@implementation DSSimplifiedBarcodeReaderSettings (Json)
|
|
133
|
-
|
|
134
|
-
- (void)updateWithDicitionary:(NSDictionary *)dictionary {
|
|
135
|
-
NSString *_barcodeFormatIdsNumberString = [dictionary valueForKey:@"_barcodeFormatIdsNumberString"];
|
|
136
|
-
if (_barcodeFormatIdsNumberString) {
|
|
137
|
-
NSUInteger unsignedIntegerValue = strtoull([_barcodeFormatIdsNumberString UTF8String], NULL, 10);
|
|
138
|
-
self.barcodeFormatIds = unsignedIntegerValue;
|
|
139
|
-
}
|
|
140
|
-
NSNumber *expectedBarcodesCount = [dictionary valueForKey:@"expectedBarcodesCount"];
|
|
141
|
-
if (expectedBarcodesCount) {
|
|
142
|
-
self.expectedBarcodesCount = expectedBarcodesCount.integerValue;
|
|
143
|
-
}
|
|
144
|
-
NSNumber *minResultConfidence = [dictionary valueForKey:@"minResultConfidence"];
|
|
145
|
-
if (minResultConfidence) {
|
|
146
|
-
self.minResultConfidence = minResultConfidence.integerValue;
|
|
147
|
-
}
|
|
148
|
-
NSNumber *minBarcodeTextLength = [dictionary valueForKey:@"minBarcodeTextLength"];
|
|
149
|
-
if (minBarcodeTextLength) {
|
|
150
|
-
self.minBarcodeTextLength = minBarcodeTextLength.integerValue;
|
|
151
|
-
}
|
|
152
|
-
NSString *barcodeTextRegExPattern = [dictionary valueForKey:@"barcodeTextRegExPattern"];
|
|
153
|
-
if (barcodeTextRegExPattern) {
|
|
154
|
-
self.barcodeTextRegExPattern = barcodeTextRegExPattern;
|
|
155
|
-
}
|
|
156
|
-
NSNumber *maxThreadsInOneTask = [dictionary valueForKey:@"maxThreadsInOneTask"];
|
|
157
|
-
if (maxThreadsInOneTask) {
|
|
158
|
-
self.maxThreadsInOneTask = maxThreadsInOneTask.integerValue;
|
|
159
|
-
}
|
|
160
|
-
NSNumber *scaleDownThreshold = [dictionary valueForKey:@"scaleDownThreshold"];
|
|
161
|
-
if (scaleDownThreshold) {
|
|
162
|
-
self.scaleDownThreshold = scaleDownThreshold.integerValue;
|
|
163
|
-
}
|
|
164
|
-
NSArray *localizationModes = [dictionary valueForKey:@"localizationModes"];
|
|
165
|
-
if (localizationModes) {
|
|
166
|
-
self.localizationModes = localizationModes;
|
|
167
|
-
}
|
|
168
|
-
NSArray *deblurModes = [dictionary valueForKey:@"deblurModes"];
|
|
169
|
-
if (deblurModes) {
|
|
170
|
-
self.deblurModes = deblurModes;
|
|
171
|
-
}
|
|
172
|
-
NSArray *grayscaleTransformationModes = [dictionary valueForKey:@"grayscaleTransformationModes"];
|
|
173
|
-
if (grayscaleTransformationModes) {
|
|
174
|
-
self.grayscaleTransformationModes = grayscaleTransformationModes;
|
|
175
|
-
}
|
|
176
|
-
NSArray *grayscaleEnhancementModes = [dictionary valueForKey:@"grayscaleEnhancementModes"];
|
|
177
|
-
if (grayscaleEnhancementModes) {
|
|
178
|
-
self.grayscaleEnhancementModes = grayscaleEnhancementModes;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
- (NSObject *)toJson {
|
|
183
|
-
if (self) {
|
|
184
|
-
NSDictionary *dictionary = @{@"_barcodeFormatIdsNumberString":@(self.barcodeFormatIds).stringValue,
|
|
185
|
-
@"expectedBarcodesCount":@(self.expectedBarcodesCount),
|
|
186
|
-
@"minResultConfidence":@(self.minResultConfidence),
|
|
187
|
-
@"minBarcodeTextLength":@(self.minBarcodeTextLength),
|
|
188
|
-
@"barcodeTextRegExPattern":self.barcodeTextRegExPattern ? self.barcodeTextRegExPattern : [NSNull null],
|
|
189
|
-
@"maxThreadsInOneTask":@(self.maxThreadsInOneTask),
|
|
190
|
-
@"scaleDownThreshold":@(self.scaleDownThreshold),
|
|
191
|
-
@"localizationModes":self.localizationModes ? self.localizationModes : [NSNull null],
|
|
192
|
-
@"deblurModes":self.deblurModes ? self.deblurModes : [NSNull null],
|
|
193
|
-
@"grayscaleTransformationModes":self.grayscaleTransformationModes ? self.grayscaleTransformationModes : [NSNull null],
|
|
194
|
-
@"grayscaleEnhancementModes":self.grayscaleEnhancementModes ? self.grayscaleEnhancementModes : [NSNull null]
|
|
195
|
-
};
|
|
196
|
-
return dictionary;
|
|
197
|
-
} else {
|
|
198
|
-
return [NSNull null];
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
@end
|
|
203
|
-
|
|
204
|
-
@implementation DSSimplifiedLabelRecognizerSettings (Json)
|
|
205
|
-
|
|
206
|
-
- (void)updateWithDicitionary:(NSDictionary *)dictionary {
|
|
207
|
-
NSArray *grayscaleTransformationModes = [dictionary valueForKey:@"grayscaleTransformationModes"];
|
|
208
|
-
if (grayscaleTransformationModes) {
|
|
209
|
-
self.grayscaleTransformationModes = grayscaleTransformationModes;
|
|
210
|
-
}
|
|
211
|
-
NSArray *grayscaleEnhancementModes = [dictionary valueForKey:@"grayscaleEnhancementModes"];
|
|
212
|
-
if (grayscaleEnhancementModes) {
|
|
213
|
-
self.grayscaleEnhancementModes = grayscaleEnhancementModes;
|
|
214
|
-
}
|
|
215
|
-
NSString *characterModelName = [dictionary valueForKey:@"characterModelName"];
|
|
216
|
-
if (characterModelName) {
|
|
217
|
-
self.characterModelName = characterModelName;
|
|
218
|
-
}
|
|
219
|
-
NSString *lineStringRegExPattern = [dictionary valueForKey:@"lineStringRegExPattern"];
|
|
220
|
-
if (lineStringRegExPattern) {
|
|
221
|
-
self.lineStringRegExPattern = lineStringRegExPattern;
|
|
222
|
-
}
|
|
223
|
-
NSNumber *maxThreadsInOneTask = [dictionary valueForKey:@"maxThreadsInOneTask"];
|
|
224
|
-
if (maxThreadsInOneTask) {
|
|
225
|
-
self.maxThreadsInOneTask = maxThreadsInOneTask.integerValue;
|
|
226
|
-
}
|
|
227
|
-
NSNumber *scaleDownThreshold = [dictionary valueForKey:@"scaleDownThreshold"];
|
|
228
|
-
if (scaleDownThreshold) {
|
|
229
|
-
self.scaleDownThreshold = scaleDownThreshold.integerValue;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
- (NSObject *)toJson {
|
|
234
|
-
if (self) {
|
|
235
|
-
NSDictionary *dictionary = @{@"grayscaleTransformationModes":self.grayscaleTransformationModes ? self.grayscaleTransformationModes : [NSNull null],
|
|
236
|
-
@"grayscaleEnhancementModes":self.grayscaleEnhancementModes ? self.grayscaleEnhancementModes : [NSNull null],
|
|
237
|
-
@"characterModelName":self.characterModelName ? self.characterModelName : [NSNull null],
|
|
238
|
-
@"lineStringRegExPattern":self.lineStringRegExPattern ? self.lineStringRegExPattern : [NSNull null],
|
|
239
|
-
@"maxThreadsInOneTask":@(self.maxThreadsInOneTask),
|
|
240
|
-
@"scaleDownThreshold":@(self.scaleDownThreshold)
|
|
241
|
-
};
|
|
242
|
-
return dictionary;
|
|
243
|
-
} else {
|
|
244
|
-
return [NSNull null];
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
@end
|
|
249
|
-
|
|
250
|
-
@implementation DSSimplifiedDocumentNormalizerSettings (Json)
|
|
251
|
-
|
|
252
|
-
- (void)updateWithDicitionary:(NSDictionary *)dictionary {
|
|
253
|
-
NSArray *grayscaleTransformationModes = [dictionary valueForKey:@"grayscaleTransformationModes"];
|
|
254
|
-
if (grayscaleTransformationModes) {
|
|
255
|
-
self.grayscaleTransformationModes = grayscaleTransformationModes;
|
|
256
|
-
}
|
|
257
|
-
NSArray *grayscaleEnhancementModes = [dictionary valueForKey:@"grayscaleEnhancementModes"];
|
|
258
|
-
if (grayscaleEnhancementModes) {
|
|
259
|
-
self.grayscaleEnhancementModes = grayscaleEnhancementModes;
|
|
260
|
-
}
|
|
261
|
-
NSNumber *colourMode = [dictionary valueForKey:@"colourMode"];
|
|
262
|
-
if (colourMode) {
|
|
263
|
-
self.colourMode = (DSImageColourMode)colourMode.integerValue;
|
|
264
|
-
}
|
|
265
|
-
NSArray *pageSize = [dictionary valueForKey:@"pageSize"];
|
|
266
|
-
if (pageSize) {
|
|
267
|
-
NSNumber *width = pageSize.firstObject;
|
|
268
|
-
NSNumber *height = pageSize.lastObject;
|
|
269
|
-
if (width && height) {
|
|
270
|
-
self.pageSize = CGSizeMake(width.integerValue, height.integerValue);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
NSNumber *brightness = [dictionary valueForKey:@"brightness"];
|
|
274
|
-
if (brightness) {
|
|
275
|
-
self.brightness = brightness.integerValue;
|
|
276
|
-
}
|
|
277
|
-
NSNumber *contrast = [dictionary valueForKey:@"contrast"];
|
|
278
|
-
if (contrast) {
|
|
279
|
-
self.contrast = contrast.integerValue;
|
|
280
|
-
}
|
|
281
|
-
NSNumber *maxThreadsInOneTask = [dictionary valueForKey:@"maxThreadsInOneTask"];
|
|
282
|
-
if (maxThreadsInOneTask) {
|
|
283
|
-
self.maxThreadsInOneTask = maxThreadsInOneTask.integerValue;
|
|
284
|
-
}
|
|
285
|
-
NSNumber *scaleDownThreshold = [dictionary valueForKey:@"scaleDownThreshold"];
|
|
286
|
-
if (scaleDownThreshold) {
|
|
287
|
-
self.scaleDownThreshold = scaleDownThreshold.integerValue;
|
|
288
|
-
}
|
|
289
|
-
NSNumber *minQuadrilateralAreaRatio = [dictionary valueForKey:@"minQuadrilateralAreaRatio"];
|
|
290
|
-
if (minQuadrilateralAreaRatio) {
|
|
291
|
-
self.minQuadrilateralAreaRatio = minQuadrilateralAreaRatio.integerValue;
|
|
292
|
-
}
|
|
293
|
-
NSNumber *expectedDocumentsCount = [dictionary valueForKey:@"expectedDocumentsCount"];
|
|
294
|
-
if (expectedDocumentsCount) {
|
|
295
|
-
self.expectedDocumentsCount = expectedDocumentsCount.integerValue;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
- (NSObject *)toJson {
|
|
300
|
-
if (self) {
|
|
301
|
-
NSDictionary *dictionary = @{@"grayscaleTransformationModes":self.grayscaleTransformationModes ? self.grayscaleTransformationModes : [NSNull null],
|
|
302
|
-
@"grayscaleEnhancementModes":self.grayscaleEnhancementModes ? self.grayscaleEnhancementModes : [NSNull null],
|
|
303
|
-
@"colourMode":@(self.colourMode),
|
|
304
|
-
@"pageSize":@[@(self.pageSize.width), @(self.pageSize.height)],
|
|
305
|
-
@"brightness":@(self.brightness),
|
|
306
|
-
@"contrast":@(self.contrast),
|
|
307
|
-
@"maxThreadsInOneTask":@(self.maxThreadsInOneTask),
|
|
308
|
-
@"scaleDownThreshold":@(self.scaleDownThreshold),
|
|
309
|
-
@"minQuadrilateralAreaRatio":@(self.minQuadrilateralAreaRatio),
|
|
310
|
-
@"expectedDocumentsCount":@(self.expectedDocumentsCount) };
|
|
311
|
-
return dictionary;
|
|
312
|
-
} else {
|
|
313
|
-
return [NSNull null];
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
@end
|
|
318
|
-
|
|
319
|
-
@implementation NSData (DSNumber)
|
|
320
|
-
|
|
321
|
-
- (nullable NSArray<NSNumber *> *)toNumberArray {
|
|
322
|
-
if (!self) return nil;
|
|
323
|
-
|
|
324
|
-
const uint8_t *bytes = (const uint8_t *)self.bytes;
|
|
325
|
-
NSUInteger length = self.length;
|
|
326
|
-
|
|
327
|
-
NSMutableArray *result = [NSMutableArray arrayWithCapacity:length];
|
|
328
|
-
for (NSUInteger i = 0; i < length; i++) {
|
|
329
|
-
[result addObject:@(bytes[i])];
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
return result;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
@end
|
|
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
|
-
|
|
351
|
-
@implementation DSCapturedResultItem (Json)
|
|
352
|
-
|
|
353
|
-
- (nullable NSDictionary *)toJson {
|
|
354
|
-
NSDictionary *dictionary;
|
|
355
|
-
switch (self.type) {
|
|
356
|
-
case DSCapturedResultItemTypeOriginalImage:
|
|
357
|
-
return nil;
|
|
358
|
-
break;
|
|
359
|
-
case DSCapturedResultItemTypeBarcode:
|
|
360
|
-
{
|
|
361
|
-
DSBarcodeResultItem *item = (DSBarcodeResultItem *)self;
|
|
362
|
-
NSMutableDictionary *mutableDictionary = [NSMutableDictionary dictionaryWithDictionary:@{
|
|
363
|
-
@"type":@(item.type),
|
|
364
|
-
@"targetROIDefName":item.targetROIDefName,
|
|
365
|
-
@"taskName":item.taskName,
|
|
366
|
-
@"_formatNumberString": [NSNumber numberWithUnsignedInteger:item.format].stringValue,
|
|
367
|
-
@"formatString":item.formatString,
|
|
368
|
-
@"text":item.text,
|
|
369
|
-
@"bytes":[item.bytes base64EncodedStringWithOptions:0],
|
|
370
|
-
@"location":[item.location toJson],
|
|
371
|
-
@"confidence":@(item.confidence),
|
|
372
|
-
@"angle":@(item.angle),
|
|
373
|
-
@"moduleSize":@(item.moduleSize),
|
|
374
|
-
@"isDPM":@(item.isDPM),
|
|
375
|
-
@"isMirrored":@(item.isMirrored)
|
|
376
|
-
}];
|
|
377
|
-
if (item.details) {
|
|
378
|
-
if (item.format == DSBarcodeFormatQRCode) {
|
|
379
|
-
DSQRCodeDetails *qrDetails = (DSQRCodeDetails *)item.details;
|
|
380
|
-
NSMutableDictionary *qrDict = [NSMutableDictionary dictionaryWithDictionary:@{
|
|
381
|
-
@"rows": @(qrDetails.rows),
|
|
382
|
-
@"columns": @(qrDetails.columns),
|
|
383
|
-
@"errorCorrectionLevel": @(qrDetails.errorCorrectionLevel),
|
|
384
|
-
@"version": @(qrDetails.version),
|
|
385
|
-
@"model": @(qrDetails.model),
|
|
386
|
-
@"mode": @(qrDetails.mode),
|
|
387
|
-
@"page": @(qrDetails.page),
|
|
388
|
-
@"totalPage": @(qrDetails.totalPage),
|
|
389
|
-
@"parityData": @(qrDetails.parityData),
|
|
390
|
-
@"dataMaskPattern": @(qrDetails.dataMaskPattern)
|
|
391
|
-
}];
|
|
392
|
-
|
|
393
|
-
if (qrDetails.codewords) {
|
|
394
|
-
qrDict[@"codewords"] = [qrDetails.codewords toNumberArray];
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
mutableDictionary[@"qrCodeDetails"] = qrDict;
|
|
398
|
-
} else if (item.format == DSBarcodeFormatAztec) {
|
|
399
|
-
DSAztecDetails *aztecDetails = (DSAztecDetails *)item.details;
|
|
400
|
-
NSDictionary *aztecDict = @{
|
|
401
|
-
@"rows": @(aztecDetails.rows),
|
|
402
|
-
@"columns": @(aztecDetails.columns),
|
|
403
|
-
@"layerNumber": @(aztecDetails.layerNumber)
|
|
404
|
-
};
|
|
405
|
-
mutableDictionary[@"aztecDetails"] = aztecDict;
|
|
406
|
-
} else if (item.format == DSBarcodeFormatDataMatrix) {
|
|
407
|
-
DSDataMatrixDetails *dmDetails = (DSDataMatrixDetails *)item.details;
|
|
408
|
-
NSDictionary *dmDict = @{
|
|
409
|
-
@"rows": @(dmDetails.rows),
|
|
410
|
-
@"columns": @(dmDetails.columns),
|
|
411
|
-
@"dataRegionRows": @(dmDetails.dataRegionRows),
|
|
412
|
-
@"dataRegionColumns": @(dmDetails.dataRegionColumns),
|
|
413
|
-
@"dataRegionNumber": @(dmDetails.dataRegionNumber)
|
|
414
|
-
};
|
|
415
|
-
mutableDictionary[@"dataMatrixDetails"] = dmDict;
|
|
416
|
-
} else if ((item.format & DSBarcodeFormatOneD) != 0) {
|
|
417
|
-
DSOneDCodeDetails *onedDetails = (DSOneDCodeDetails *)item.details;
|
|
418
|
-
NSMutableDictionary *onedDict = [NSMutableDictionary dictionary];
|
|
419
|
-
|
|
420
|
-
if (onedDetails.startCharsBytes) {
|
|
421
|
-
onedDict[@"startCharsBytes"] = [onedDetails.startCharsBytes toNumberArray];
|
|
422
|
-
}
|
|
423
|
-
if (onedDetails.stopCharsBytes) {
|
|
424
|
-
onedDict[@"stopCharsBytes"] = [onedDetails.stopCharsBytes toNumberArray];
|
|
425
|
-
}
|
|
426
|
-
if (onedDetails.checkDigitBytes) {
|
|
427
|
-
onedDict[@"checkDigitBytes"] = [onedDetails.checkDigitBytes toNumberArray];
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
onedDict[@"startPatternRange_lower"] = @(onedDetails.startPatternRange.minimum);
|
|
431
|
-
onedDict[@"middlePatternRange_lower"] = @(onedDetails.middlePatternRange.minimum);
|
|
432
|
-
onedDict[@"endPatternRange_lower"] = @(onedDetails.endPatternRange.minimum);
|
|
433
|
-
onedDict[@"startPatternRange_upper"] = @(onedDetails.startPatternRange.maximum);
|
|
434
|
-
onedDict[@"middlePatternRange_upper"] = @(onedDetails.middlePatternRange.maximum);
|
|
435
|
-
onedDict[@"endPatternRange_upper"] = @(onedDetails.endPatternRange.maximum);
|
|
436
|
-
|
|
437
|
-
mutableDictionary[@"oneDCodeDetails"] = onedDict;
|
|
438
|
-
} else if (item.format == DSBarcodeFormatPDF417) {
|
|
439
|
-
DSPDF417Details *pdf417Details = (DSPDF417Details *)item.details;
|
|
440
|
-
NSMutableDictionary *pdf417Dict = [NSMutableDictionary dictionaryWithDictionary:@{
|
|
441
|
-
@"rows": @(pdf417Details.rows),
|
|
442
|
-
@"columns": @(pdf417Details.columns),
|
|
443
|
-
@"errorCorrectionLevel": @(pdf417Details.errorCorrectionLevel),
|
|
444
|
-
@"hasLeftRowIndicator": @(pdf417Details.hasLeftRowIndicator),
|
|
445
|
-
@"hasRightRowIndicator": @(pdf417Details.hasRightRowIndicator)
|
|
446
|
-
}];
|
|
447
|
-
|
|
448
|
-
if (pdf417Details.codewords) {
|
|
449
|
-
pdf417Dict[@"codewords"] = pdf417Details.codewords;
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
mutableDictionary[@"pdf417Details"] = pdf417Dict;
|
|
453
|
-
}
|
|
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
|
-
}
|
|
465
|
-
dictionary = [mutableDictionary copy];
|
|
466
|
-
}
|
|
467
|
-
break;
|
|
468
|
-
case DSCapturedResultItemTypeTextLine:
|
|
469
|
-
{
|
|
470
|
-
DSTextLineResultItem *item = (DSTextLineResultItem *)self;
|
|
471
|
-
NSArray<DSCharacterResult *> *charResultArray = item.charResult;
|
|
472
|
-
id charResult;
|
|
473
|
-
if (charResultArray.count > 0) {
|
|
474
|
-
NSMutableArray<NSDictionary *> *mutableArray = [NSMutableArray array];
|
|
475
|
-
for (DSCharacterResult *result in charResultArray) {
|
|
476
|
-
[mutableArray addObject:[result toJson]];
|
|
477
|
-
}
|
|
478
|
-
charResult = [mutableArray copy];
|
|
479
|
-
} else {
|
|
480
|
-
charResult = [NSNull null];
|
|
481
|
-
}
|
|
482
|
-
dictionary = @{ @"type":@(item.type),
|
|
483
|
-
@"targetROIDefName":item.targetROIDefName,
|
|
484
|
-
@"taskName":item.taskName,
|
|
485
|
-
@"text":item.text,
|
|
486
|
-
@"rawText":item.rawText,
|
|
487
|
-
@"location":[item.location toJson],
|
|
488
|
-
@"confidence":@(item.confidence),
|
|
489
|
-
@"characterResults":charResult,
|
|
490
|
-
@"specificationName": item.specificationName
|
|
491
|
-
};
|
|
492
|
-
}
|
|
493
|
-
break;
|
|
494
|
-
case DSCapturedResultItemTypeDetectedQuad:
|
|
495
|
-
{
|
|
496
|
-
DSDetectedQuadResultItem *item = (DSDetectedQuadResultItem *)self;
|
|
497
|
-
dictionary = @{ @"type":@(item.type),
|
|
498
|
-
@"targetROIDefName":item.targetROIDefName,
|
|
499
|
-
@"taskName":item.taskName,
|
|
500
|
-
@"location":[item.location toJson],
|
|
501
|
-
@"confidenceAsDocumentBoundary":@(item.confidenceAsDocumentBoundary),
|
|
502
|
-
@"crossVerificationStatus":@(item.crossVerificationStatus)
|
|
503
|
-
};
|
|
504
|
-
}
|
|
505
|
-
break;
|
|
506
|
-
case DSCapturedResultItemTypeDeskewedImage:
|
|
507
|
-
{
|
|
508
|
-
DSDeskewedImageResultItem *item = (DSDeskewedImageResultItem *)self;
|
|
509
|
-
dictionary = @{ @"type":@(item.type),
|
|
510
|
-
@"targetROIDefName":item.targetROIDefName,
|
|
511
|
-
@"taskName":item.taskName,
|
|
512
|
-
@"sourceDeskewQuad":[item.sourceDeskewQuad toJson],
|
|
513
|
-
@"crossVerificationStatus":@(item.crossVerificationStatus),
|
|
514
|
-
@"originalToLocalMatrix":CGAffineTransformToArray(item.originalToLocalMatrix)
|
|
515
|
-
};
|
|
516
|
-
}
|
|
517
|
-
break;
|
|
518
|
-
case DSCapturedResultItemTypeEnhancedImage: {
|
|
519
|
-
DSEnhancedImageResultItem *item = (DSEnhancedImageResultItem *)self;
|
|
520
|
-
dictionary = @{ @"type":@(item.type),
|
|
521
|
-
@"targetROIDefName":item.targetROIDefName,
|
|
522
|
-
@"taskName":item.taskName,
|
|
523
|
-
@"originalToLocalMatrix":CGAffineTransformToArray(item.originalToLocalMatrix)
|
|
524
|
-
};
|
|
525
|
-
break;
|
|
526
|
-
}
|
|
527
|
-
case DSCapturedResultItemTypeParsedResult:
|
|
528
|
-
{
|
|
529
|
-
DSParsedResultItem *item = (DSParsedResultItem *)self;
|
|
530
|
-
NSDictionary<NSString *, NSString *> *parsedFields = item.parsedFields;
|
|
531
|
-
NSMutableDictionary *mutableDictionary = [NSMutableDictionary dictionaryWithDictionary:parsedFields];
|
|
532
|
-
for (NSString *key in [parsedFields allKeys]) {
|
|
533
|
-
[mutableDictionary setValue:@{ @"value":[parsedFields valueForKey:key],
|
|
534
|
-
@"mappingStatus":@([item getFieldMappingStatus:key]),
|
|
535
|
-
@"validationStatus":@([item getFieldValidationStatus:key]) } forKey:key];
|
|
536
|
-
}
|
|
537
|
-
dictionary = @{ @"type":@(item.type),
|
|
538
|
-
@"targetROIDefName":item.targetROIDefName,
|
|
539
|
-
@"taskName":item.taskName,
|
|
540
|
-
@"jsonString":item.jsonString,
|
|
541
|
-
@"codeType":item.codeType,
|
|
542
|
-
@"parsedFields":[mutableDictionary copy]
|
|
543
|
-
};
|
|
544
|
-
}
|
|
545
|
-
break;
|
|
546
|
-
}
|
|
547
|
-
return dictionary;
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
@end
|
|
551
|
-
|
|
552
|
-
@implementation DSCapturedResult (Json)
|
|
553
|
-
|
|
554
|
-
- (NSObject *)toJson {
|
|
555
|
-
if (self) {
|
|
556
|
-
id items;
|
|
557
|
-
if (self.items.count > 0) {
|
|
558
|
-
NSMutableArray *array = [NSMutableArray array];
|
|
559
|
-
for (DSCapturedResultItem *item in self.items) {
|
|
560
|
-
NSDictionary *obj = [item toJson];
|
|
561
|
-
if (obj) {
|
|
562
|
-
[array addObject:obj];
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
items = [array copy];
|
|
566
|
-
} else {
|
|
567
|
-
items = [NSNull null];
|
|
568
|
-
}
|
|
569
|
-
NSDictionary *dictionary = @{@"originalImageHashId":self.originalImageHashId,
|
|
570
|
-
@"items":items,
|
|
571
|
-
@"rotationTransformMatrix":CGAffineTransformToArray(self.rotationTransformMatrix),
|
|
572
|
-
@"errorCode":@(self.errorCode),
|
|
573
|
-
@"errorMessage":self.errorMessage ? self.errorMessage : [NSNull null]
|
|
574
|
-
};
|
|
575
|
-
return dictionary;
|
|
576
|
-
} else {
|
|
577
|
-
return [NSNull null];
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
@end
|
|
582
|
-
|
|
583
|
-
@implementation DSDecodedBarcodesResult (Json)
|
|
584
|
-
|
|
585
|
-
- (NSObject *)toJson {
|
|
586
|
-
if (self) {
|
|
587
|
-
id items;
|
|
588
|
-
if (self.items.count > 0) {
|
|
589
|
-
NSMutableArray *array = [NSMutableArray array];
|
|
590
|
-
for (DSBarcodeResultItem *item in self.items) {
|
|
591
|
-
NSDictionary *obj = [item toJson];
|
|
592
|
-
if (obj) {
|
|
593
|
-
[array addObject:obj];
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
items = [array copy];
|
|
597
|
-
} else {
|
|
598
|
-
items = [NSNull null];
|
|
599
|
-
}
|
|
600
|
-
NSDictionary *dictionary = @{@"originalImageHashId":self.originalImageHashId,
|
|
601
|
-
@"items":items,
|
|
602
|
-
@"rotationTransformMatrix":CGAffineTransformToArray(self.rotationTransformMatrix),
|
|
603
|
-
@"errorCode":@(self.errorCode),
|
|
604
|
-
@"errorMessage":self.errorMessage ? self.errorMessage : [NSNull null]
|
|
605
|
-
};
|
|
606
|
-
return dictionary;
|
|
607
|
-
} else {
|
|
608
|
-
return [NSNull null];
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
@end
|
|
613
|
-
|
|
614
|
-
@implementation DSProcessedDocumentResult (Json)
|
|
615
|
-
|
|
616
|
-
- (NSObject *)toJson {
|
|
617
|
-
if (self) {
|
|
618
|
-
id detectedQuadResultItems;
|
|
619
|
-
if (self.detectedQuadResultItems.count > 0) {
|
|
620
|
-
NSMutableArray *array = [NSMutableArray array];
|
|
621
|
-
for (DSDetectedQuadResultItem *item in self.detectedQuadResultItems) {
|
|
622
|
-
NSDictionary *obj = [item toJson];
|
|
623
|
-
if (obj) {
|
|
624
|
-
[array addObject:obj];
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
detectedQuadResultItems = [array copy];
|
|
628
|
-
} else {
|
|
629
|
-
detectedQuadResultItems = [NSNull null];
|
|
630
|
-
}
|
|
631
|
-
id deskewedImageResultItems;
|
|
632
|
-
if (self.deskewedImageResultItems.count > 0) {
|
|
633
|
-
NSMutableArray *array = [NSMutableArray array];
|
|
634
|
-
for (DSDeskewedImageResultItem *item in self.deskewedImageResultItems) {
|
|
635
|
-
NSDictionary *obj = [item toJson];
|
|
636
|
-
if (obj) {
|
|
637
|
-
[array addObject:obj];
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
deskewedImageResultItems = [array copy];
|
|
641
|
-
} else {
|
|
642
|
-
deskewedImageResultItems = [NSNull null];
|
|
643
|
-
}
|
|
644
|
-
id enhancedImageResultItems;
|
|
645
|
-
if (self.enhancedImageResultItems.count > 0) {
|
|
646
|
-
NSMutableArray *array = [NSMutableArray array];
|
|
647
|
-
for (DSEnhancedImageResultItem *item in self.enhancedImageResultItems) {
|
|
648
|
-
NSDictionary *obj = [item toJson];
|
|
649
|
-
if (obj) {
|
|
650
|
-
[array addObject:obj];
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
enhancedImageResultItems = [array copy];
|
|
654
|
-
} else {
|
|
655
|
-
enhancedImageResultItems = [NSNull null];
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
NSDictionary *dictionary = @{@"originalImageHashId":self.originalImageHashId,
|
|
659
|
-
@"detectedQuadResultItems":detectedQuadResultItems,
|
|
660
|
-
@"deskewedImageResultItems":deskewedImageResultItems,
|
|
661
|
-
@"enhancedImageResultItems":enhancedImageResultItems,
|
|
662
|
-
@"rotationTransformMatrix":CGAffineTransformToArray(self.rotationTransformMatrix),
|
|
663
|
-
@"errorCode":@(self.errorCode),
|
|
664
|
-
@"errorMessage":self.errorMessage ? self.errorMessage : [NSNull null]
|
|
665
|
-
};
|
|
666
|
-
return dictionary;
|
|
667
|
-
} else {
|
|
668
|
-
return [NSNull null];
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
@end
|
|
673
|
-
|
|
674
|
-
@implementation DSRecognizedTextLinesResult (Json)
|
|
675
|
-
|
|
676
|
-
- (NSObject *)toJson {
|
|
677
|
-
if (self) {
|
|
678
|
-
id items;
|
|
679
|
-
if (self.items.count > 0) {
|
|
680
|
-
NSMutableArray *array = [NSMutableArray array];
|
|
681
|
-
for (DSTextLineResultItem *item in self.items) {
|
|
682
|
-
NSDictionary *obj = [item toJson];
|
|
683
|
-
if (obj) {
|
|
684
|
-
[array addObject:obj];
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
items = [array copy];
|
|
688
|
-
} else {
|
|
689
|
-
items = [NSNull null];
|
|
690
|
-
}
|
|
691
|
-
NSDictionary *dictionary = @{@"originalImageHashId":self.originalImageHashId,
|
|
692
|
-
@"items":items,
|
|
693
|
-
@"rotationTransformMatrix":CGAffineTransformToArray(self.rotationTransformMatrix),
|
|
694
|
-
@"errorCode":@(self.errorCode),
|
|
695
|
-
@"errorMessage":self.errorMessage ? self.errorMessage : [NSNull null]
|
|
696
|
-
};
|
|
697
|
-
return dictionary;
|
|
698
|
-
} else {
|
|
699
|
-
return [NSNull null];
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
@end
|
|
704
|
-
|
|
705
|
-
@implementation DSParsedResult (Json)
|
|
706
|
-
|
|
707
|
-
- (NSObject *)toJson {
|
|
708
|
-
if (self) {
|
|
709
|
-
id items;
|
|
710
|
-
if (self.items.count > 0) {
|
|
711
|
-
NSMutableArray *array = [NSMutableArray array];
|
|
712
|
-
for (DSParsedResultItem *item in self.items) {
|
|
713
|
-
NSDictionary *obj = [item toJson];
|
|
714
|
-
if (obj) {
|
|
715
|
-
[array addObject:obj];
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
items = [array copy];
|
|
719
|
-
} else {
|
|
720
|
-
items = [NSNull null];
|
|
721
|
-
}
|
|
722
|
-
NSDictionary *dictionary = @{@"originalImageHashId":self.originalImageHashId,
|
|
723
|
-
@"items":items,
|
|
724
|
-
@"errorCode":@(self.errorCode),
|
|
725
|
-
@"errorMessage":self.errorMessage ? self.errorMessage : [NSNull null]
|
|
726
|
-
};
|
|
727
|
-
return dictionary;
|
|
728
|
-
} else {
|
|
729
|
-
return [NSNull null];
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
@end
|
|
1
|
+
/*
|
|
2
|
+
* Copyright © Dynamsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
#import "RNDynamsoft+Json.h"
|
|
6
|
+
|
|
7
|
+
NSArray<NSNumber *> *CGAffineTransformToArray(CGAffineTransform transform) {
|
|
8
|
+
return @[@(transform.a), @(transform.b), @(transform.c), @(transform.d), @(transform.tx), @(transform.ty)];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
void runOnMainThread(void (^block)(void))
|
|
12
|
+
{
|
|
13
|
+
if ([NSThread isMainThread]) {
|
|
14
|
+
block();
|
|
15
|
+
} else {
|
|
16
|
+
dispatch_async(dispatch_get_main_queue(), block);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@implementation DSQuadrilateral (Json)
|
|
21
|
+
|
|
22
|
+
+ (nullable DSQuadrilateral *)quadrilateralWithDictionary:(NSDictionary *)dictionary {
|
|
23
|
+
if (dictionary) {
|
|
24
|
+
NSArray *array = [dictionary valueForKey:@"points"];
|
|
25
|
+
NSMutableArray *points = [NSMutableArray array];
|
|
26
|
+
for (id object in array) {
|
|
27
|
+
if ([object isKindOfClass:NSDictionary.class]) {
|
|
28
|
+
NSNumber *x = [object valueForKey:@"x"];
|
|
29
|
+
NSNumber *y = [object valueForKey:@"y"];
|
|
30
|
+
CGPoint point = CGPointMake(x.floatValue, y.floatValue);
|
|
31
|
+
[points addObject:[NSValue valueWithCGPoint:point]];
|
|
32
|
+
} else {
|
|
33
|
+
return nil;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return [[DSQuadrilateral alloc] initWithPointArray:[points copy]];
|
|
37
|
+
} else {
|
|
38
|
+
return nil;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
- (NSDictionary *)toJson {
|
|
43
|
+
NSMutableArray *array = [NSMutableArray array];
|
|
44
|
+
for (NSValue *value in self.points) {
|
|
45
|
+
CGPoint point = value.CGPointValue;
|
|
46
|
+
[array addObject:@{@"x":@(point.x), @"y":@(point.y)}];
|
|
47
|
+
}
|
|
48
|
+
NSDictionary *dictionary = @{@"points":[array copy]};
|
|
49
|
+
return dictionary;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@end
|
|
53
|
+
|
|
54
|
+
@implementation DSCharacterResult (Json)
|
|
55
|
+
|
|
56
|
+
- (NSDictionary *)toJson {
|
|
57
|
+
unichar h = self.characterH;
|
|
58
|
+
unichar m = self.characterM;
|
|
59
|
+
unichar l = self.characterL;
|
|
60
|
+
return @{ @"characterH":[NSString stringWithCharacters:&h length:1],
|
|
61
|
+
@"characterM":[NSString stringWithCharacters:&m length:1],
|
|
62
|
+
@"characterL":[NSString stringWithCharacters:&l length:1],
|
|
63
|
+
@"location":self.location ? [self.location toJson] : [NSNull null],
|
|
64
|
+
@"characterHConfidence":@(self.characterHConfidence),
|
|
65
|
+
@"characterMConfidence":@(self.characterMConfidence),
|
|
66
|
+
@"characterLConfidence":@(self.characterLConfidence)
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@end
|
|
71
|
+
|
|
72
|
+
@implementation DSSimplifiedCaptureVisionSettings (Json)
|
|
73
|
+
|
|
74
|
+
- (void)updateWithDicitionary:(NSDictionary *)dictionary {
|
|
75
|
+
NSNumber *outputOriginalImage = [dictionary valueForKey:@"outputOriginalImage"];
|
|
76
|
+
if (outputOriginalImage) {
|
|
77
|
+
self.outputOriginalImage = outputOriginalImage.boolValue;
|
|
78
|
+
}
|
|
79
|
+
NSDictionary *roi = [dictionary valueForKey:@"roi"];
|
|
80
|
+
if (roi) {
|
|
81
|
+
self.roi = [DSQuadrilateral quadrilateralWithDictionary:roi];
|
|
82
|
+
}
|
|
83
|
+
NSNumber *roiMeasuredInPercentage = [dictionary valueForKey:@"roiMeasuredInPercentage"];
|
|
84
|
+
if (roiMeasuredInPercentage) {
|
|
85
|
+
self.roiMeasuredInPercentage = roiMeasuredInPercentage.boolValue;
|
|
86
|
+
}
|
|
87
|
+
NSNumber *maxParallelTasks = [dictionary valueForKey:@"maxParallelTasks"];
|
|
88
|
+
if (maxParallelTasks) {
|
|
89
|
+
self.maxParallelTasks = maxParallelTasks.integerValue;
|
|
90
|
+
}
|
|
91
|
+
NSNumber *timeout = [dictionary valueForKey:@"timeout"];
|
|
92
|
+
if (timeout) {
|
|
93
|
+
self.timeout = timeout.integerValue;
|
|
94
|
+
}
|
|
95
|
+
NSNumber *minImageCaptureInterval = [dictionary valueForKey:@"minImageCaptureInterval"];
|
|
96
|
+
if (minImageCaptureInterval) {
|
|
97
|
+
self.minImageCaptureInterval = minImageCaptureInterval.integerValue;
|
|
98
|
+
}
|
|
99
|
+
NSDictionary *barcodeSettings = [dictionary valueForKey:@"barcodeSettings"];
|
|
100
|
+
if (barcodeSettings) {
|
|
101
|
+
[self.barcodeSettings updateWithDicitionary:barcodeSettings];
|
|
102
|
+
}
|
|
103
|
+
NSDictionary *labelSettings = [dictionary valueForKey:@"labelSettings"];
|
|
104
|
+
if (labelSettings) {
|
|
105
|
+
[self.labelSettings updateWithDicitionary:labelSettings];
|
|
106
|
+
}
|
|
107
|
+
NSDictionary *documentSettings = [dictionary valueForKey:@"documentSettings"];
|
|
108
|
+
if (documentSettings) {
|
|
109
|
+
[self.documentSettings updateWithDicitionary:documentSettings];
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
- (NSObject *)toJson {
|
|
114
|
+
if (self) {
|
|
115
|
+
NSDictionary *dictionary = @{@"outputOriginalImage":@(self.outputOriginalImage),
|
|
116
|
+
@"roi":self.roi ? [self.roi toJson] : [NSNull null],
|
|
117
|
+
@"roiMeasuredInPercentage":@(self.roiMeasuredInPercentage),
|
|
118
|
+
@"maxParallelTasks":@(self.maxParallelTasks),
|
|
119
|
+
@"timeout":@(self.timeout),
|
|
120
|
+
@"minImageCaptureInterval":@(self.minImageCaptureInterval),
|
|
121
|
+
@"barcodeSettings": [self.barcodeSettings toJson],
|
|
122
|
+
@"labelSettings":[self.labelSettings toJson],
|
|
123
|
+
@"documentSettings":[self.documentSettings toJson] };
|
|
124
|
+
return dictionary;
|
|
125
|
+
} else {
|
|
126
|
+
return [NSNull null];
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@end
|
|
131
|
+
|
|
132
|
+
@implementation DSSimplifiedBarcodeReaderSettings (Json)
|
|
133
|
+
|
|
134
|
+
- (void)updateWithDicitionary:(NSDictionary *)dictionary {
|
|
135
|
+
NSString *_barcodeFormatIdsNumberString = [dictionary valueForKey:@"_barcodeFormatIdsNumberString"];
|
|
136
|
+
if (_barcodeFormatIdsNumberString) {
|
|
137
|
+
NSUInteger unsignedIntegerValue = strtoull([_barcodeFormatIdsNumberString UTF8String], NULL, 10);
|
|
138
|
+
self.barcodeFormatIds = unsignedIntegerValue;
|
|
139
|
+
}
|
|
140
|
+
NSNumber *expectedBarcodesCount = [dictionary valueForKey:@"expectedBarcodesCount"];
|
|
141
|
+
if (expectedBarcodesCount) {
|
|
142
|
+
self.expectedBarcodesCount = expectedBarcodesCount.integerValue;
|
|
143
|
+
}
|
|
144
|
+
NSNumber *minResultConfidence = [dictionary valueForKey:@"minResultConfidence"];
|
|
145
|
+
if (minResultConfidence) {
|
|
146
|
+
self.minResultConfidence = minResultConfidence.integerValue;
|
|
147
|
+
}
|
|
148
|
+
NSNumber *minBarcodeTextLength = [dictionary valueForKey:@"minBarcodeTextLength"];
|
|
149
|
+
if (minBarcodeTextLength) {
|
|
150
|
+
self.minBarcodeTextLength = minBarcodeTextLength.integerValue;
|
|
151
|
+
}
|
|
152
|
+
NSString *barcodeTextRegExPattern = [dictionary valueForKey:@"barcodeTextRegExPattern"];
|
|
153
|
+
if (barcodeTextRegExPattern) {
|
|
154
|
+
self.barcodeTextRegExPattern = barcodeTextRegExPattern;
|
|
155
|
+
}
|
|
156
|
+
NSNumber *maxThreadsInOneTask = [dictionary valueForKey:@"maxThreadsInOneTask"];
|
|
157
|
+
if (maxThreadsInOneTask) {
|
|
158
|
+
self.maxThreadsInOneTask = maxThreadsInOneTask.integerValue;
|
|
159
|
+
}
|
|
160
|
+
NSNumber *scaleDownThreshold = [dictionary valueForKey:@"scaleDownThreshold"];
|
|
161
|
+
if (scaleDownThreshold) {
|
|
162
|
+
self.scaleDownThreshold = scaleDownThreshold.integerValue;
|
|
163
|
+
}
|
|
164
|
+
NSArray *localizationModes = [dictionary valueForKey:@"localizationModes"];
|
|
165
|
+
if (localizationModes) {
|
|
166
|
+
self.localizationModes = localizationModes;
|
|
167
|
+
}
|
|
168
|
+
NSArray *deblurModes = [dictionary valueForKey:@"deblurModes"];
|
|
169
|
+
if (deblurModes) {
|
|
170
|
+
self.deblurModes = deblurModes;
|
|
171
|
+
}
|
|
172
|
+
NSArray *grayscaleTransformationModes = [dictionary valueForKey:@"grayscaleTransformationModes"];
|
|
173
|
+
if (grayscaleTransformationModes) {
|
|
174
|
+
self.grayscaleTransformationModes = grayscaleTransformationModes;
|
|
175
|
+
}
|
|
176
|
+
NSArray *grayscaleEnhancementModes = [dictionary valueForKey:@"grayscaleEnhancementModes"];
|
|
177
|
+
if (grayscaleEnhancementModes) {
|
|
178
|
+
self.grayscaleEnhancementModes = grayscaleEnhancementModes;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
- (NSObject *)toJson {
|
|
183
|
+
if (self) {
|
|
184
|
+
NSDictionary *dictionary = @{@"_barcodeFormatIdsNumberString":@(self.barcodeFormatIds).stringValue,
|
|
185
|
+
@"expectedBarcodesCount":@(self.expectedBarcodesCount),
|
|
186
|
+
@"minResultConfidence":@(self.minResultConfidence),
|
|
187
|
+
@"minBarcodeTextLength":@(self.minBarcodeTextLength),
|
|
188
|
+
@"barcodeTextRegExPattern":self.barcodeTextRegExPattern ? self.barcodeTextRegExPattern : [NSNull null],
|
|
189
|
+
@"maxThreadsInOneTask":@(self.maxThreadsInOneTask),
|
|
190
|
+
@"scaleDownThreshold":@(self.scaleDownThreshold),
|
|
191
|
+
@"localizationModes":self.localizationModes ? self.localizationModes : [NSNull null],
|
|
192
|
+
@"deblurModes":self.deblurModes ? self.deblurModes : [NSNull null],
|
|
193
|
+
@"grayscaleTransformationModes":self.grayscaleTransformationModes ? self.grayscaleTransformationModes : [NSNull null],
|
|
194
|
+
@"grayscaleEnhancementModes":self.grayscaleEnhancementModes ? self.grayscaleEnhancementModes : [NSNull null]
|
|
195
|
+
};
|
|
196
|
+
return dictionary;
|
|
197
|
+
} else {
|
|
198
|
+
return [NSNull null];
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
@end
|
|
203
|
+
|
|
204
|
+
@implementation DSSimplifiedLabelRecognizerSettings (Json)
|
|
205
|
+
|
|
206
|
+
- (void)updateWithDicitionary:(NSDictionary *)dictionary {
|
|
207
|
+
NSArray *grayscaleTransformationModes = [dictionary valueForKey:@"grayscaleTransformationModes"];
|
|
208
|
+
if (grayscaleTransformationModes) {
|
|
209
|
+
self.grayscaleTransformationModes = grayscaleTransformationModes;
|
|
210
|
+
}
|
|
211
|
+
NSArray *grayscaleEnhancementModes = [dictionary valueForKey:@"grayscaleEnhancementModes"];
|
|
212
|
+
if (grayscaleEnhancementModes) {
|
|
213
|
+
self.grayscaleEnhancementModes = grayscaleEnhancementModes;
|
|
214
|
+
}
|
|
215
|
+
NSString *characterModelName = [dictionary valueForKey:@"characterModelName"];
|
|
216
|
+
if (characterModelName) {
|
|
217
|
+
self.characterModelName = characterModelName;
|
|
218
|
+
}
|
|
219
|
+
NSString *lineStringRegExPattern = [dictionary valueForKey:@"lineStringRegExPattern"];
|
|
220
|
+
if (lineStringRegExPattern) {
|
|
221
|
+
self.lineStringRegExPattern = lineStringRegExPattern;
|
|
222
|
+
}
|
|
223
|
+
NSNumber *maxThreadsInOneTask = [dictionary valueForKey:@"maxThreadsInOneTask"];
|
|
224
|
+
if (maxThreadsInOneTask) {
|
|
225
|
+
self.maxThreadsInOneTask = maxThreadsInOneTask.integerValue;
|
|
226
|
+
}
|
|
227
|
+
NSNumber *scaleDownThreshold = [dictionary valueForKey:@"scaleDownThreshold"];
|
|
228
|
+
if (scaleDownThreshold) {
|
|
229
|
+
self.scaleDownThreshold = scaleDownThreshold.integerValue;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
- (NSObject *)toJson {
|
|
234
|
+
if (self) {
|
|
235
|
+
NSDictionary *dictionary = @{@"grayscaleTransformationModes":self.grayscaleTransformationModes ? self.grayscaleTransformationModes : [NSNull null],
|
|
236
|
+
@"grayscaleEnhancementModes":self.grayscaleEnhancementModes ? self.grayscaleEnhancementModes : [NSNull null],
|
|
237
|
+
@"characterModelName":self.characterModelName ? self.characterModelName : [NSNull null],
|
|
238
|
+
@"lineStringRegExPattern":self.lineStringRegExPattern ? self.lineStringRegExPattern : [NSNull null],
|
|
239
|
+
@"maxThreadsInOneTask":@(self.maxThreadsInOneTask),
|
|
240
|
+
@"scaleDownThreshold":@(self.scaleDownThreshold)
|
|
241
|
+
};
|
|
242
|
+
return dictionary;
|
|
243
|
+
} else {
|
|
244
|
+
return [NSNull null];
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
@end
|
|
249
|
+
|
|
250
|
+
@implementation DSSimplifiedDocumentNormalizerSettings (Json)
|
|
251
|
+
|
|
252
|
+
- (void)updateWithDicitionary:(NSDictionary *)dictionary {
|
|
253
|
+
NSArray *grayscaleTransformationModes = [dictionary valueForKey:@"grayscaleTransformationModes"];
|
|
254
|
+
if (grayscaleTransformationModes) {
|
|
255
|
+
self.grayscaleTransformationModes = grayscaleTransformationModes;
|
|
256
|
+
}
|
|
257
|
+
NSArray *grayscaleEnhancementModes = [dictionary valueForKey:@"grayscaleEnhancementModes"];
|
|
258
|
+
if (grayscaleEnhancementModes) {
|
|
259
|
+
self.grayscaleEnhancementModes = grayscaleEnhancementModes;
|
|
260
|
+
}
|
|
261
|
+
NSNumber *colourMode = [dictionary valueForKey:@"colourMode"];
|
|
262
|
+
if (colourMode) {
|
|
263
|
+
self.colourMode = (DSImageColourMode)colourMode.integerValue;
|
|
264
|
+
}
|
|
265
|
+
NSArray *pageSize = [dictionary valueForKey:@"pageSize"];
|
|
266
|
+
if (pageSize) {
|
|
267
|
+
NSNumber *width = pageSize.firstObject;
|
|
268
|
+
NSNumber *height = pageSize.lastObject;
|
|
269
|
+
if (width && height) {
|
|
270
|
+
self.pageSize = CGSizeMake(width.integerValue, height.integerValue);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
NSNumber *brightness = [dictionary valueForKey:@"brightness"];
|
|
274
|
+
if (brightness) {
|
|
275
|
+
self.brightness = brightness.integerValue;
|
|
276
|
+
}
|
|
277
|
+
NSNumber *contrast = [dictionary valueForKey:@"contrast"];
|
|
278
|
+
if (contrast) {
|
|
279
|
+
self.contrast = contrast.integerValue;
|
|
280
|
+
}
|
|
281
|
+
NSNumber *maxThreadsInOneTask = [dictionary valueForKey:@"maxThreadsInOneTask"];
|
|
282
|
+
if (maxThreadsInOneTask) {
|
|
283
|
+
self.maxThreadsInOneTask = maxThreadsInOneTask.integerValue;
|
|
284
|
+
}
|
|
285
|
+
NSNumber *scaleDownThreshold = [dictionary valueForKey:@"scaleDownThreshold"];
|
|
286
|
+
if (scaleDownThreshold) {
|
|
287
|
+
self.scaleDownThreshold = scaleDownThreshold.integerValue;
|
|
288
|
+
}
|
|
289
|
+
NSNumber *minQuadrilateralAreaRatio = [dictionary valueForKey:@"minQuadrilateralAreaRatio"];
|
|
290
|
+
if (minQuadrilateralAreaRatio) {
|
|
291
|
+
self.minQuadrilateralAreaRatio = minQuadrilateralAreaRatio.integerValue;
|
|
292
|
+
}
|
|
293
|
+
NSNumber *expectedDocumentsCount = [dictionary valueForKey:@"expectedDocumentsCount"];
|
|
294
|
+
if (expectedDocumentsCount) {
|
|
295
|
+
self.expectedDocumentsCount = expectedDocumentsCount.integerValue;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
- (NSObject *)toJson {
|
|
300
|
+
if (self) {
|
|
301
|
+
NSDictionary *dictionary = @{@"grayscaleTransformationModes":self.grayscaleTransformationModes ? self.grayscaleTransformationModes : [NSNull null],
|
|
302
|
+
@"grayscaleEnhancementModes":self.grayscaleEnhancementModes ? self.grayscaleEnhancementModes : [NSNull null],
|
|
303
|
+
@"colourMode":@(self.colourMode),
|
|
304
|
+
@"pageSize":@[@(self.pageSize.width), @(self.pageSize.height)],
|
|
305
|
+
@"brightness":@(self.brightness),
|
|
306
|
+
@"contrast":@(self.contrast),
|
|
307
|
+
@"maxThreadsInOneTask":@(self.maxThreadsInOneTask),
|
|
308
|
+
@"scaleDownThreshold":@(self.scaleDownThreshold),
|
|
309
|
+
@"minQuadrilateralAreaRatio":@(self.minQuadrilateralAreaRatio),
|
|
310
|
+
@"expectedDocumentsCount":@(self.expectedDocumentsCount) };
|
|
311
|
+
return dictionary;
|
|
312
|
+
} else {
|
|
313
|
+
return [NSNull null];
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
@end
|
|
318
|
+
|
|
319
|
+
@implementation NSData (DSNumber)
|
|
320
|
+
|
|
321
|
+
- (nullable NSArray<NSNumber *> *)toNumberArray {
|
|
322
|
+
if (!self) return nil;
|
|
323
|
+
|
|
324
|
+
const uint8_t *bytes = (const uint8_t *)self.bytes;
|
|
325
|
+
NSUInteger length = self.length;
|
|
326
|
+
|
|
327
|
+
NSMutableArray *result = [NSMutableArray arrayWithCapacity:length];
|
|
328
|
+
for (NSUInteger i = 0; i < length; i++) {
|
|
329
|
+
[result addObject:@(bytes[i])];
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
return result;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
@end
|
|
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
|
+
|
|
351
|
+
@implementation DSCapturedResultItem (Json)
|
|
352
|
+
|
|
353
|
+
- (nullable NSDictionary *)toJson {
|
|
354
|
+
NSDictionary *dictionary;
|
|
355
|
+
switch (self.type) {
|
|
356
|
+
case DSCapturedResultItemTypeOriginalImage:
|
|
357
|
+
return nil;
|
|
358
|
+
break;
|
|
359
|
+
case DSCapturedResultItemTypeBarcode:
|
|
360
|
+
{
|
|
361
|
+
DSBarcodeResultItem *item = (DSBarcodeResultItem *)self;
|
|
362
|
+
NSMutableDictionary *mutableDictionary = [NSMutableDictionary dictionaryWithDictionary:@{
|
|
363
|
+
@"type":@(item.type),
|
|
364
|
+
@"targetROIDefName":item.targetROIDefName,
|
|
365
|
+
@"taskName":item.taskName,
|
|
366
|
+
@"_formatNumberString": [NSNumber numberWithUnsignedInteger:item.format].stringValue,
|
|
367
|
+
@"formatString":item.formatString,
|
|
368
|
+
@"text":item.text,
|
|
369
|
+
@"bytes":[item.bytes base64EncodedStringWithOptions:0],
|
|
370
|
+
@"location":[item.location toJson],
|
|
371
|
+
@"confidence":@(item.confidence),
|
|
372
|
+
@"angle":@(item.angle),
|
|
373
|
+
@"moduleSize":@(item.moduleSize),
|
|
374
|
+
@"isDPM":@(item.isDPM),
|
|
375
|
+
@"isMirrored":@(item.isMirrored)
|
|
376
|
+
}];
|
|
377
|
+
if (item.details) {
|
|
378
|
+
if (item.format == DSBarcodeFormatQRCode) {
|
|
379
|
+
DSQRCodeDetails *qrDetails = (DSQRCodeDetails *)item.details;
|
|
380
|
+
NSMutableDictionary *qrDict = [NSMutableDictionary dictionaryWithDictionary:@{
|
|
381
|
+
@"rows": @(qrDetails.rows),
|
|
382
|
+
@"columns": @(qrDetails.columns),
|
|
383
|
+
@"errorCorrectionLevel": @(qrDetails.errorCorrectionLevel),
|
|
384
|
+
@"version": @(qrDetails.version),
|
|
385
|
+
@"model": @(qrDetails.model),
|
|
386
|
+
@"mode": @(qrDetails.mode),
|
|
387
|
+
@"page": @(qrDetails.page),
|
|
388
|
+
@"totalPage": @(qrDetails.totalPage),
|
|
389
|
+
@"parityData": @(qrDetails.parityData),
|
|
390
|
+
@"dataMaskPattern": @(qrDetails.dataMaskPattern)
|
|
391
|
+
}];
|
|
392
|
+
|
|
393
|
+
if (qrDetails.codewords) {
|
|
394
|
+
qrDict[@"codewords"] = [qrDetails.codewords toNumberArray];
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
mutableDictionary[@"qrCodeDetails"] = qrDict;
|
|
398
|
+
} else if (item.format == DSBarcodeFormatAztec) {
|
|
399
|
+
DSAztecDetails *aztecDetails = (DSAztecDetails *)item.details;
|
|
400
|
+
NSDictionary *aztecDict = @{
|
|
401
|
+
@"rows": @(aztecDetails.rows),
|
|
402
|
+
@"columns": @(aztecDetails.columns),
|
|
403
|
+
@"layerNumber": @(aztecDetails.layerNumber)
|
|
404
|
+
};
|
|
405
|
+
mutableDictionary[@"aztecDetails"] = aztecDict;
|
|
406
|
+
} else if (item.format == DSBarcodeFormatDataMatrix) {
|
|
407
|
+
DSDataMatrixDetails *dmDetails = (DSDataMatrixDetails *)item.details;
|
|
408
|
+
NSDictionary *dmDict = @{
|
|
409
|
+
@"rows": @(dmDetails.rows),
|
|
410
|
+
@"columns": @(dmDetails.columns),
|
|
411
|
+
@"dataRegionRows": @(dmDetails.dataRegionRows),
|
|
412
|
+
@"dataRegionColumns": @(dmDetails.dataRegionColumns),
|
|
413
|
+
@"dataRegionNumber": @(dmDetails.dataRegionNumber)
|
|
414
|
+
};
|
|
415
|
+
mutableDictionary[@"dataMatrixDetails"] = dmDict;
|
|
416
|
+
} else if ((item.format & DSBarcodeFormatOneD) != 0) {
|
|
417
|
+
DSOneDCodeDetails *onedDetails = (DSOneDCodeDetails *)item.details;
|
|
418
|
+
NSMutableDictionary *onedDict = [NSMutableDictionary dictionary];
|
|
419
|
+
|
|
420
|
+
if (onedDetails.startCharsBytes) {
|
|
421
|
+
onedDict[@"startCharsBytes"] = [onedDetails.startCharsBytes toNumberArray];
|
|
422
|
+
}
|
|
423
|
+
if (onedDetails.stopCharsBytes) {
|
|
424
|
+
onedDict[@"stopCharsBytes"] = [onedDetails.stopCharsBytes toNumberArray];
|
|
425
|
+
}
|
|
426
|
+
if (onedDetails.checkDigitBytes) {
|
|
427
|
+
onedDict[@"checkDigitBytes"] = [onedDetails.checkDigitBytes toNumberArray];
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
onedDict[@"startPatternRange_lower"] = @(onedDetails.startPatternRange.minimum);
|
|
431
|
+
onedDict[@"middlePatternRange_lower"] = @(onedDetails.middlePatternRange.minimum);
|
|
432
|
+
onedDict[@"endPatternRange_lower"] = @(onedDetails.endPatternRange.minimum);
|
|
433
|
+
onedDict[@"startPatternRange_upper"] = @(onedDetails.startPatternRange.maximum);
|
|
434
|
+
onedDict[@"middlePatternRange_upper"] = @(onedDetails.middlePatternRange.maximum);
|
|
435
|
+
onedDict[@"endPatternRange_upper"] = @(onedDetails.endPatternRange.maximum);
|
|
436
|
+
|
|
437
|
+
mutableDictionary[@"oneDCodeDetails"] = onedDict;
|
|
438
|
+
} else if (item.format == DSBarcodeFormatPDF417) {
|
|
439
|
+
DSPDF417Details *pdf417Details = (DSPDF417Details *)item.details;
|
|
440
|
+
NSMutableDictionary *pdf417Dict = [NSMutableDictionary dictionaryWithDictionary:@{
|
|
441
|
+
@"rows": @(pdf417Details.rows),
|
|
442
|
+
@"columns": @(pdf417Details.columns),
|
|
443
|
+
@"errorCorrectionLevel": @(pdf417Details.errorCorrectionLevel),
|
|
444
|
+
@"hasLeftRowIndicator": @(pdf417Details.hasLeftRowIndicator),
|
|
445
|
+
@"hasRightRowIndicator": @(pdf417Details.hasRightRowIndicator)
|
|
446
|
+
}];
|
|
447
|
+
|
|
448
|
+
if (pdf417Details.codewords) {
|
|
449
|
+
pdf417Dict[@"codewords"] = pdf417Details.codewords;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
mutableDictionary[@"pdf417Details"] = pdf417Dict;
|
|
453
|
+
}
|
|
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
|
+
}
|
|
465
|
+
dictionary = [mutableDictionary copy];
|
|
466
|
+
}
|
|
467
|
+
break;
|
|
468
|
+
case DSCapturedResultItemTypeTextLine:
|
|
469
|
+
{
|
|
470
|
+
DSTextLineResultItem *item = (DSTextLineResultItem *)self;
|
|
471
|
+
NSArray<DSCharacterResult *> *charResultArray = item.charResult;
|
|
472
|
+
id charResult;
|
|
473
|
+
if (charResultArray.count > 0) {
|
|
474
|
+
NSMutableArray<NSDictionary *> *mutableArray = [NSMutableArray array];
|
|
475
|
+
for (DSCharacterResult *result in charResultArray) {
|
|
476
|
+
[mutableArray addObject:[result toJson]];
|
|
477
|
+
}
|
|
478
|
+
charResult = [mutableArray copy];
|
|
479
|
+
} else {
|
|
480
|
+
charResult = [NSNull null];
|
|
481
|
+
}
|
|
482
|
+
dictionary = @{ @"type":@(item.type),
|
|
483
|
+
@"targetROIDefName":item.targetROIDefName,
|
|
484
|
+
@"taskName":item.taskName,
|
|
485
|
+
@"text":item.text,
|
|
486
|
+
@"rawText":item.rawText,
|
|
487
|
+
@"location":[item.location toJson],
|
|
488
|
+
@"confidence":@(item.confidence),
|
|
489
|
+
@"characterResults":charResult,
|
|
490
|
+
@"specificationName": item.specificationName
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
break;
|
|
494
|
+
case DSCapturedResultItemTypeDetectedQuad:
|
|
495
|
+
{
|
|
496
|
+
DSDetectedQuadResultItem *item = (DSDetectedQuadResultItem *)self;
|
|
497
|
+
dictionary = @{ @"type":@(item.type),
|
|
498
|
+
@"targetROIDefName":item.targetROIDefName,
|
|
499
|
+
@"taskName":item.taskName,
|
|
500
|
+
@"location":[item.location toJson],
|
|
501
|
+
@"confidenceAsDocumentBoundary":@(item.confidenceAsDocumentBoundary),
|
|
502
|
+
@"crossVerificationStatus":@(item.crossVerificationStatus)
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
break;
|
|
506
|
+
case DSCapturedResultItemTypeDeskewedImage:
|
|
507
|
+
{
|
|
508
|
+
DSDeskewedImageResultItem *item = (DSDeskewedImageResultItem *)self;
|
|
509
|
+
dictionary = @{ @"type":@(item.type),
|
|
510
|
+
@"targetROIDefName":item.targetROIDefName,
|
|
511
|
+
@"taskName":item.taskName,
|
|
512
|
+
@"sourceDeskewQuad":[item.sourceDeskewQuad toJson],
|
|
513
|
+
@"crossVerificationStatus":@(item.crossVerificationStatus),
|
|
514
|
+
@"originalToLocalMatrix":CGAffineTransformToArray(item.originalToLocalMatrix)
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
break;
|
|
518
|
+
case DSCapturedResultItemTypeEnhancedImage: {
|
|
519
|
+
DSEnhancedImageResultItem *item = (DSEnhancedImageResultItem *)self;
|
|
520
|
+
dictionary = @{ @"type":@(item.type),
|
|
521
|
+
@"targetROIDefName":item.targetROIDefName,
|
|
522
|
+
@"taskName":item.taskName,
|
|
523
|
+
@"originalToLocalMatrix":CGAffineTransformToArray(item.originalToLocalMatrix)
|
|
524
|
+
};
|
|
525
|
+
break;
|
|
526
|
+
}
|
|
527
|
+
case DSCapturedResultItemTypeParsedResult:
|
|
528
|
+
{
|
|
529
|
+
DSParsedResultItem *item = (DSParsedResultItem *)self;
|
|
530
|
+
NSDictionary<NSString *, NSString *> *parsedFields = item.parsedFields;
|
|
531
|
+
NSMutableDictionary *mutableDictionary = [NSMutableDictionary dictionaryWithDictionary:parsedFields];
|
|
532
|
+
for (NSString *key in [parsedFields allKeys]) {
|
|
533
|
+
[mutableDictionary setValue:@{ @"value":[parsedFields valueForKey:key],
|
|
534
|
+
@"mappingStatus":@([item getFieldMappingStatus:key]),
|
|
535
|
+
@"validationStatus":@([item getFieldValidationStatus:key]) } forKey:key];
|
|
536
|
+
}
|
|
537
|
+
dictionary = @{ @"type":@(item.type),
|
|
538
|
+
@"targetROIDefName":item.targetROIDefName,
|
|
539
|
+
@"taskName":item.taskName,
|
|
540
|
+
@"jsonString":item.jsonString,
|
|
541
|
+
@"codeType":item.codeType,
|
|
542
|
+
@"parsedFields":[mutableDictionary copy]
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
break;
|
|
546
|
+
}
|
|
547
|
+
return dictionary;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
@end
|
|
551
|
+
|
|
552
|
+
@implementation DSCapturedResult (Json)
|
|
553
|
+
|
|
554
|
+
- (NSObject *)toJson {
|
|
555
|
+
if (self) {
|
|
556
|
+
id items;
|
|
557
|
+
if (self.items.count > 0) {
|
|
558
|
+
NSMutableArray *array = [NSMutableArray array];
|
|
559
|
+
for (DSCapturedResultItem *item in self.items) {
|
|
560
|
+
NSDictionary *obj = [item toJson];
|
|
561
|
+
if (obj) {
|
|
562
|
+
[array addObject:obj];
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
items = [array copy];
|
|
566
|
+
} else {
|
|
567
|
+
items = [NSNull null];
|
|
568
|
+
}
|
|
569
|
+
NSDictionary *dictionary = @{@"originalImageHashId":self.originalImageHashId,
|
|
570
|
+
@"items":items,
|
|
571
|
+
@"rotationTransformMatrix":CGAffineTransformToArray(self.rotationTransformMatrix),
|
|
572
|
+
@"errorCode":@(self.errorCode),
|
|
573
|
+
@"errorMessage":self.errorMessage ? self.errorMessage : [NSNull null]
|
|
574
|
+
};
|
|
575
|
+
return dictionary;
|
|
576
|
+
} else {
|
|
577
|
+
return [NSNull null];
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
@end
|
|
582
|
+
|
|
583
|
+
@implementation DSDecodedBarcodesResult (Json)
|
|
584
|
+
|
|
585
|
+
- (NSObject *)toJson {
|
|
586
|
+
if (self) {
|
|
587
|
+
id items;
|
|
588
|
+
if (self.items.count > 0) {
|
|
589
|
+
NSMutableArray *array = [NSMutableArray array];
|
|
590
|
+
for (DSBarcodeResultItem *item in self.items) {
|
|
591
|
+
NSDictionary *obj = [item toJson];
|
|
592
|
+
if (obj) {
|
|
593
|
+
[array addObject:obj];
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
items = [array copy];
|
|
597
|
+
} else {
|
|
598
|
+
items = [NSNull null];
|
|
599
|
+
}
|
|
600
|
+
NSDictionary *dictionary = @{@"originalImageHashId":self.originalImageHashId,
|
|
601
|
+
@"items":items,
|
|
602
|
+
@"rotationTransformMatrix":CGAffineTransformToArray(self.rotationTransformMatrix),
|
|
603
|
+
@"errorCode":@(self.errorCode),
|
|
604
|
+
@"errorMessage":self.errorMessage ? self.errorMessage : [NSNull null]
|
|
605
|
+
};
|
|
606
|
+
return dictionary;
|
|
607
|
+
} else {
|
|
608
|
+
return [NSNull null];
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
@end
|
|
613
|
+
|
|
614
|
+
@implementation DSProcessedDocumentResult (Json)
|
|
615
|
+
|
|
616
|
+
- (NSObject *)toJson {
|
|
617
|
+
if (self) {
|
|
618
|
+
id detectedQuadResultItems;
|
|
619
|
+
if (self.detectedQuadResultItems.count > 0) {
|
|
620
|
+
NSMutableArray *array = [NSMutableArray array];
|
|
621
|
+
for (DSDetectedQuadResultItem *item in self.detectedQuadResultItems) {
|
|
622
|
+
NSDictionary *obj = [item toJson];
|
|
623
|
+
if (obj) {
|
|
624
|
+
[array addObject:obj];
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
detectedQuadResultItems = [array copy];
|
|
628
|
+
} else {
|
|
629
|
+
detectedQuadResultItems = [NSNull null];
|
|
630
|
+
}
|
|
631
|
+
id deskewedImageResultItems;
|
|
632
|
+
if (self.deskewedImageResultItems.count > 0) {
|
|
633
|
+
NSMutableArray *array = [NSMutableArray array];
|
|
634
|
+
for (DSDeskewedImageResultItem *item in self.deskewedImageResultItems) {
|
|
635
|
+
NSDictionary *obj = [item toJson];
|
|
636
|
+
if (obj) {
|
|
637
|
+
[array addObject:obj];
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
deskewedImageResultItems = [array copy];
|
|
641
|
+
} else {
|
|
642
|
+
deskewedImageResultItems = [NSNull null];
|
|
643
|
+
}
|
|
644
|
+
id enhancedImageResultItems;
|
|
645
|
+
if (self.enhancedImageResultItems.count > 0) {
|
|
646
|
+
NSMutableArray *array = [NSMutableArray array];
|
|
647
|
+
for (DSEnhancedImageResultItem *item in self.enhancedImageResultItems) {
|
|
648
|
+
NSDictionary *obj = [item toJson];
|
|
649
|
+
if (obj) {
|
|
650
|
+
[array addObject:obj];
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
enhancedImageResultItems = [array copy];
|
|
654
|
+
} else {
|
|
655
|
+
enhancedImageResultItems = [NSNull null];
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
NSDictionary *dictionary = @{@"originalImageHashId":self.originalImageHashId,
|
|
659
|
+
@"detectedQuadResultItems":detectedQuadResultItems,
|
|
660
|
+
@"deskewedImageResultItems":deskewedImageResultItems,
|
|
661
|
+
@"enhancedImageResultItems":enhancedImageResultItems,
|
|
662
|
+
@"rotationTransformMatrix":CGAffineTransformToArray(self.rotationTransformMatrix),
|
|
663
|
+
@"errorCode":@(self.errorCode),
|
|
664
|
+
@"errorMessage":self.errorMessage ? self.errorMessage : [NSNull null]
|
|
665
|
+
};
|
|
666
|
+
return dictionary;
|
|
667
|
+
} else {
|
|
668
|
+
return [NSNull null];
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
@end
|
|
673
|
+
|
|
674
|
+
@implementation DSRecognizedTextLinesResult (Json)
|
|
675
|
+
|
|
676
|
+
- (NSObject *)toJson {
|
|
677
|
+
if (self) {
|
|
678
|
+
id items;
|
|
679
|
+
if (self.items.count > 0) {
|
|
680
|
+
NSMutableArray *array = [NSMutableArray array];
|
|
681
|
+
for (DSTextLineResultItem *item in self.items) {
|
|
682
|
+
NSDictionary *obj = [item toJson];
|
|
683
|
+
if (obj) {
|
|
684
|
+
[array addObject:obj];
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
items = [array copy];
|
|
688
|
+
} else {
|
|
689
|
+
items = [NSNull null];
|
|
690
|
+
}
|
|
691
|
+
NSDictionary *dictionary = @{@"originalImageHashId":self.originalImageHashId,
|
|
692
|
+
@"items":items,
|
|
693
|
+
@"rotationTransformMatrix":CGAffineTransformToArray(self.rotationTransformMatrix),
|
|
694
|
+
@"errorCode":@(self.errorCode),
|
|
695
|
+
@"errorMessage":self.errorMessage ? self.errorMessage : [NSNull null]
|
|
696
|
+
};
|
|
697
|
+
return dictionary;
|
|
698
|
+
} else {
|
|
699
|
+
return [NSNull null];
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
@end
|
|
704
|
+
|
|
705
|
+
@implementation DSParsedResult (Json)
|
|
706
|
+
|
|
707
|
+
- (NSObject *)toJson {
|
|
708
|
+
if (self) {
|
|
709
|
+
id items;
|
|
710
|
+
if (self.items.count > 0) {
|
|
711
|
+
NSMutableArray *array = [NSMutableArray array];
|
|
712
|
+
for (DSParsedResultItem *item in self.items) {
|
|
713
|
+
NSDictionary *obj = [item toJson];
|
|
714
|
+
if (obj) {
|
|
715
|
+
[array addObject:obj];
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
items = [array copy];
|
|
719
|
+
} else {
|
|
720
|
+
items = [NSNull null];
|
|
721
|
+
}
|
|
722
|
+
NSDictionary *dictionary = @{@"originalImageHashId":self.originalImageHashId,
|
|
723
|
+
@"items":items,
|
|
724
|
+
@"errorCode":@(self.errorCode),
|
|
725
|
+
@"errorMessage":self.errorMessage ? self.errorMessage : [NSNull null]
|
|
726
|
+
};
|
|
727
|
+
return dictionary;
|
|
728
|
+
} else {
|
|
729
|
+
return [NSNull null];
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
@end
|