@trustchex/react-native-sdk 1.374.0 → 1.381.0
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/android/src/main/java/com/trustchex/reactnativesdk/camera/TrustchexCameraView.kt +0 -9
- package/android/src/main/java/com/trustchex/reactnativesdk/opencv/OpenCVModule.kt +636 -301
- package/ios/Camera/TrustchexCameraView.swift +8 -8
- package/ios/OpenCV/OpenCVHelper.h +0 -7
- package/ios/OpenCV/OpenCVHelper.mm +0 -60
- package/ios/OpenCV/OpenCVModule.h +0 -4
- package/ios/OpenCV/OpenCVModule.mm +440 -358
- package/lib/module/Shared/Components/DebugOverlay.js +541 -0
- package/lib/module/Shared/Components/IdentityDocumentCamera.constants.js +44 -0
- package/lib/module/Shared/Components/IdentityDocumentCamera.flows.js +270 -0
- package/lib/module/Shared/Components/IdentityDocumentCamera.js +679 -1701
- package/lib/module/Shared/Components/IdentityDocumentCamera.types.js +3 -0
- package/lib/module/Shared/Components/IdentityDocumentCamera.utils.js +273 -0
- package/lib/module/version.js +1 -1
- package/lib/typescript/src/Shared/Components/DebugOverlay.d.ts +30 -0
- package/lib/typescript/src/Shared/Components/DebugOverlay.d.ts.map +1 -0
- package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.constants.d.ts +35 -0
- package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.constants.d.ts.map +1 -0
- package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.d.ts +3 -56
- package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.flows.d.ts +88 -0
- package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.flows.d.ts.map +1 -0
- package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.types.d.ts +116 -0
- package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.types.d.ts.map +1 -0
- package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.utils.d.ts +93 -0
- package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.utils.d.ts.map +1 -0
- package/lib/typescript/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/Shared/Components/DebugOverlay.tsx +656 -0
- package/src/Shared/Components/IdentityDocumentCamera.constants.ts +44 -0
- package/src/Shared/Components/IdentityDocumentCamera.flows.ts +342 -0
- package/src/Shared/Components/IdentityDocumentCamera.tsx +1065 -2462
- package/src/Shared/Components/IdentityDocumentCamera.types.ts +136 -0
- package/src/Shared/Components/IdentityDocumentCamera.utils.ts +364 -0
- package/src/version.ts +1 -1
|
@@ -33,7 +33,7 @@ class TrustchexCameraView: UIView {
|
|
|
33
33
|
@objc var resolution: String = "fullhd" {
|
|
34
34
|
didSet {
|
|
35
35
|
if resolution != oldValue {
|
|
36
|
-
//
|
|
36
|
+
// "hd" or "fullhd" - reinitialize camera with new resolution
|
|
37
37
|
setupCamera()
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -123,10 +123,10 @@ class TrustchexCameraView: UIView {
|
|
|
123
123
|
let cameraPosition: AVCaptureDevice.Position = (_cameraType == "front") ? .front : .back
|
|
124
124
|
|
|
125
125
|
// Set quality based on resolution setting
|
|
126
|
-
//
|
|
127
|
-
//
|
|
126
|
+
// "hd": 720x1280 (HD) - lower bandwidth, faster processing
|
|
127
|
+
// "fullhd": 1920x1080 (Full HD, default) - sharp text/document capture
|
|
128
128
|
let sessionPreset: AVCaptureSession.Preset
|
|
129
|
-
if resolution.lowercased() ==
|
|
129
|
+
if resolution.lowercased() == "hd" {
|
|
130
130
|
sessionPreset = .hd1280x720
|
|
131
131
|
} else {
|
|
132
132
|
sessionPreset = .hd1920x1080 // Full HD (default)
|
|
@@ -422,10 +422,10 @@ class TrustchexCameraView: UIView {
|
|
|
422
422
|
targetFps = fps
|
|
423
423
|
}
|
|
424
424
|
|
|
425
|
-
@objc(
|
|
426
|
-
func
|
|
427
|
-
//
|
|
428
|
-
resolution = res.lowercased() ==
|
|
425
|
+
@objc(changeResolution:)
|
|
426
|
+
func changeResolution(_ res: String) {
|
|
427
|
+
// "hd" (720x1280) or "fullhd" (1920x1080, default)
|
|
428
|
+
resolution = res.lowercased() == "hd" ? "hd" : "fullhd"
|
|
429
429
|
}
|
|
430
430
|
|
|
431
431
|
@objc func setFocusPoint(_ x: NSNumber, _ y: NSNumber) {
|
|
@@ -5,13 +5,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
5
5
|
|
|
6
6
|
@interface OpenCVHelper : NSObject
|
|
7
7
|
|
|
8
|
-
/// Preprocesses an image for better OCR text recognition
|
|
9
|
-
/// Applies bilateral filtering, CLAHE, and sharpening to enhance text clarity
|
|
10
|
-
/// @param image The input UIImage to preprocess
|
|
11
|
-
/// @param applyThresholding Whether to apply adaptive thresholding (for binary output)
|
|
12
|
-
/// @return A preprocessed UIImage optimized for text recognition, or nil if preprocessing fails
|
|
13
|
-
+ (UIImage * _Nullable)preprocessImageForOCR:(UIImage *)image applyThresholding:(BOOL)applyThresholding;
|
|
14
|
-
|
|
15
8
|
@end
|
|
16
9
|
|
|
17
10
|
NS_ASSUME_NONNULL_END
|
|
@@ -65,64 +65,4 @@
|
|
|
65
65
|
return image;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
+ (UIImage *)preprocessImageForOCR:(UIImage *)image applyThresholding:(BOOL)applyThresholding {
|
|
69
|
-
@try {
|
|
70
|
-
if (!image) return nil;
|
|
71
|
-
|
|
72
|
-
cv::Mat mat = [self imageToMat:image];
|
|
73
|
-
if (mat.empty()) return nil;
|
|
74
|
-
|
|
75
|
-
// Step 1: Convert to grayscale
|
|
76
|
-
cv::Mat gray;
|
|
77
|
-
cv::cvtColor(mat, gray, cv::COLOR_RGB2GRAY);
|
|
78
|
-
mat.release();
|
|
79
|
-
|
|
80
|
-
// Step 2: Suppress background using blackhat morphology
|
|
81
|
-
cv::Mat blackhat;
|
|
82
|
-
cv::Mat kernel = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(15, 5));
|
|
83
|
-
cv::morphologyEx(gray, blackhat, cv::MORPH_BLACKHAT, kernel);
|
|
84
|
-
gray.release();
|
|
85
|
-
|
|
86
|
-
// Step 3: Advanced denoising - removes artifacts while keeping character details
|
|
87
|
-
cv::Mat denoised;
|
|
88
|
-
cv::fastNlMeansDenoising(blackhat, denoised, 6.0, 7, 21);
|
|
89
|
-
blackhat.release();
|
|
90
|
-
|
|
91
|
-
// Step 4: CLAHE for local contrast without over-amplifying noise
|
|
92
|
-
cv::Ptr<cv::CLAHE> clahe = cv::createCLAHE(2.0, cv::Size(8, 8));
|
|
93
|
-
cv::Mat enhanced;
|
|
94
|
-
clahe->apply(denoised, enhanced);
|
|
95
|
-
denoised.release();
|
|
96
|
-
|
|
97
|
-
// Step 5: Unsharp masking for clearer edges without halos
|
|
98
|
-
cv::Mat blurred;
|
|
99
|
-
cv::GaussianBlur(enhanced, blurred, cv::Size(0, 0), 1.2);
|
|
100
|
-
cv::Mat sharpened;
|
|
101
|
-
cv::addWeighted(enhanced, 1.8, blurred, -0.8, 0, sharpened);
|
|
102
|
-
blurred.release();
|
|
103
|
-
enhanced.release();
|
|
104
|
-
|
|
105
|
-
// Step 6: Normalize to full 0-255 range
|
|
106
|
-
// Ensures maximum contrast for ML Kit
|
|
107
|
-
cv::Mat result;
|
|
108
|
-
cv::normalize(sharpened, result, 0, 255, cv::NORM_MINMAX);
|
|
109
|
-
sharpened.release();
|
|
110
|
-
|
|
111
|
-
if (applyThresholding) {
|
|
112
|
-
cv::Mat thresholded;
|
|
113
|
-
cv::adaptiveThreshold(result, thresholded, 255, cv::ADAPTIVE_THRESH_GAUSSIAN_C, cv::THRESH_BINARY, 31, 10);
|
|
114
|
-
result.release();
|
|
115
|
-
result = thresholded;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
UIImage *resultImage = [self matToImage:result];
|
|
119
|
-
result.release();
|
|
120
|
-
|
|
121
|
-
return resultImage;
|
|
122
|
-
} @catch (NSException *exception) {
|
|
123
|
-
NSLog(@"OpenCV preprocessing error: %@", exception.reason);
|
|
124
|
-
return nil;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
68
|
@end
|
|
@@ -3,8 +3,4 @@
|
|
|
3
3
|
|
|
4
4
|
@interface OpenCVModule : NSObject <RCTBridgeModule>
|
|
5
5
|
|
|
6
|
-
// Synchronous method for preprocessingimage for OCR
|
|
7
|
-
// This is called directly from Swift camera code for better performance
|
|
8
|
-
- (UIImage * _Nullable)preprocessImageForOCRSync:(UIImage * _Nonnull)image applyThresholding:(BOOL)applyThresholding;
|
|
9
|
-
|
|
10
6
|
@end
|