dynamsoft-capture-vision-react-native 3.4.1200 → 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 +5 -5
- package/README.md +62 -66
- 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,108 +1,108 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright © Dynamsoft Corporation. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
#import "RNDynamsoftCameraView.h"
|
|
6
|
-
#import <DynamsoftCaptureVisionBundle/DynamsoftCaptureVisionBundle.h>
|
|
7
|
-
|
|
8
|
-
@interface RNDynamsoftCameraView ()
|
|
9
|
-
|
|
10
|
-
@end
|
|
11
|
-
|
|
12
|
-
@implementation RNDynamsoftCameraView
|
|
13
|
-
|
|
14
|
-
- (instancetype)init
|
|
15
|
-
{
|
|
16
|
-
self = [super init];
|
|
17
|
-
if (self) {
|
|
18
|
-
_cameraView = [[DSCameraView alloc] init];
|
|
19
|
-
[self addSubview:_cameraView];
|
|
20
|
-
}
|
|
21
|
-
return self;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
- (void)layoutSubviews {
|
|
25
|
-
[super layoutSubviews];
|
|
26
|
-
self.cameraView.frame = self.bounds;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
- (void)setVisibleLayerIds:(NSArray<NSNumber *> *)visibleLayerIds {
|
|
30
|
-
_visibleLayerIds = visibleLayerIds;
|
|
31
|
-
NSArray<NSNumber *> *layerArray = @[@(DSDrawingLayerIdDBR), @(DSDrawingLayerIdDDN), @(DSDrawingLayerIdDLR)];
|
|
32
|
-
for (NSNumber *layerId in layerArray) {
|
|
33
|
-
DSDrawingLayer *layer = [self.cameraView getDrawingLayer:layerId.unsignedIntegerValue];
|
|
34
|
-
if ([visibleLayerIds containsObject:layerId]) {
|
|
35
|
-
layer.visible = true;
|
|
36
|
-
} else {
|
|
37
|
-
layer.visible = false;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
- (void)setScanRegionMaskVisible:(BOOL)scanRegionMaskVisible {
|
|
43
|
-
_scanRegionMaskVisible = scanRegionMaskVisible;
|
|
44
|
-
self.cameraView.scanRegionMaskVisible = scanRegionMaskVisible;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
- (void)setScanLaserVisible:(BOOL)scanLaserVisible {
|
|
48
|
-
_scanLaserVisible = scanLaserVisible;
|
|
49
|
-
self.cameraView.scanLaserVisible = scanLaserVisible;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
- (void)setTorchButton:(NSDictionary *)torchButton {
|
|
53
|
-
if (torchButton != nil) {
|
|
54
|
-
_torchButton = torchButton;
|
|
55
|
-
NSDictionary *location = [torchButton valueForKey:@"location"];
|
|
56
|
-
NSNumber *visible = [torchButton valueForKey:@"visible"];
|
|
57
|
-
NSString *torchOnImageBase64 = [torchButton valueForKey:@"torchOnImageBase64"];
|
|
58
|
-
NSString *torchOffImageBase64 = [torchButton valueForKey:@"torchOffImageBase64"];
|
|
59
|
-
if (location != nil) {
|
|
60
|
-
NSNumber *x = [location valueForKey:@"x"];
|
|
61
|
-
NSNumber *y = [location valueForKey:@"y"];
|
|
62
|
-
NSNumber *width = [location valueForKey:@"width"];
|
|
63
|
-
NSNumber *height = [location valueForKey:@"height"];
|
|
64
|
-
CGRect rect = CGRectMake(x.floatValue, y.floatValue, width.floatValue, height.floatValue);
|
|
65
|
-
UIImage *torchOnImage, *torchOffImage;
|
|
66
|
-
if ((torchOnImageBase64 != nil) && (torchOffImageBase64 != nil)) {
|
|
67
|
-
torchOnImage = [UIImage imageWithData: [[NSData alloc]initWithBase64EncodedString:torchOnImageBase64 options:(NSDataBase64DecodingIgnoreUnknownCharacters)]];
|
|
68
|
-
torchOffImage = [UIImage imageWithData: [[NSData alloc]initWithBase64EncodedString:torchOffImageBase64 options:(NSDataBase64DecodingIgnoreUnknownCharacters)]];
|
|
69
|
-
}
|
|
70
|
-
[self.cameraView setTorchButtonWithFrame:rect torchOnImage:torchOnImage torchOffImage:torchOffImage];
|
|
71
|
-
}
|
|
72
|
-
if (visible != nil) {
|
|
73
|
-
self.cameraView.torchButtonVisible = visible.boolValue;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
- (void)setTorchButtonVisible:(BOOL)torchButtonVisible {
|
|
79
|
-
_torchButtonVisible = torchButtonVisible;
|
|
80
|
-
self.cameraView.torchButtonVisible = torchButtonVisible;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
- (void)setCameraToggleButton:(NSDictionary *)cameraToggleButton {
|
|
84
|
-
if (cameraToggleButton != nil) {
|
|
85
|
-
_cameraToggleButton = cameraToggleButton;
|
|
86
|
-
NSDictionary *location = [cameraToggleButton valueForKey:@"location"];
|
|
87
|
-
NSString *cameraToggleImageBase64 = [cameraToggleButton valueForKey:@"cameraToggleImageBase64"];
|
|
88
|
-
if (location != nil) {
|
|
89
|
-
NSNumber *x = [location valueForKey:@"x"];
|
|
90
|
-
NSNumber *y = [location valueForKey:@"y"];
|
|
91
|
-
NSNumber *width = [location valueForKey:@"width"];
|
|
92
|
-
NSNumber *height = [location valueForKey:@"height"];
|
|
93
|
-
CGRect rect = CGRectMake(x.floatValue, y.floatValue, width.floatValue, height.floatValue);
|
|
94
|
-
UIImage *image;
|
|
95
|
-
if (cameraToggleImageBase64 != nil) {
|
|
96
|
-
image = [UIImage imageWithData: [[NSData alloc]initWithBase64EncodedString:cameraToggleImageBase64 options:(NSDataBase64DecodingIgnoreUnknownCharacters)]];
|
|
97
|
-
}
|
|
98
|
-
[self.cameraView setCameraToggleButtonWithFrame:rect cameraToggleImage:image];
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
- (void)setCameraToggleButtonVisible:(BOOL)cameraToggleButtonVisible {
|
|
104
|
-
_cameraToggleButtonVisible = cameraToggleButtonVisible;
|
|
105
|
-
self.cameraView.cameraToggleButtonVisible = cameraToggleButtonVisible;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
@end
|
|
1
|
+
/*
|
|
2
|
+
* Copyright © Dynamsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
#import "RNDynamsoftCameraView.h"
|
|
6
|
+
#import <DynamsoftCaptureVisionBundle/DynamsoftCaptureVisionBundle.h>
|
|
7
|
+
|
|
8
|
+
@interface RNDynamsoftCameraView ()
|
|
9
|
+
|
|
10
|
+
@end
|
|
11
|
+
|
|
12
|
+
@implementation RNDynamsoftCameraView
|
|
13
|
+
|
|
14
|
+
- (instancetype)init
|
|
15
|
+
{
|
|
16
|
+
self = [super init];
|
|
17
|
+
if (self) {
|
|
18
|
+
_cameraView = [[DSCameraView alloc] init];
|
|
19
|
+
[self addSubview:_cameraView];
|
|
20
|
+
}
|
|
21
|
+
return self;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
- (void)layoutSubviews {
|
|
25
|
+
[super layoutSubviews];
|
|
26
|
+
self.cameraView.frame = self.bounds;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
- (void)setVisibleLayerIds:(NSArray<NSNumber *> *)visibleLayerIds {
|
|
30
|
+
_visibleLayerIds = visibleLayerIds;
|
|
31
|
+
NSArray<NSNumber *> *layerArray = @[@(DSDrawingLayerIdDBR), @(DSDrawingLayerIdDDN), @(DSDrawingLayerIdDLR)];
|
|
32
|
+
for (NSNumber *layerId in layerArray) {
|
|
33
|
+
DSDrawingLayer *layer = [self.cameraView getDrawingLayer:layerId.unsignedIntegerValue];
|
|
34
|
+
if ([visibleLayerIds containsObject:layerId]) {
|
|
35
|
+
layer.visible = true;
|
|
36
|
+
} else {
|
|
37
|
+
layer.visible = false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
- (void)setScanRegionMaskVisible:(BOOL)scanRegionMaskVisible {
|
|
43
|
+
_scanRegionMaskVisible = scanRegionMaskVisible;
|
|
44
|
+
self.cameraView.scanRegionMaskVisible = scanRegionMaskVisible;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
- (void)setScanLaserVisible:(BOOL)scanLaserVisible {
|
|
48
|
+
_scanLaserVisible = scanLaserVisible;
|
|
49
|
+
self.cameraView.scanLaserVisible = scanLaserVisible;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
- (void)setTorchButton:(NSDictionary *)torchButton {
|
|
53
|
+
if (torchButton != nil) {
|
|
54
|
+
_torchButton = torchButton;
|
|
55
|
+
NSDictionary *location = [torchButton valueForKey:@"location"];
|
|
56
|
+
NSNumber *visible = [torchButton valueForKey:@"visible"];
|
|
57
|
+
NSString *torchOnImageBase64 = [torchButton valueForKey:@"torchOnImageBase64"];
|
|
58
|
+
NSString *torchOffImageBase64 = [torchButton valueForKey:@"torchOffImageBase64"];
|
|
59
|
+
if (location != nil) {
|
|
60
|
+
NSNumber *x = [location valueForKey:@"x"];
|
|
61
|
+
NSNumber *y = [location valueForKey:@"y"];
|
|
62
|
+
NSNumber *width = [location valueForKey:@"width"];
|
|
63
|
+
NSNumber *height = [location valueForKey:@"height"];
|
|
64
|
+
CGRect rect = CGRectMake(x.floatValue, y.floatValue, width.floatValue, height.floatValue);
|
|
65
|
+
UIImage *torchOnImage, *torchOffImage;
|
|
66
|
+
if ((torchOnImageBase64 != nil) && (torchOffImageBase64 != nil)) {
|
|
67
|
+
torchOnImage = [UIImage imageWithData: [[NSData alloc]initWithBase64EncodedString:torchOnImageBase64 options:(NSDataBase64DecodingIgnoreUnknownCharacters)]];
|
|
68
|
+
torchOffImage = [UIImage imageWithData: [[NSData alloc]initWithBase64EncodedString:torchOffImageBase64 options:(NSDataBase64DecodingIgnoreUnknownCharacters)]];
|
|
69
|
+
}
|
|
70
|
+
[self.cameraView setTorchButtonWithFrame:rect torchOnImage:torchOnImage torchOffImage:torchOffImage];
|
|
71
|
+
}
|
|
72
|
+
if (visible != nil) {
|
|
73
|
+
self.cameraView.torchButtonVisible = visible.boolValue;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
- (void)setTorchButtonVisible:(BOOL)torchButtonVisible {
|
|
79
|
+
_torchButtonVisible = torchButtonVisible;
|
|
80
|
+
self.cameraView.torchButtonVisible = torchButtonVisible;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
- (void)setCameraToggleButton:(NSDictionary *)cameraToggleButton {
|
|
84
|
+
if (cameraToggleButton != nil) {
|
|
85
|
+
_cameraToggleButton = cameraToggleButton;
|
|
86
|
+
NSDictionary *location = [cameraToggleButton valueForKey:@"location"];
|
|
87
|
+
NSString *cameraToggleImageBase64 = [cameraToggleButton valueForKey:@"cameraToggleImageBase64"];
|
|
88
|
+
if (location != nil) {
|
|
89
|
+
NSNumber *x = [location valueForKey:@"x"];
|
|
90
|
+
NSNumber *y = [location valueForKey:@"y"];
|
|
91
|
+
NSNumber *width = [location valueForKey:@"width"];
|
|
92
|
+
NSNumber *height = [location valueForKey:@"height"];
|
|
93
|
+
CGRect rect = CGRectMake(x.floatValue, y.floatValue, width.floatValue, height.floatValue);
|
|
94
|
+
UIImage *image;
|
|
95
|
+
if (cameraToggleImageBase64 != nil) {
|
|
96
|
+
image = [UIImage imageWithData: [[NSData alloc]initWithBase64EncodedString:cameraToggleImageBase64 options:(NSDataBase64DecodingIgnoreUnknownCharacters)]];
|
|
97
|
+
}
|
|
98
|
+
[self.cameraView setCameraToggleButtonWithFrame:rect cameraToggleImage:image];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
- (void)setCameraToggleButtonVisible:(BOOL)cameraToggleButtonVisible {
|
|
104
|
+
_cameraToggleButtonVisible = cameraToggleButtonVisible;
|
|
105
|
+
self.cameraView.cameraToggleButtonVisible = cameraToggleButtonVisible;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
@end
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright © Dynamsoft Corporation. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
#import <React/RCTViewManager.h>
|
|
6
|
-
#import <React/RCTBridgeModule.h>
|
|
7
|
-
|
|
8
|
-
NS_ASSUME_NONNULL_BEGIN
|
|
9
|
-
|
|
10
|
-
@interface RNDynamsoftCameraViewManager : RCTViewManager
|
|
11
|
-
|
|
12
|
-
@end
|
|
13
|
-
|
|
14
|
-
NS_ASSUME_NONNULL_END
|
|
1
|
+
/*
|
|
2
|
+
* Copyright © Dynamsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
#import <React/RCTViewManager.h>
|
|
6
|
+
#import <React/RCTBridgeModule.h>
|
|
7
|
+
|
|
8
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
9
|
+
|
|
10
|
+
@interface RNDynamsoftCameraViewManager : RCTViewManager
|
|
11
|
+
|
|
12
|
+
@end
|
|
13
|
+
|
|
14
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -1,195 +1,195 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright © Dynamsoft Corporation. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
#import "RNDynamsoftCameraViewManager.h"
|
|
6
|
-
#import "RNDynamsoftCameraView.h"
|
|
7
|
-
#import <DynamsoftCaptureVisionBundle/DynamsoftCaptureVisionBundle.h>
|
|
8
|
-
#import <React/RCTUIManager.h>
|
|
9
|
-
#import "RNDynamsoftImageSourceAdapter.h"
|
|
10
|
-
|
|
11
|
-
@interface RNDynamsoftCameraViewManager ()
|
|
12
|
-
|
|
13
|
-
@property (nonatomic, strong) DSCameraEnhancer *dce;
|
|
14
|
-
|
|
15
|
-
@end
|
|
16
|
-
|
|
17
|
-
@implementation RNDynamsoftCameraViewManager {
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
RCT_EXPORT_MODULE(DynamsoftCameraView)
|
|
22
|
-
|
|
23
|
-
- (instancetype)init
|
|
24
|
-
{
|
|
25
|
-
self = [super init];
|
|
26
|
-
if (self) {
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
return self;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
- (UIView *)view {
|
|
33
|
-
return [[RNDynamsoftCameraView alloc] init];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
RCT_EXPORT_VIEW_PROPERTY(visibleLayerIds, NSArray)
|
|
37
|
-
RCT_EXPORT_VIEW_PROPERTY(scanRegionMaskVisible, BOOL)
|
|
38
|
-
RCT_EXPORT_VIEW_PROPERTY(scanLaserVisible, BOOL)
|
|
39
|
-
RCT_EXPORT_VIEW_PROPERTY(torchButton, NSDictionary)
|
|
40
|
-
RCT_EXPORT_VIEW_PROPERTY(torchButtonVisible, BOOL)
|
|
41
|
-
RCT_EXPORT_VIEW_PROPERTY(cameraToggleButton, NSDictionary)
|
|
42
|
-
RCT_EXPORT_VIEW_PROPERTY(cameraToggleButtonVisible, BOOL)
|
|
43
|
-
|
|
44
|
-
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(createInstance) {
|
|
45
|
-
RNDynamsoftImageSourceAdapter *rnAdapter = [self.bridge moduleForClass:[RNDynamsoftImageSourceAdapter class]];
|
|
46
|
-
if (self.dce) {
|
|
47
|
-
[rnAdapter.isaDictionary removeObjectForKey:[NSNumber numberWithUnsignedInteger:self.dce.hash].stringValue];
|
|
48
|
-
}
|
|
49
|
-
self.dce = [[DSCameraEnhancer alloc] init];
|
|
50
|
-
NSString *key = [NSNumber numberWithUnsignedInteger:self.dce.hash].stringValue;
|
|
51
|
-
[rnAdapter.isaDictionary setValue:self.dce forKey:key];
|
|
52
|
-
return key;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(destroyInstance:(NSString *)key) {
|
|
56
|
-
self.dce = nil;
|
|
57
|
-
RNDynamsoftImageSourceAdapter *rnAdapter = [self.bridge moduleForClass:[RNDynamsoftImageSourceAdapter class]];
|
|
58
|
-
[rnAdapter.isaDictionary removeObjectForKey:key];
|
|
59
|
-
return @true;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
RCT_EXPORT_METHOD(open) {
|
|
63
|
-
[self.dce open];
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
RCT_EXPORT_METHOD(close) {
|
|
67
|
-
[self.dce close];
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
RCT_EXPORT_METHOD(setCameraView:(nonnull NSNumber *)tag) {
|
|
71
|
-
if (tag.integerValue != 0) {
|
|
72
|
-
[self trySetCameraViewWithTag:tag attempt:1];
|
|
73
|
-
} else {
|
|
74
|
-
self.dce.cameraView = nil;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
- (void)trySetCameraViewWithTag:(nonnull NSNumber *)tag attempt:(NSInteger)attempt {
|
|
79
|
-
const NSInteger maxAttempts = 10;
|
|
80
|
-
const NSTimeInterval retryDelay = 0.1; // 100ms
|
|
81
|
-
|
|
82
|
-
[self.bridge.uiManager addUIBlock:
|
|
83
|
-
^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
84
|
-
id view = viewRegistry[tag];
|
|
85
|
-
if (!view || ![view isKindOfClass:[RNDynamsoftCameraView class]]) {
|
|
86
|
-
if (attempt < maxAttempts) {
|
|
87
|
-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(retryDelay * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
88
|
-
[self trySetCameraViewWithTag:tag attempt:attempt + 1];
|
|
89
|
-
});
|
|
90
|
-
} else {
|
|
91
|
-
RCTLogError(@"Cannot find RNDynamsoftCameraView with tag #%@ after %ld attempts", tag, (long)attempt);
|
|
92
|
-
}
|
|
93
|
-
} else {
|
|
94
|
-
self.dce.cameraView = ((RNDynamsoftCameraView *)view).cameraView;
|
|
95
|
-
}
|
|
96
|
-
}];
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
RCT_EXPORT_METHOD(selectCamera:(NSInteger)position) {
|
|
100
|
-
[self.dce selectCameraWithPosition:position completion:nil];
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
RCT_EXPORT_METHOD(getCameraPosition:(RCTPromiseResolveBlock)resolve
|
|
104
|
-
rejecter:(RCTPromiseRejectBlock)reject)
|
|
105
|
-
{
|
|
106
|
-
resolve(@([self.dce getCameraPosition]));
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
RCT_EXPORT_METHOD(setFocus:(CGFloat)x y:(CGFloat)y mode:(NSInteger)mode) {
|
|
110
|
-
[self.dce setFocus:CGPointMake(x, y) focusMode:mode];
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
RCT_EXPORT_METHOD(getFocusMode:(RCTPromiseResolveBlock)resolve
|
|
114
|
-
rejecter:(RCTPromiseRejectBlock)reject)
|
|
115
|
-
{
|
|
116
|
-
resolve(@([self.dce getFocusMode]));
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
RCT_EXPORT_METHOD(setZoomFactor:(CGFloat)factor) {
|
|
120
|
-
[self.dce setZoomFactor:factor];
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
RCT_EXPORT_METHOD(getZoomFactor:(RCTPromiseResolveBlock)resolve
|
|
124
|
-
rejecter:(RCTPromiseRejectBlock)reject)
|
|
125
|
-
{
|
|
126
|
-
resolve(@([self.dce getZoomFactor]));
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
RCT_EXPORT_METHOD(enableEnhancedFeatures:(NSInteger)features) {
|
|
130
|
-
[self.dce enableEnhancedFeatures:features];
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
RCT_EXPORT_METHOD(disableEnhancedFeatures:(NSInteger)features) {
|
|
134
|
-
[self.dce disableEnhancedFeatures:features];
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
RCT_EXPORT_METHOD(setScanRegion:(NSDictionary *)region
|
|
138
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
139
|
-
rejecter: (RCTPromiseRejectBlock)reject)
|
|
140
|
-
{
|
|
141
|
-
if (region) {
|
|
142
|
-
NSNumber *top = [region valueForKey:@"top"];
|
|
143
|
-
NSNumber *left = [region valueForKey:@"left"];
|
|
144
|
-
NSNumber *right = [region valueForKey:@"right"];
|
|
145
|
-
NSNumber *bottom = [region valueForKey:@"bottom"];
|
|
146
|
-
NSNumber *measuredInPercentage = [region valueForKey:@"measuredInPercentage"];
|
|
147
|
-
if (top && left && right && bottom && measuredInPercentage) {
|
|
148
|
-
DSRect *rect = [[DSRect alloc] init];
|
|
149
|
-
rect.top = top.floatValue;
|
|
150
|
-
rect.left = left.floatValue;
|
|
151
|
-
rect.right = right.floatValue;
|
|
152
|
-
rect.bottom = bottom.floatValue;
|
|
153
|
-
rect.measuredInPercentage = measuredInPercentage.boolValue;
|
|
154
|
-
NSError *error;
|
|
155
|
-
[self.dce setScanRegion:rect error:&error];
|
|
156
|
-
if (error) {
|
|
157
|
-
NSString *code = [NSString stringWithFormat:@"%ld",(long)error.code];
|
|
158
|
-
reject(code, error.localizedDescription, error);
|
|
159
|
-
}
|
|
160
|
-
resolve(@(true));
|
|
161
|
-
}
|
|
162
|
-
} else {
|
|
163
|
-
[self.dce setScanRegion:nil error:nil];
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
RCT_EXPORT_METHOD(getScanRegion:(RCTPromiseResolveBlock)resolve
|
|
168
|
-
rejecter: (RCTPromiseRejectBlock)reject)
|
|
169
|
-
{
|
|
170
|
-
DSRect *rect = [self.dce getScanRegion];
|
|
171
|
-
NSDictionary *dic = @{@"top" : @(rect.top), @"left" : @(rect.left), @"right" : @(rect.right), @"bottom" : @(rect.bottom), @"measuredInPercentage" : @(rect.measuredInPercentage)};
|
|
172
|
-
resolve(dic);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
RCT_EXPORT_METHOD(turnOnTorch) {
|
|
176
|
-
[self.dce turnOnTorch];
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
RCT_EXPORT_METHOD(turnOffTorch) {
|
|
180
|
-
[self.dce turnOffTorch];
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
RCT_EXPORT_METHOD(beep) {
|
|
184
|
-
[DSFeedback beep];
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
RCT_EXPORT_METHOD(vibrate) {
|
|
188
|
-
[DSFeedback vibrate];
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
RCT_EXPORT_METHOD(setResolution:(NSInteger)resolution) {
|
|
192
|
-
[self.dce setResolution:resolution];
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
@end
|
|
1
|
+
/*
|
|
2
|
+
* Copyright © Dynamsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
#import "RNDynamsoftCameraViewManager.h"
|
|
6
|
+
#import "RNDynamsoftCameraView.h"
|
|
7
|
+
#import <DynamsoftCaptureVisionBundle/DynamsoftCaptureVisionBundle.h>
|
|
8
|
+
#import <React/RCTUIManager.h>
|
|
9
|
+
#import "RNDynamsoftImageSourceAdapter.h"
|
|
10
|
+
|
|
11
|
+
@interface RNDynamsoftCameraViewManager ()
|
|
12
|
+
|
|
13
|
+
@property (nonatomic, strong) DSCameraEnhancer *dce;
|
|
14
|
+
|
|
15
|
+
@end
|
|
16
|
+
|
|
17
|
+
@implementation RNDynamsoftCameraViewManager {
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
RCT_EXPORT_MODULE(DynamsoftCameraView)
|
|
22
|
+
|
|
23
|
+
- (instancetype)init
|
|
24
|
+
{
|
|
25
|
+
self = [super init];
|
|
26
|
+
if (self) {
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
return self;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
- (UIView *)view {
|
|
33
|
+
return [[RNDynamsoftCameraView alloc] init];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
RCT_EXPORT_VIEW_PROPERTY(visibleLayerIds, NSArray)
|
|
37
|
+
RCT_EXPORT_VIEW_PROPERTY(scanRegionMaskVisible, BOOL)
|
|
38
|
+
RCT_EXPORT_VIEW_PROPERTY(scanLaserVisible, BOOL)
|
|
39
|
+
RCT_EXPORT_VIEW_PROPERTY(torchButton, NSDictionary)
|
|
40
|
+
RCT_EXPORT_VIEW_PROPERTY(torchButtonVisible, BOOL)
|
|
41
|
+
RCT_EXPORT_VIEW_PROPERTY(cameraToggleButton, NSDictionary)
|
|
42
|
+
RCT_EXPORT_VIEW_PROPERTY(cameraToggleButtonVisible, BOOL)
|
|
43
|
+
|
|
44
|
+
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(createInstance) {
|
|
45
|
+
RNDynamsoftImageSourceAdapter *rnAdapter = [self.bridge moduleForClass:[RNDynamsoftImageSourceAdapter class]];
|
|
46
|
+
if (self.dce) {
|
|
47
|
+
[rnAdapter.isaDictionary removeObjectForKey:[NSNumber numberWithUnsignedInteger:self.dce.hash].stringValue];
|
|
48
|
+
}
|
|
49
|
+
self.dce = [[DSCameraEnhancer alloc] init];
|
|
50
|
+
NSString *key = [NSNumber numberWithUnsignedInteger:self.dce.hash].stringValue;
|
|
51
|
+
[rnAdapter.isaDictionary setValue:self.dce forKey:key];
|
|
52
|
+
return key;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(destroyInstance:(NSString *)key) {
|
|
56
|
+
self.dce = nil;
|
|
57
|
+
RNDynamsoftImageSourceAdapter *rnAdapter = [self.bridge moduleForClass:[RNDynamsoftImageSourceAdapter class]];
|
|
58
|
+
[rnAdapter.isaDictionary removeObjectForKey:key];
|
|
59
|
+
return @true;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
RCT_EXPORT_METHOD(open) {
|
|
63
|
+
[self.dce open];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
RCT_EXPORT_METHOD(close) {
|
|
67
|
+
[self.dce close];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
RCT_EXPORT_METHOD(setCameraView:(nonnull NSNumber *)tag) {
|
|
71
|
+
if (tag.integerValue != 0) {
|
|
72
|
+
[self trySetCameraViewWithTag:tag attempt:1];
|
|
73
|
+
} else {
|
|
74
|
+
self.dce.cameraView = nil;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
- (void)trySetCameraViewWithTag:(nonnull NSNumber *)tag attempt:(NSInteger)attempt {
|
|
79
|
+
const NSInteger maxAttempts = 10;
|
|
80
|
+
const NSTimeInterval retryDelay = 0.1; // 100ms
|
|
81
|
+
|
|
82
|
+
[self.bridge.uiManager addUIBlock:
|
|
83
|
+
^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
84
|
+
id view = viewRegistry[tag];
|
|
85
|
+
if (!view || ![view isKindOfClass:[RNDynamsoftCameraView class]]) {
|
|
86
|
+
if (attempt < maxAttempts) {
|
|
87
|
+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(retryDelay * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
88
|
+
[self trySetCameraViewWithTag:tag attempt:attempt + 1];
|
|
89
|
+
});
|
|
90
|
+
} else {
|
|
91
|
+
RCTLogError(@"Cannot find RNDynamsoftCameraView with tag #%@ after %ld attempts", tag, (long)attempt);
|
|
92
|
+
}
|
|
93
|
+
} else {
|
|
94
|
+
self.dce.cameraView = ((RNDynamsoftCameraView *)view).cameraView;
|
|
95
|
+
}
|
|
96
|
+
}];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
RCT_EXPORT_METHOD(selectCamera:(NSInteger)position) {
|
|
100
|
+
[self.dce selectCameraWithPosition:position completion:nil];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
RCT_EXPORT_METHOD(getCameraPosition:(RCTPromiseResolveBlock)resolve
|
|
104
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
105
|
+
{
|
|
106
|
+
resolve(@([self.dce getCameraPosition]));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
RCT_EXPORT_METHOD(setFocus:(CGFloat)x y:(CGFloat)y mode:(NSInteger)mode) {
|
|
110
|
+
[self.dce setFocus:CGPointMake(x, y) focusMode:mode];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
RCT_EXPORT_METHOD(getFocusMode:(RCTPromiseResolveBlock)resolve
|
|
114
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
115
|
+
{
|
|
116
|
+
resolve(@([self.dce getFocusMode]));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
RCT_EXPORT_METHOD(setZoomFactor:(CGFloat)factor) {
|
|
120
|
+
[self.dce setZoomFactor:factor];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
RCT_EXPORT_METHOD(getZoomFactor:(RCTPromiseResolveBlock)resolve
|
|
124
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
125
|
+
{
|
|
126
|
+
resolve(@([self.dce getZoomFactor]));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
RCT_EXPORT_METHOD(enableEnhancedFeatures:(NSInteger)features) {
|
|
130
|
+
[self.dce enableEnhancedFeatures:features];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
RCT_EXPORT_METHOD(disableEnhancedFeatures:(NSInteger)features) {
|
|
134
|
+
[self.dce disableEnhancedFeatures:features];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
RCT_EXPORT_METHOD(setScanRegion:(NSDictionary *)region
|
|
138
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
139
|
+
rejecter: (RCTPromiseRejectBlock)reject)
|
|
140
|
+
{
|
|
141
|
+
if (region) {
|
|
142
|
+
NSNumber *top = [region valueForKey:@"top"];
|
|
143
|
+
NSNumber *left = [region valueForKey:@"left"];
|
|
144
|
+
NSNumber *right = [region valueForKey:@"right"];
|
|
145
|
+
NSNumber *bottom = [region valueForKey:@"bottom"];
|
|
146
|
+
NSNumber *measuredInPercentage = [region valueForKey:@"measuredInPercentage"];
|
|
147
|
+
if (top && left && right && bottom && measuredInPercentage) {
|
|
148
|
+
DSRect *rect = [[DSRect alloc] init];
|
|
149
|
+
rect.top = top.floatValue;
|
|
150
|
+
rect.left = left.floatValue;
|
|
151
|
+
rect.right = right.floatValue;
|
|
152
|
+
rect.bottom = bottom.floatValue;
|
|
153
|
+
rect.measuredInPercentage = measuredInPercentage.boolValue;
|
|
154
|
+
NSError *error;
|
|
155
|
+
[self.dce setScanRegion:rect error:&error];
|
|
156
|
+
if (error) {
|
|
157
|
+
NSString *code = [NSString stringWithFormat:@"%ld",(long)error.code];
|
|
158
|
+
reject(code, error.localizedDescription, error);
|
|
159
|
+
}
|
|
160
|
+
resolve(@(true));
|
|
161
|
+
}
|
|
162
|
+
} else {
|
|
163
|
+
[self.dce setScanRegion:nil error:nil];
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
RCT_EXPORT_METHOD(getScanRegion:(RCTPromiseResolveBlock)resolve
|
|
168
|
+
rejecter: (RCTPromiseRejectBlock)reject)
|
|
169
|
+
{
|
|
170
|
+
DSRect *rect = [self.dce getScanRegion];
|
|
171
|
+
NSDictionary *dic = @{@"top" : @(rect.top), @"left" : @(rect.left), @"right" : @(rect.right), @"bottom" : @(rect.bottom), @"measuredInPercentage" : @(rect.measuredInPercentage)};
|
|
172
|
+
resolve(dic);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
RCT_EXPORT_METHOD(turnOnTorch) {
|
|
176
|
+
[self.dce turnOnTorch];
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
RCT_EXPORT_METHOD(turnOffTorch) {
|
|
180
|
+
[self.dce turnOffTorch];
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
RCT_EXPORT_METHOD(beep) {
|
|
184
|
+
[DSFeedback beep];
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
RCT_EXPORT_METHOD(vibrate) {
|
|
188
|
+
[DSFeedback vibrate];
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
RCT_EXPORT_METHOD(setResolution:(NSInteger)resolution) {
|
|
192
|
+
[self.dce setResolution:resolution];
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
@end
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright © Dynamsoft Corporation. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
#import <React/RCTBridgeModule.h>
|
|
6
|
-
#import <React/RCTEventEmitter.h>
|
|
7
|
-
|
|
8
|
-
NS_ASSUME_NONNULL_BEGIN
|
|
9
|
-
|
|
10
|
-
@class DSMultiFrameResultCrossFilter;
|
|
11
|
-
|
|
12
|
-
@interface RNDynamsoftCaptureVisionRouter : RCTEventEmitter <RCTBridgeModule>
|
|
13
|
-
|
|
14
|
-
@property (nonatomic, strong) NSMutableDictionary<NSString *, DSMultiFrameResultCrossFilter *> *filterDictionary;
|
|
15
|
-
|
|
16
|
-
@end
|
|
17
|
-
|
|
18
|
-
NS_ASSUME_NONNULL_END
|
|
1
|
+
/*
|
|
2
|
+
* Copyright © Dynamsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
#import <React/RCTBridgeModule.h>
|
|
6
|
+
#import <React/RCTEventEmitter.h>
|
|
7
|
+
|
|
8
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
9
|
+
|
|
10
|
+
@class DSMultiFrameResultCrossFilter;
|
|
11
|
+
|
|
12
|
+
@interface RNDynamsoftCaptureVisionRouter : RCTEventEmitter <RCTBridgeModule>
|
|
13
|
+
|
|
14
|
+
@property (nonatomic, strong) NSMutableDictionary<NSString *, DSMultiFrameResultCrossFilter *> *filterDictionary;
|
|
15
|
+
|
|
16
|
+
@end
|
|
17
|
+
|
|
18
|
+
NS_ASSUME_NONNULL_END
|