react-native-rectangle-doc-scanner 2.0.0 → 2.1.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/CHANGELOG.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## [2.1.0] - 2025-10-17
|
|
6
|
+
|
|
7
|
+
### ✨ Enhanced - Camera Quality Optimizations
|
|
8
|
+
|
|
9
|
+
Significant improvements to image capture quality with automatic optimizations:
|
|
10
|
+
|
|
11
|
+
#### Camera Resolution
|
|
12
|
+
- Added automatic 4K resolution support (3840x2160)
|
|
13
|
+
- Falls back to Full HD (1920x1080) or Photo preset based on device capability
|
|
14
|
+
- Enabled `highResolutionStillImageOutputEnabled` for maximum capture quality
|
|
15
|
+
|
|
16
|
+
#### Display & Preview
|
|
17
|
+
- Fixed Retina display scaling (2x, 3x) for crisp camera preview
|
|
18
|
+
- Improved preview rendering quality with proper `contentScaleFactor`
|
|
19
|
+
|
|
20
|
+
#### Camera Features
|
|
21
|
+
- Enabled video stabilization for sharper images
|
|
22
|
+
- Configured continuous autofocus for always-sharp captures
|
|
23
|
+
- Added continuous auto exposure for optimal brightness
|
|
24
|
+
- Enabled continuous auto white balance for natural colors
|
|
25
|
+
- Enabled low-light boost for better performance in dark environments
|
|
26
|
+
- Automatic 4K format selection on iOS 13+ devices
|
|
27
|
+
|
|
28
|
+
#### Image Processing
|
|
29
|
+
- Direct pixel buffer access (`CVImageBuffer`) instead of JPEG re-compression
|
|
30
|
+
- Improved JPEG quality from default to 95% (near-lossless)
|
|
31
|
+
- Hardware-accelerated image conversion using `CIContext`
|
|
32
|
+
- Removed intermediate quality loss from UIGraphics rendering
|
|
33
|
+
- Source image used directly for processing (no decode/encode cycle)
|
|
34
|
+
|
|
35
|
+
### 📝 Technical Details
|
|
36
|
+
|
|
37
|
+
All optimizations are applied automatically through patches to the underlying `react-native-document-scanner` package. No configuration or code changes required in your app.
|
|
38
|
+
|
|
39
|
+
**Before**: Standard photo quality with basic camera settings
|
|
40
|
+
**After**: 4K capture with professional camera features and near-lossless image processing
|
|
41
|
+
|
|
42
|
+
## [2.0.0] - Previous Release
|
|
43
|
+
|
|
44
|
+
Initial release with TypeScript wrapper and basic functionality.
|
package/README.md
CHANGED
|
@@ -4,6 +4,23 @@ React Native-friendly wrapper around [`react-native-document-scanner`](https://g
|
|
|
4
4
|
|
|
5
5
|
> The native implementation lives inside the upstream library (Objective‑C/OpenCV on iOS, Kotlin/OpenCV on Android). This package simply re-exports a type-safe wrapper, optional crop editor helpers, and a full-screen scanner flow.
|
|
6
6
|
|
|
7
|
+
## ✨ Enhanced Image Quality (v2.1.0+)
|
|
8
|
+
|
|
9
|
+
This package includes automatic camera quality optimizations:
|
|
10
|
+
|
|
11
|
+
- **4K Resolution Support** - Automatically uses the highest available resolution (4K → Full HD → Photo)
|
|
12
|
+
- **High-Resolution Still Capture** - Enables `highResolutionStillImageOutputEnabled` for maximum quality
|
|
13
|
+
- **Retina Display Optimization** - Proper scale factor for crisp preview on all devices
|
|
14
|
+
- **Advanced Camera Features**:
|
|
15
|
+
- Video stabilization for sharper images
|
|
16
|
+
- Continuous autofocus for always-sharp captures
|
|
17
|
+
- Auto exposure and white balance
|
|
18
|
+
- Low-light boost in dark environments
|
|
19
|
+
- **Lossless Processing** - Direct pixel buffer access with 95% JPEG quality
|
|
20
|
+
- **Hardware-Accelerated Rendering** - Uses CIContext for efficient, high-quality image conversion
|
|
21
|
+
|
|
22
|
+
No configuration needed - these optimizations are applied automatically!
|
|
23
|
+
|
|
7
24
|
## Installation
|
|
8
25
|
|
|
9
26
|
```bash
|
package/package.json
CHANGED
|
@@ -30,16 +30,85 @@ index 1234567..abcdefg 100644
|
|
|
30
30
|
[session addInput:input];
|
|
31
31
|
|
|
32
32
|
AVCaptureVideoDataOutput *dataOutput = [[AVCaptureVideoDataOutput alloc] init];
|
|
33
|
-
@@ -134,
|
|
33
|
+
@@ -134,23 +143,70 @@
|
|
34
34
|
[session addOutput:dataOutput];
|
|
35
35
|
|
|
36
36
|
self.stillImageOutput = [[AVCaptureStillImageOutput alloc] init];
|
|
37
|
-
+ //
|
|
37
|
+
+ // Configure for maximum quality still image capture
|
|
38
38
|
+ self.stillImageOutput.outputSettings = @{AVVideoCodecKey: AVVideoCodecJPEG};
|
|
39
|
+
+ self.stillImageOutput.highResolutionStillImageOutputEnabled = YES;
|
|
39
40
|
[session addOutput:self.stillImageOutput];
|
|
40
41
|
|
|
41
42
|
AVCaptureConnection *connection = [dataOutput.connections firstObject];
|
|
42
|
-
|
|
43
|
+
[connection setVideoOrientation:AVCaptureVideoOrientationPortrait];
|
|
44
|
+
|
|
45
|
+
- if (device.isFlashAvailable)
|
|
46
|
+
+ // Enable video stabilization for better quality
|
|
47
|
+
+ if ([connection isVideoStabilizationSupported]) {
|
|
48
|
+
+ [connection setPreferredVideoStabilizationMode:AVCaptureVideoStabilizationModeAuto];
|
|
49
|
+
+ }
|
|
50
|
+
+
|
|
51
|
+
+ // Configure device for best quality
|
|
52
|
+
+ if ([device lockForConfiguration:nil])
|
|
53
|
+
{
|
|
54
|
+
- [device lockForConfiguration:nil];
|
|
55
|
+
- [device setFlashMode:AVCaptureFlashModeOff];
|
|
56
|
+
- [device unlockForConfiguration];
|
|
57
|
+
+ // Disable flash for better natural lighting
|
|
58
|
+
+ if (device.isFlashAvailable) {
|
|
59
|
+
+ [device setFlashMode:AVCaptureFlashModeOff];
|
|
60
|
+
+ }
|
|
61
|
+
|
|
62
|
+
- if ([device isFocusModeSupported:AVCaptureFocusModeContinuousAutoFocus])
|
|
63
|
+
- {
|
|
64
|
+
- [device lockForConfiguration:nil];
|
|
65
|
+
+ // Enable continuous autofocus for sharp images
|
|
66
|
+
+ if ([device isFocusModeSupported:AVCaptureFocusModeContinuousAutoFocus]) {
|
|
67
|
+
[device setFocusMode:AVCaptureFocusModeContinuousAutoFocus];
|
|
68
|
+
- [device unlockForConfiguration];
|
|
69
|
+
}
|
|
70
|
+
+
|
|
71
|
+
+ // Enable continuous auto exposure
|
|
72
|
+
+ if ([device isExposureModeSupported:AVCaptureExposureModeContinuousAutoExposure]) {
|
|
73
|
+
+ [device setExposureMode:AVCaptureExposureModeContinuousAutoExposure];
|
|
74
|
+
+ }
|
|
75
|
+
+
|
|
76
|
+
+ // Enable auto white balance
|
|
77
|
+
+ if ([device isWhiteBalanceModeSupported:AVCaptureWhiteBalanceModeContinuousAutoWhiteBalance]) {
|
|
78
|
+
+ [device setWhiteBalanceMode:AVCaptureWhiteBalanceModeContinuousAutoWhiteBalance];
|
|
79
|
+
+ }
|
|
80
|
+
+
|
|
81
|
+
+ // Enable low light boost if available
|
|
82
|
+
+ if (device.isLowLightBoostSupported) {
|
|
83
|
+
+ [device setAutomaticallyEnablesLowLightBoostWhenAvailable:YES];
|
|
84
|
+
+ }
|
|
85
|
+
+
|
|
86
|
+
+ // Set active video format to highest resolution
|
|
87
|
+
+ if (@available(iOS 13.0, *)) {
|
|
88
|
+
+ AVCaptureDeviceFormat *bestFormat = nil;
|
|
89
|
+
+ AVFrameRateRange *bestFrameRateRange = nil;
|
|
90
|
+
+ for (AVCaptureDeviceFormat *format in [device formats]) {
|
|
91
|
+
+ CMVideoDimensions dimensions = CMVideoFormatDescriptionGetDimensions(format.formatDescription);
|
|
92
|
+
+ // Prefer 4K resolution (3840x2160)
|
|
93
|
+
+ if (dimensions.width == 3840 && dimensions.height == 2160) {
|
|
94
|
+
+ for (AVFrameRateRange *range in format.videoSupportedFrameRateRanges) {
|
|
95
|
+
+ if (bestFormat == nil || range.maxFrameRate > bestFrameRateRange.maxFrameRate) {
|
|
96
|
+
+ bestFormat = format;
|
|
97
|
+
+ bestFrameRateRange = range;
|
|
98
|
+
+ }
|
|
99
|
+
+ }
|
|
100
|
+
+ }
|
|
101
|
+
+ }
|
|
102
|
+
+ if (bestFormat) {
|
|
103
|
+
+ [device setActiveFormat:bestFormat];
|
|
104
|
+
+ }
|
|
105
|
+
+ }
|
|
106
|
+
+
|
|
107
|
+
+ [device unlockForConfiguration];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
[session commitConfiguration];
|
|
111
|
+
@@ -381,10 +437,18 @@
|
|
43
112
|
|
|
44
113
|
[self.stillImageOutput captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler: ^(CMSampleBufferRef imageSampleBuffer, NSError *error)
|
|
45
114
|
{
|
|
@@ -60,7 +129,7 @@ index 1234567..abcdefg 100644
|
|
|
60
129
|
|
|
61
130
|
if (weakSelf.cameraViewType == IPDFCameraViewTypeBlackAndWhite)
|
|
62
131
|
{
|
|
63
|
-
@@ -405,10 +
|
|
132
|
+
@@ -405,10 +469,17 @@
|
|
64
133
|
{
|
|
65
134
|
enhancedImage = [self correctPerspectiveForImage:enhancedImage withFeatures:rectangleFeature];
|
|
66
135
|
|