dynamsoft-capture-vision-react-native 3.0.5201 → 3.2.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/README.md +5 -2
- package/android/build.gradle +4 -6
- package/android/gradle.properties +3 -3
- package/android/src/main/cpp/JsiCore.cpp +1 -1
- package/android/src/main/cpp/JsiDbr.cpp +208 -23
- package/android/src/main/cpp/JsiDcp.cpp +1 -1
- package/android/src/main/cpp/JsiDlr.cpp +10 -1
- package/android/src/main/cpp/JsiUtility.cpp +470 -62
- package/android/src/main/cpp/JsiUtility.h +13 -3
- 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/java/com/dynamsoft/reactnativelib/CVRModule.kt +17 -2
- package/android/src/main/java/com/dynamsoft/reactnativelib/CameraViewManager.kt +13 -1
- package/android/src/main/java/com/dynamsoft/reactnativelib/ImageEditorViewManager.kt +1 -1
- package/android/src/main/java/com/dynamsoft/reactnativelib/{utils → basicutils}/Basic.kt +1 -1
- package/android/src/main/java/com/dynamsoft/reactnativelib/{utils → basicutils}/ForCore.kt +1 -2
- package/android/src/main/java/com/dynamsoft/reactnativelib/{utils → basicutils}/ForCvr.kt +1 -5
- package/android/src/main/java/com/dynamsoft/reactnativelib/{utils → basicutils}/ForDBR.kt +74 -3
- package/android/src/main/java/com/dynamsoft/reactnativelib/{utils → basicutils}/ForDCE.kt +33 -13
- package/android/src/main/java/com/dynamsoft/reactnativelib/{utils → basicutils}/ForDCP.kt +1 -1
- package/android/src/main/java/com/dynamsoft/reactnativelib/{utils → basicutils}/ForDDN.kt +1 -3
- package/android/src/main/java/com/dynamsoft/reactnativelib/{utils → basicutils}/ForDLR.kt +6 -3
- package/android/src/main/java/com/dynamsoft/reactnativelib/{utils → basicutils}/ImageUtil.kt +2 -2
- package/android/src/main/java/com/dynamsoft/reactnativelib/cvr/CaptureVisionRouterModuleImpl.kt +25 -5
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/CameraEnhancerModuleImpl.kt +6 -3
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/CameraViewManagerImpl.kt +15 -3
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/ImageEditorViewManagerImpl.kt +1 -5
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/ImageEditorViewModuleImpl.kt +2 -4
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/RNCameraView.kt +1 -2
- package/android/src/main/java/com/dynamsoft/reactnativelib/utility/ImageManagerModuleImpl.kt +75 -3
- package/android/src/main/java/com/dynamsoft/reactnativelib/utility/MultiCrossFilterModuleImpl.kt +2 -2
- package/dynamsoft-capture-vision-react-native.podspec +1 -1
- package/ios/CPP/ImageDataHostObject.cpp +1 -1
- package/ios/CPP/ImageDataHostObject.hpp +1 -1
- package/ios/CPP/RNDynamsoft+JSI.h +3 -0
- package/ios/CPP/RNDynamsoft+JSI.mm +119 -2
- package/ios/CPP/RNDynamsoft+Json.m +114 -14
- package/ios/CPP/YeetJSIUtils.h +2 -0
- package/ios/CPP/YeetJSIUtils.mm +15 -0
- package/ios/RNDynamsoftCameraView.h +4 -0
- package/ios/RNDynamsoftCameraView.m +25 -0
- package/ios/RNDynamsoftCameraViewManager.m +8 -2
- package/ios/RNDynamsoftCaptureVisionRouter.mm +149 -92
- package/ios/RNDynamsoftImageEditorViewManager.mm +71 -40
- package/ios/RNDynamsoftImageManager.mm +295 -81
- package/ios/RNDynamsoftImageSourceAdapter.mm +100 -65
- package/package.json +1 -1
- package/src/core/EnumGrayscaleEnhancementMode.tsx +1 -0
- package/src/core/EnumGrayscaleTransformationMode.tsx +1 -0
- package/src/core/EnumImageFileFormat.tsx +6 -0
- package/src/core/index.tsx +1 -0
- package/src/cvr/CaptureVisionRouter.tsx +33 -5
- package/src/dbr/BarcodeDetails.tsx +51 -0
- package/src/dbr/BarcodeResultItem.tsx +11 -0
- package/src/dbr/EnumBarcodeFormat.tsx +2 -0
- package/src/dbr/EnumDeblurMode.tsx +1 -0
- package/src/dbr/EnumLocalizationMode.tsx +1 -0
- package/src/dbr/EnumQRCodeErrorCorrectionLevel.tsx +6 -0
- package/src/dbr/index.tsx +2 -0
- package/src/dce/CameraEnhancer.tsx +14 -6
- package/src/dce/CameraView.tsx +10 -2
- package/src/dce/DynamsoftCameraViewNativeComponent.ts +25 -0
- package/src/dce/EnumCameraPosition.tsx +13 -1
- package/src/dce/EnumEnhancedFeatures.tsx +3 -4
- package/src/dce/ImageEditorView.tsx +1 -1
- package/src/dlr/CharacterResult.tsx +4 -1
- package/src/dlr/SimplifiedLabelRecognizerSettings.tsx +2 -0
- package/src/dlr/TextLineResultItem.tsx +5 -0
- package/src/utility/EnumFilterType.tsx +5 -0
- package/src/utility/ImageManager.tsx +227 -9
- package/src/utility/index.tsx +1 -0
package/android/src/main/java/com/dynamsoft/reactnativelib/utility/ImageManagerModuleImpl.kt
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
package com.dynamsoft.reactnativelib.utility
|
|
2
2
|
|
|
3
|
+
import android.graphics.Rect
|
|
4
|
+
import com.dynamsoft.core.basic_structures.DSRect
|
|
5
|
+
import com.dynamsoft.core.basic_structures.EnumImageFileFormat
|
|
3
6
|
import com.dynamsoft.core.basic_structures.ImageData
|
|
4
7
|
import com.dynamsoft.core.basic_structures.Quadrilateral
|
|
8
|
+
import com.dynamsoft.utility.EnumFilterType
|
|
5
9
|
import com.dynamsoft.utility.ImageDrawer
|
|
6
10
|
import com.dynamsoft.utility.ImageIO
|
|
7
11
|
import com.dynamsoft.utility.ImageProcessor
|
|
@@ -30,18 +34,86 @@ class ImageManagerModuleImpl(private val reactContext: ReactApplicationContext)
|
|
|
30
34
|
imageIo.saveToFile(imageData, filePath, overWrite)
|
|
31
35
|
}
|
|
32
36
|
|
|
37
|
+
fun readFromFileCalledInJsi(filePath: String): ImageData? {
|
|
38
|
+
return try {
|
|
39
|
+
imageIo.readFromFile(filePath)
|
|
40
|
+
} catch (_: UtilityException) {
|
|
41
|
+
null
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
fun readFromMemoryCalledInJsi(buffer: ByteArray): ImageData? {
|
|
46
|
+
return try {
|
|
47
|
+
imageIo.readFromMemory(buffer)
|
|
48
|
+
} catch (_: UtilityException) {
|
|
49
|
+
null
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
fun saveToMemoryCalledInJsi(imageData: ImageData, @EnumImageFileFormat format: Int): ByteArray? {
|
|
55
|
+
return try {
|
|
56
|
+
imageIo.saveToMemory(imageData, format)
|
|
57
|
+
} catch (_: UtilityException) {
|
|
58
|
+
null
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
33
62
|
fun drawOnImageCalledInJsi(imageData: ImageData, quads: Array<Quadrilateral>, color: Int, thickness: Int): ImageData {
|
|
34
63
|
return imageDrawer.drawOnImage(imageData, quads, color, thickness)
|
|
35
64
|
}
|
|
36
65
|
|
|
37
|
-
fun cropImageCalledInJsi(imageData: ImageData,
|
|
66
|
+
fun cropImageCalledInJsi(imageData: ImageData, dsRect: DSRect): ImageData? {
|
|
67
|
+
val rect = if (dsRect.measuredInPercentage) {
|
|
68
|
+
Rect(
|
|
69
|
+
(dsRect.left * imageData.width).toInt(),
|
|
70
|
+
(dsRect.top * imageData.height).toInt(),
|
|
71
|
+
(dsRect.right * imageData.width).toInt(),
|
|
72
|
+
(dsRect.bottom * imageData.height).toInt()
|
|
73
|
+
)
|
|
74
|
+
} else {
|
|
75
|
+
Rect(dsRect.left.toInt(), dsRect.top.toInt(), dsRect.right.toInt(), dsRect.bottom.toInt())
|
|
76
|
+
}
|
|
77
|
+
return try {
|
|
78
|
+
imageProcessor.cropImage(imageData, rect)
|
|
79
|
+
} catch (e: UtilityException) {
|
|
80
|
+
null
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
fun cropAndDeskewImageCalledInJsi(imageData: ImageData, quad: Quadrilateral, dstWidth: Int, dstHeight: Int, padding: Int): ImageData? {
|
|
38
85
|
return try {
|
|
39
|
-
imageProcessor.cropAndDeskewImage(imageData, quad)
|
|
86
|
+
imageProcessor.cropAndDeskewImage(imageData, quad, dstWidth, dstHeight, padding)
|
|
40
87
|
} catch (e: UtilityException) {
|
|
41
|
-
null
|
|
88
|
+
null
|
|
42
89
|
}
|
|
43
90
|
}
|
|
44
91
|
|
|
92
|
+
fun adjustBrightnessCalledInJsi(imageData: ImageData, brightness: Int) : ImageData {
|
|
93
|
+
return imageProcessor.adjustBrightness(imageData, brightness)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
fun adjustContrastCalledInJsi(imageData: ImageData, contrast: Int) : ImageData {
|
|
97
|
+
return imageProcessor.adjustContrast(imageData, contrast)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
fun filterImageCalledInJsi(imageData: ImageData, @EnumFilterType filterType: Int) : ImageData {
|
|
101
|
+
return imageProcessor.filterImage(imageData, filterType)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
fun convertToGrayCalledInJsi(imageData: ImageData, r: Float, g: Float, b: Float) : ImageData {
|
|
105
|
+
return imageProcessor.convertToGray(imageData, r, g, b)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
fun convertToBinaryGlobalCalledInJsi(imageData: ImageData, threshold: Int, invert: Boolean): ImageData {
|
|
109
|
+
return imageProcessor.convertToBinaryGlobal(imageData, threshold, invert)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
fun convertToBinaryLocalCalledInJsi(imageData: ImageData, blockSize: Int, compensation: Int, invert: Boolean): ImageData {
|
|
113
|
+
return imageProcessor.convertToBinaryLocal(imageData, blockSize, compensation, invert)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
|
|
45
117
|
|
|
46
118
|
private external fun nativeInstall(jsiPtr: Long)
|
|
47
119
|
|
package/android/src/main/java/com/dynamsoft/reactnativelib/utility/MultiCrossFilterModuleImpl.kt
CHANGED
|
@@ -45,7 +45,7 @@ class MultiCrossFilterModuleImpl(context: ReactApplicationContext) {
|
|
|
45
45
|
|
|
46
46
|
@ReactMethod
|
|
47
47
|
fun enableResultDeduplication(filterId: String, resultItemTypes: Int, enable: Boolean) {
|
|
48
|
-
getMultiCrossFilterById(filterId)?.enableResultDeduplication(resultItemTypes, enable)
|
|
48
|
+
getMultiCrossFilterById(filterId)?.enableResultDeduplication(resultItemTypes, enable)
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
@ReactMethod
|
|
@@ -55,7 +55,7 @@ class MultiCrossFilterModuleImpl(context: ReactApplicationContext) {
|
|
|
55
55
|
|
|
56
56
|
@ReactMethod
|
|
57
57
|
fun setDuplicateForgetTime(filterId: String, resultItemTypes: Int, time: Int) {
|
|
58
|
-
getMultiCrossFilterById(filterId)?.setDuplicateForgetTime(resultItemTypes, time)
|
|
58
|
+
getMultiCrossFilterById(filterId)?.setDuplicateForgetTime(resultItemTypes, time)
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
@ReactMethod
|
|
@@ -17,7 +17,7 @@ Pod::Spec.new do |s|
|
|
|
17
17
|
s.private_header_files = "ios/**/*.h"
|
|
18
18
|
s.requires_arc = true
|
|
19
19
|
|
|
20
|
-
s.dependency "DynamsoftCaptureVisionBundle", ">= 3.
|
|
20
|
+
s.dependency "DynamsoftCaptureVisionBundle", ">= 3.2.3000", "< 4.0"
|
|
21
21
|
|
|
22
22
|
install_modules_dependencies(s)
|
|
23
23
|
end
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
ImageDataHostObject::ImageDataHostObject(int width, int height, int stride, int format, int orientation, uint8_t *buffer, int bufferSize)
|
|
12
12
|
: width(width), height(height), stride(stride), format(format), orientation(orientation), buffer(buffer), bufferSize(bufferSize) {}
|
|
13
13
|
|
|
14
|
-
ImageDataHostObject ImageDataHostObject::getHOFromObject(Runtime &runtime, Object jsObj) {
|
|
14
|
+
ImageDataHostObject ImageDataHostObject::getHOFromObject(Runtime &runtime, Object &jsObj) {
|
|
15
15
|
if (jsObj.isHostObject<ImageDataHostObject>(runtime)) {
|
|
16
16
|
return *((ImageDataHostObject *) (jsObj.asHostObject(runtime).get()));
|
|
17
17
|
}
|
|
@@ -29,7 +29,7 @@ class JSI_EXPORT ImageDataHostObject : public HostObject {
|
|
|
29
29
|
void set(Runtime &, const PropNameID &name, const Value &value) override;
|
|
30
30
|
std::vector<PropNameID> getPropertyNames(Runtime &rt) override;
|
|
31
31
|
|
|
32
|
-
static ImageDataHostObject getHOFromObject(Runtime &runtime, Object jsObj);
|
|
32
|
+
static ImageDataHostObject getHOFromObject(Runtime &runtime, Object &jsObj);
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
#endif /* ImageDataHostObject_hpp */
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
#import <DynamsoftCaptureVisionBundle/DSCapturedResult.h>
|
|
6
6
|
#import <DynamsoftCaptureVisionBundle/DSQuadrilateral.h>
|
|
7
|
+
#import <DynamsoftCaptureVisionBundle/DSRect.h>
|
|
7
8
|
#import <jsi/jsi.h>
|
|
8
9
|
|
|
9
10
|
NS_ASSUME_NONNULL_BEGIN
|
|
@@ -17,3 +18,5 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
17
18
|
NS_ASSUME_NONNULL_END
|
|
18
19
|
|
|
19
20
|
DSQuadrilateral * _Nullable convertJSIValueToDSQuadrilateral(facebook::jsi::Runtime &runtime, const facebook::jsi::Object &value);
|
|
21
|
+
|
|
22
|
+
DSRect * _Nullable convertJSIValueToDSRect(facebook::jsi::Runtime &runtime, const facebook::jsi::Object &value);
|
|
@@ -12,6 +12,24 @@ NSArray<NSNumber *> *CGAffineTransformToArray(CGAffineTransform transform) {
|
|
|
12
12
|
return @[@(transform.a), @(transform.b), @(transform.c), @(transform.d), @(transform.tx), @(transform.ty)];
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
@implementation NSData (DSNumber)
|
|
16
|
+
|
|
17
|
+
- (nullable NSArray<NSNumber *> *)toNumberArray {
|
|
18
|
+
if (!self) return nil;
|
|
19
|
+
|
|
20
|
+
const uint8_t *bytes = (const uint8_t *)self.bytes;
|
|
21
|
+
NSUInteger length = self.length;
|
|
22
|
+
|
|
23
|
+
NSMutableArray *result = [NSMutableArray arrayWithCapacity:length];
|
|
24
|
+
for (NSUInteger i = 0; i < length; i++) {
|
|
25
|
+
[result addObject:@(bytes[i])];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@end
|
|
32
|
+
|
|
15
33
|
@implementation DSCapturedResultItem (JSI)
|
|
16
34
|
|
|
17
35
|
- (Object)convertToJSIObject:(Runtime& )runtime {
|
|
@@ -28,7 +46,8 @@ NSArray<NSNumber *> *CGAffineTransformToArray(CGAffineTransform transform) {
|
|
|
28
46
|
case DSCapturedResultItemTypeBarcode:
|
|
29
47
|
{
|
|
30
48
|
DSBarcodeResultItem *item = (DSBarcodeResultItem *)self;
|
|
31
|
-
obj.setProperty(runtime, "format",
|
|
49
|
+
obj.setProperty(runtime, "format", BigInt::fromUint64(runtime, item.format));
|
|
50
|
+
obj.setProperty(runtime, "_formatNumberString", convertNSStringToJSIString(runtime, [NSNumber numberWithUnsignedInteger:item.format].stringValue));
|
|
32
51
|
obj.setProperty(runtime, "formatString", convertNSStringToJSIString(runtime, item.formatString));
|
|
33
52
|
obj.setProperty(runtime, "text", convertNSStringToJSIString(runtime, item.text));
|
|
34
53
|
obj.setProperty(runtime, "location", convertNSDictionaryToJSIObject(runtime, [item.location toJson]));
|
|
@@ -37,12 +56,90 @@ NSArray<NSNumber *> *CGAffineTransformToArray(CGAffineTransform transform) {
|
|
|
37
56
|
obj.setProperty(runtime, "moduleSize", convertNSNumberToJSINumber(runtime, @(item.moduleSize)));
|
|
38
57
|
obj.setProperty(runtime, "isDPM", convertNSNumberToJSIBoolean(runtime, @(item.isDPM)));
|
|
39
58
|
obj.setProperty(runtime, "isMirrored", convertNSNumberToJSIBoolean(runtime, @(item.isMirrored)));
|
|
59
|
+
if (item.details) {
|
|
60
|
+
if (item.format == DSBarcodeFormatQRCode) {
|
|
61
|
+
DSQRCodeDetails *qrDetails = (DSQRCodeDetails *)item.details;
|
|
62
|
+
NSMutableDictionary *qrDict = [NSMutableDictionary dictionaryWithDictionary:@{
|
|
63
|
+
@"rows": @(qrDetails.rows),
|
|
64
|
+
@"columns": @(qrDetails.columns),
|
|
65
|
+
@"errorCorrectionLevel": @(qrDetails.errorCorrectionLevel),
|
|
66
|
+
@"version": @(qrDetails.version),
|
|
67
|
+
@"model": @(qrDetails.model),
|
|
68
|
+
@"mode": @(qrDetails.mode),
|
|
69
|
+
@"page": @(qrDetails.page),
|
|
70
|
+
@"totalPage": @(qrDetails.totalPage),
|
|
71
|
+
@"parityData": @(qrDetails.parityData),
|
|
72
|
+
@"dataMaskPattern": @(qrDetails.dataMaskPattern)
|
|
73
|
+
}];
|
|
74
|
+
|
|
75
|
+
if (qrDetails.codewords) {
|
|
76
|
+
qrDict[@"codewords"] = [qrDetails.codewords toNumberArray];
|
|
77
|
+
}
|
|
78
|
+
obj.setProperty(runtime, "qrCodeDetails", convertNSDictionaryToJSIObject(runtime, [qrDict copy]));
|
|
79
|
+
} else if (item.format == DSBarcodeFormatAztec) {
|
|
80
|
+
DSAztecDetails *aztecDetails = (DSAztecDetails *)item.details;
|
|
81
|
+
NSDictionary *aztecDict = @{
|
|
82
|
+
@"rows": @(aztecDetails.rows),
|
|
83
|
+
@"columns": @(aztecDetails.columns),
|
|
84
|
+
@"layerNumber": @(aztecDetails.layerNumber)
|
|
85
|
+
};
|
|
86
|
+
obj.setProperty(runtime, "aztecDetails", convertNSDictionaryToJSIObject(runtime, [aztecDict copy]));
|
|
87
|
+
} else if (item.format == DSBarcodeFormatDataMatrix) {
|
|
88
|
+
DSDataMatrixDetails *dmDetails = (DSDataMatrixDetails *)item.details;
|
|
89
|
+
NSDictionary *dmDict = @{
|
|
90
|
+
@"rows": @(dmDetails.rows),
|
|
91
|
+
@"columns": @(dmDetails.columns),
|
|
92
|
+
@"dataRegionRows": @(dmDetails.dataRegionRows),
|
|
93
|
+
@"dataRegionColumns": @(dmDetails.dataRegionColumns),
|
|
94
|
+
@"dataRegionNumber": @(dmDetails.dataRegionNumber)
|
|
95
|
+
};
|
|
96
|
+
obj.setProperty(runtime, "dataMatrixDetails", convertNSDictionaryToJSIObject(runtime, [dmDict copy]));
|
|
97
|
+
} else if ((item.format & DSBarcodeFormatOneD) != 0) {
|
|
98
|
+
DSOneDCodeDetails *onedDetails = (DSOneDCodeDetails *)item.details;
|
|
99
|
+
NSMutableDictionary *onedDict = [NSMutableDictionary dictionary];
|
|
100
|
+
|
|
101
|
+
if (onedDetails.startCharsBytes) {
|
|
102
|
+
onedDict[@"startCharsBytes"] = [onedDetails.startCharsBytes toNumberArray];
|
|
103
|
+
}
|
|
104
|
+
if (onedDetails.stopCharsBytes) {
|
|
105
|
+
onedDict[@"stopCharsBytes"] = [onedDetails.stopCharsBytes toNumberArray];
|
|
106
|
+
}
|
|
107
|
+
if (onedDetails.checkDigitBytes) {
|
|
108
|
+
onedDict[@"checkDigitBytes"] = [onedDetails.checkDigitBytes toNumberArray];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
onedDict[@"startPatternRange_lower"] = @(onedDetails.startPatternRange.minimum);
|
|
112
|
+
onedDict[@"middlePatternRange_lower"] = @(onedDetails.middlePatternRange.minimum);
|
|
113
|
+
onedDict[@"endPatternRange_lower"] = @(onedDetails.endPatternRange.minimum);
|
|
114
|
+
onedDict[@"startPatternRange_upper"] = @(onedDetails.startPatternRange.maximum);
|
|
115
|
+
onedDict[@"middlePatternRange_upper"] = @(onedDetails.middlePatternRange.maximum);
|
|
116
|
+
onedDict[@"endPatternRange_upper"] = @(onedDetails.endPatternRange.maximum);
|
|
117
|
+
|
|
118
|
+
obj.setProperty(runtime, "oneDCodeDetails", convertNSDictionaryToJSIObject(runtime, [onedDict copy]));
|
|
119
|
+
} else if (item.format == DSBarcodeFormatPDF417) {
|
|
120
|
+
DSPDF417Details *pdf417Details = (DSPDF417Details *)item.details;
|
|
121
|
+
NSMutableDictionary *pdf417Dict = [NSMutableDictionary dictionaryWithDictionary:@{
|
|
122
|
+
@"rows": @(pdf417Details.rows),
|
|
123
|
+
@"columns": @(pdf417Details.columns),
|
|
124
|
+
@"errorCorrectionLevel": @(pdf417Details.errorCorrectionLevel),
|
|
125
|
+
@"hasLeftRowIndicator": @(pdf417Details.hasLeftRowIndicator),
|
|
126
|
+
@"hasRightRowIndicator": @(pdf417Details.hasRightRowIndicator)
|
|
127
|
+
}];
|
|
128
|
+
|
|
129
|
+
if (pdf417Details.codewords) {
|
|
130
|
+
pdf417Dict[@"codewords"] = pdf417Details.codewords;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
obj.setProperty(runtime, "pdf417Details", convertNSDictionaryToJSIObject(runtime, [pdf417Dict copy]));
|
|
134
|
+
}
|
|
135
|
+
}
|
|
40
136
|
}
|
|
41
137
|
break;
|
|
42
138
|
case DSCapturedResultItemTypeTextLine:
|
|
43
139
|
{
|
|
44
140
|
DSTextLineResultItem *item = (DSTextLineResultItem *)self;
|
|
45
141
|
obj.setProperty(runtime, "text", convertNSStringToJSIString(runtime, item.text));
|
|
142
|
+
obj.setProperty(runtime, "rawText", convertNSStringToJSIString(runtime, item.rawText));
|
|
46
143
|
obj.setProperty(runtime, "location", convertNSDictionaryToJSIObject(runtime, [item.location toJson]));
|
|
47
144
|
obj.setProperty(runtime, "confidence",convertNSNumberToJSINumber(runtime, @(item.confidence)));
|
|
48
145
|
int count = item.charResult.count;
|
|
@@ -51,8 +148,9 @@ NSArray<NSNumber *> *CGAffineTransformToArray(CGAffineTransform transform) {
|
|
|
51
148
|
for (size_t i = 0; i < count; i++) {
|
|
52
149
|
array.setValueAtIndex(runtime, i, convertNSDictionaryToJSIObject(runtime, [[item.charResult objectAtIndex:i] toJson]));
|
|
53
150
|
}
|
|
54
|
-
obj.setProperty(runtime, "
|
|
151
|
+
obj.setProperty(runtime, "characterResults", array);
|
|
55
152
|
}
|
|
153
|
+
obj.setProperty(runtime, "specificationName", convertNSStringToJSIString(runtime, item.specificationName));
|
|
56
154
|
}
|
|
57
155
|
break;
|
|
58
156
|
case DSCapturedResultItemTypeDetectedQuad:
|
|
@@ -151,3 +249,22 @@ DSQuadrilateral * convertJSIValueToDSQuadrilateral(
|
|
|
151
249
|
}
|
|
152
250
|
return nil;
|
|
153
251
|
}
|
|
252
|
+
|
|
253
|
+
DSRect * convertJSIValueToDSRect(
|
|
254
|
+
jsi::Runtime &runtime,
|
|
255
|
+
const jsi::Object &value)
|
|
256
|
+
{
|
|
257
|
+
if (value.hasProperty(runtime, "top") &&
|
|
258
|
+
value.hasProperty(runtime, "bottom") &&
|
|
259
|
+
value.hasProperty(runtime, "right") &&
|
|
260
|
+
value.hasProperty(runtime, "left") &&
|
|
261
|
+
value.hasProperty(runtime, "measuredInPercentage")) {
|
|
262
|
+
double top = value.getProperty(runtime, "top").getNumber();
|
|
263
|
+
double bottom = value.getProperty(runtime, "bottom").getNumber();
|
|
264
|
+
double right = value.getProperty(runtime, "right").getNumber();
|
|
265
|
+
double left = value.getProperty(runtime, "left").getNumber();
|
|
266
|
+
BOOL measuredInPercentage = value.getProperty(runtime, "measuredInPercentage").getBool();
|
|
267
|
+
return [[DSRect alloc] initWithLeft:left top:top right:right bottom:bottom measuredInPercentage:measuredInPercentage];
|
|
268
|
+
}
|
|
269
|
+
return nil;
|
|
270
|
+
}
|
|
@@ -316,6 +316,24 @@ void runOnMainThread(void (^block)(void))
|
|
|
316
316
|
|
|
317
317
|
@end
|
|
318
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
|
+
|
|
319
337
|
@implementation DSCapturedResultItem (Json)
|
|
320
338
|
|
|
321
339
|
- (nullable NSDictionary *)toJson {
|
|
@@ -327,19 +345,99 @@ void runOnMainThread(void (^block)(void))
|
|
|
327
345
|
case DSCapturedResultItemTypeBarcode:
|
|
328
346
|
{
|
|
329
347
|
DSBarcodeResultItem *item = (DSBarcodeResultItem *)self;
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
348
|
+
NSMutableDictionary *mutableDictionary = [NSMutableDictionary dictionaryWithDictionary:@{
|
|
349
|
+
@"type":@(item.type),
|
|
350
|
+
@"targetROIDefName":item.targetROIDefName,
|
|
351
|
+
@"taskName":item.taskName,
|
|
352
|
+
@"_formatNumberString": [NSNumber numberWithUnsignedInteger:item.format].stringValue,
|
|
353
|
+
@"formatString":item.formatString,
|
|
354
|
+
@"text":item.text,
|
|
355
|
+
@"location":[item.location toJson],
|
|
356
|
+
@"confidence":@(item.confidence),
|
|
357
|
+
@"angle":@(item.angle),
|
|
358
|
+
@"moduleSize":@(item.moduleSize),
|
|
359
|
+
@"isDPM":@(item.isDPM),
|
|
360
|
+
@"isMirrored":@(item.isMirrored)
|
|
361
|
+
}];
|
|
362
|
+
if (item.details) {
|
|
363
|
+
if (item.format == DSBarcodeFormatQRCode) {
|
|
364
|
+
DSQRCodeDetails *qrDetails = (DSQRCodeDetails *)item.details;
|
|
365
|
+
NSMutableDictionary *qrDict = [NSMutableDictionary dictionaryWithDictionary:@{
|
|
366
|
+
@"rows": @(qrDetails.rows),
|
|
367
|
+
@"columns": @(qrDetails.columns),
|
|
368
|
+
@"errorCorrectionLevel": @(qrDetails.errorCorrectionLevel),
|
|
369
|
+
@"version": @(qrDetails.version),
|
|
370
|
+
@"model": @(qrDetails.model),
|
|
371
|
+
@"mode": @(qrDetails.mode),
|
|
372
|
+
@"page": @(qrDetails.page),
|
|
373
|
+
@"totalPage": @(qrDetails.totalPage),
|
|
374
|
+
@"parityData": @(qrDetails.parityData),
|
|
375
|
+
@"dataMaskPattern": @(qrDetails.dataMaskPattern)
|
|
376
|
+
}];
|
|
377
|
+
|
|
378
|
+
if (qrDetails.codewords) {
|
|
379
|
+
qrDict[@"codewords"] = [qrDetails.codewords toNumberArray];
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
mutableDictionary[@"qrCodeDetails"] = qrDict;
|
|
383
|
+
} else if (item.format == DSBarcodeFormatAztec) {
|
|
384
|
+
DSAztecDetails *aztecDetails = (DSAztecDetails *)item.details;
|
|
385
|
+
NSDictionary *aztecDict = @{
|
|
386
|
+
@"rows": @(aztecDetails.rows),
|
|
387
|
+
@"columns": @(aztecDetails.columns),
|
|
388
|
+
@"layerNumber": @(aztecDetails.layerNumber)
|
|
389
|
+
};
|
|
390
|
+
mutableDictionary[@"aztecDetails"] = aztecDict;
|
|
391
|
+
} else if (item.format == DSBarcodeFormatDataMatrix) {
|
|
392
|
+
DSDataMatrixDetails *dmDetails = (DSDataMatrixDetails *)item.details;
|
|
393
|
+
NSDictionary *dmDict = @{
|
|
394
|
+
@"rows": @(dmDetails.rows),
|
|
395
|
+
@"columns": @(dmDetails.columns),
|
|
396
|
+
@"dataRegionRows": @(dmDetails.dataRegionRows),
|
|
397
|
+
@"dataRegionColumns": @(dmDetails.dataRegionColumns),
|
|
398
|
+
@"dataRegionNumber": @(dmDetails.dataRegionNumber)
|
|
399
|
+
};
|
|
400
|
+
mutableDictionary[@"dataMatrixDetails"] = dmDict;
|
|
401
|
+
} else if ((item.format & DSBarcodeFormatOneD) != 0) {
|
|
402
|
+
DSOneDCodeDetails *onedDetails = (DSOneDCodeDetails *)item.details;
|
|
403
|
+
NSMutableDictionary *onedDict = [NSMutableDictionary dictionary];
|
|
404
|
+
|
|
405
|
+
if (onedDetails.startCharsBytes) {
|
|
406
|
+
onedDict[@"startCharsBytes"] = [onedDetails.startCharsBytes toNumberArray];
|
|
407
|
+
}
|
|
408
|
+
if (onedDetails.stopCharsBytes) {
|
|
409
|
+
onedDict[@"stopCharsBytes"] = [onedDetails.stopCharsBytes toNumberArray];
|
|
410
|
+
}
|
|
411
|
+
if (onedDetails.checkDigitBytes) {
|
|
412
|
+
onedDict[@"checkDigitBytes"] = [onedDetails.checkDigitBytes toNumberArray];
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
onedDict[@"startPatternRange_lower"] = @(onedDetails.startPatternRange.minimum);
|
|
416
|
+
onedDict[@"middlePatternRange_lower"] = @(onedDetails.middlePatternRange.minimum);
|
|
417
|
+
onedDict[@"endPatternRange_lower"] = @(onedDetails.endPatternRange.minimum);
|
|
418
|
+
onedDict[@"startPatternRange_upper"] = @(onedDetails.startPatternRange.maximum);
|
|
419
|
+
onedDict[@"middlePatternRange_upper"] = @(onedDetails.middlePatternRange.maximum);
|
|
420
|
+
onedDict[@"endPatternRange_upper"] = @(onedDetails.endPatternRange.maximum);
|
|
421
|
+
|
|
422
|
+
mutableDictionary[@"oneDCodeDetails"] = onedDict;
|
|
423
|
+
} else if (item.format == DSBarcodeFormatPDF417) {
|
|
424
|
+
DSPDF417Details *pdf417Details = (DSPDF417Details *)item.details;
|
|
425
|
+
NSMutableDictionary *pdf417Dict = [NSMutableDictionary dictionaryWithDictionary:@{
|
|
426
|
+
@"rows": @(pdf417Details.rows),
|
|
427
|
+
@"columns": @(pdf417Details.columns),
|
|
428
|
+
@"errorCorrectionLevel": @(pdf417Details.errorCorrectionLevel),
|
|
429
|
+
@"hasLeftRowIndicator": @(pdf417Details.hasLeftRowIndicator),
|
|
430
|
+
@"hasRightRowIndicator": @(pdf417Details.hasRightRowIndicator)
|
|
431
|
+
}];
|
|
432
|
+
|
|
433
|
+
if (pdf417Details.codewords) {
|
|
434
|
+
pdf417Dict[@"codewords"] = pdf417Details.codewords;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
mutableDictionary[@"pdf417Details"] = pdf417Dict;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
dictionary = [mutableDictionary copy];
|
|
343
441
|
}
|
|
344
442
|
break;
|
|
345
443
|
case DSCapturedResultItemTypeTextLine:
|
|
@@ -360,9 +458,11 @@ void runOnMainThread(void (^block)(void))
|
|
|
360
458
|
@"targetROIDefName":item.targetROIDefName,
|
|
361
459
|
@"taskName":item.taskName,
|
|
362
460
|
@"text":item.text,
|
|
461
|
+
@"rawText":item.rawText,
|
|
363
462
|
@"location":[item.location toJson],
|
|
364
463
|
@"confidence":@(item.confidence),
|
|
365
|
-
@"
|
|
464
|
+
@"characterResults":charResult,
|
|
465
|
+
@"specificationName": item.specificationName
|
|
366
466
|
};
|
|
367
467
|
}
|
|
368
468
|
break;
|
package/ios/CPP/YeetJSIUtils.h
CHANGED
|
@@ -36,6 +36,8 @@ RCTResponseSenderBlock convertJSIFunctionToCallback(
|
|
|
36
36
|
|
|
37
37
|
NSData* convertArrayBufferToNSData(jsi::Runtime &runtime, const jsi::ArrayBuffer &buffer);
|
|
38
38
|
|
|
39
|
+
jsi::ArrayBuffer converNSDataToArrayBuffer(jsi::Runtime &runtime, NSData *data);
|
|
40
|
+
|
|
39
41
|
struct Promise {
|
|
40
42
|
Promise(jsi::Runtime &rt, jsi::Function resolve, jsi::Function reject);
|
|
41
43
|
|
package/ios/CPP/YeetJSIUtils.mm
CHANGED
|
@@ -154,6 +154,21 @@ NSData* convertArrayBufferToNSData(jsi::Runtime &runtime, const jsi::ArrayBuffer
|
|
|
154
154
|
length:buffer.size(runtime)];
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
+
jsi::ArrayBuffer converNSDataToArrayBuffer(jsi::Runtime &runtime, NSData *data) {
|
|
158
|
+
size_t length = [data length];
|
|
159
|
+
const void *bytes = [data bytes];
|
|
160
|
+
|
|
161
|
+
jsi::ArrayBuffer arrayBuffer = runtime.global()
|
|
162
|
+
.getPropertyAsFunction(runtime, "ArrayBuffer")
|
|
163
|
+
.callAsConstructor(runtime, (double)length)
|
|
164
|
+
.getObject(runtime)
|
|
165
|
+
.getArrayBuffer(runtime);
|
|
166
|
+
|
|
167
|
+
memcpy(arrayBuffer.data(runtime), bytes, length);
|
|
168
|
+
|
|
169
|
+
return arrayBuffer;
|
|
170
|
+
}
|
|
171
|
+
|
|
157
172
|
Promise::Promise(jsi::Runtime &rt, jsi::Function resolve, jsi::Function reject)
|
|
158
173
|
: runtime_(rt), resolve_(std::move(resolve)), reject_(std::move(reject)) {}
|
|
159
174
|
|
|
@@ -22,6 +22,10 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
22
22
|
|
|
23
23
|
@property (nonatomic, strong) DSCameraView *cameraView;
|
|
24
24
|
|
|
25
|
+
@property (nonatomic, strong) NSDictionary *cameraToggleButton;
|
|
26
|
+
|
|
27
|
+
@property (nonatomic, assign) BOOL cameraToggleButtonVisible;
|
|
28
|
+
|
|
25
29
|
@end
|
|
26
30
|
|
|
27
31
|
NS_ASSUME_NONNULL_END
|
|
@@ -80,4 +80,29 @@
|
|
|
80
80
|
self.cameraView.torchButtonVisible = torchButtonVisible;
|
|
81
81
|
}
|
|
82
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
|
+
|
|
83
108
|
@end
|
|
@@ -38,6 +38,8 @@ RCT_EXPORT_VIEW_PROPERTY(scanRegionMaskVisible, BOOL)
|
|
|
38
38
|
RCT_EXPORT_VIEW_PROPERTY(scanLaserVisible, BOOL)
|
|
39
39
|
RCT_EXPORT_VIEW_PROPERTY(torchButton, NSDictionary)
|
|
40
40
|
RCT_EXPORT_VIEW_PROPERTY(torchButtonVisible, BOOL)
|
|
41
|
+
RCT_EXPORT_VIEW_PROPERTY(cameraToggleButton, NSDictionary)
|
|
42
|
+
RCT_EXPORT_VIEW_PROPERTY(cameraToggleButtonVisible, BOOL)
|
|
41
43
|
|
|
42
44
|
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(createInstance) {
|
|
43
45
|
RNDynamsoftImageSourceAdapter *rnAdapter = [self.bridge moduleForClass:[RNDynamsoftImageSourceAdapter class]];
|
|
@@ -58,8 +60,12 @@ RCT_EXPORT_METHOD(close) {
|
|
|
58
60
|
[self.dce close];
|
|
59
61
|
}
|
|
60
62
|
|
|
61
|
-
RCT_EXPORT_METHOD(setCameraView:(
|
|
62
|
-
|
|
63
|
+
RCT_EXPORT_METHOD(setCameraView:(nullable NSNumber *)tag) {
|
|
64
|
+
if (tag && tag.integerValue != 0) {
|
|
65
|
+
[self trySetCameraViewWithTag:tag attempt:1];
|
|
66
|
+
} else {
|
|
67
|
+
self.dce.cameraView = nil;
|
|
68
|
+
}
|
|
63
69
|
}
|
|
64
70
|
|
|
65
71
|
- (void)trySetCameraViewWithTag:(nonnull NSNumber *)tag attempt:(NSInteger)attempt {
|