react-native-rectangle-doc-scanner 1.16.0 → 2.0.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/package.json
CHANGED
|
@@ -30,31 +30,57 @@ index 1234567..abcdefg 100644
|
|
|
30
30
|
[session addInput:input];
|
|
31
31
|
|
|
32
32
|
AVCaptureVideoDataOutput *dataOutput = [[AVCaptureVideoDataOutput alloc] init];
|
|
33
|
-
@@ -134,6 +143,
|
|
33
|
+
@@ -134,6 +143,8 @@
|
|
34
34
|
[session addOutput:dataOutput];
|
|
35
35
|
|
|
36
36
|
self.stillImageOutput = [[AVCaptureStillImageOutput alloc] init];
|
|
37
|
-
+
|
|
38
|
-
+
|
|
39
|
-
+ NSDictionary *outputSettings = @{
|
|
40
|
-
+ AVVideoCodecKey: AVVideoCodecJPEG,
|
|
41
|
-
+ AVVideoQualityKey: @(0.95)
|
|
42
|
-
+ };
|
|
43
|
-
+ [self.stillImageOutput setOutputSettings:outputSettings];
|
|
44
|
-
+
|
|
37
|
+
+ // Use maximum quality for still image capture
|
|
38
|
+
+ self.stillImageOutput.outputSettings = @{AVVideoCodecKey: AVVideoCodecJPEG};
|
|
45
39
|
[session addOutput:self.stillImageOutput];
|
|
46
40
|
|
|
47
41
|
AVCaptureConnection *connection = [dataOutput.connections firstObject];
|
|
48
|
-
@@ -
|
|
49
|
-
|
|
50
|
-
|
|
42
|
+
@@ -381,10 +392,18 @@
|
|
43
|
+
|
|
44
|
+
[self.stillImageOutput captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler: ^(CMSampleBufferRef imageSampleBuffer, NSError *error)
|
|
45
|
+
{
|
|
46
|
+
- NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageSampleBuffer];
|
|
47
|
+
+ // Get the highest quality image data from sample buffer
|
|
48
|
+
+ CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(imageSampleBuffer);
|
|
49
|
+
+ CIImage *sourceImage = [CIImage imageWithCVPixelBuffer:imageBuffer];
|
|
50
|
+
+
|
|
51
|
+
+ // Create high quality JPEG data
|
|
52
|
+
+ CIContext *context = [CIContext context];
|
|
53
|
+
+ NSData *imageData = [context JPEGRepresentationOfImage:sourceImage colorSpace:sourceImage.colorSpace options:@{(id)kCGImageDestinationLossyCompressionQuality: @(0.95)}];
|
|
54
|
+
|
|
55
|
+
if (weakSelf.cameraViewType == IPDFCameraViewTypeBlackAndWhite || weakSelf.isBorderDetectionEnabled)
|
|
56
|
+
{
|
|
57
|
+
- CIImage *enhancedImage = [CIImage imageWithData:imageData];
|
|
58
|
+
+ // Use source image directly for better quality
|
|
59
|
+
+ CIImage *enhancedImage = sourceImage;
|
|
60
|
+
|
|
61
|
+
if (weakSelf.cameraViewType == IPDFCameraViewTypeBlackAndWhite)
|
|
62
|
+
{
|
|
63
|
+
@@ -405,10 +424,17 @@
|
|
64
|
+
{
|
|
65
|
+
enhancedImage = [self correctPerspectiveForImage:enhancedImage withFeatures:rectangleFeature];
|
|
51
66
|
|
|
52
67
|
- UIGraphicsBeginImageContext(CGSizeMake(enhancedImage.extent.size.height, enhancedImage.extent.size.width));
|
|
53
68
|
- [[UIImage imageWithCIImage:enhancedImage scale:1.0 orientation:UIImageOrientationRight] drawInRect:CGRectMake(0,0, enhancedImage.extent.size.height, enhancedImage.extent.size.width)];
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
+
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
69
|
+
- UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
|
|
70
|
+
- UIImage *initialImage = [UIImage imageWithData:imageData];
|
|
71
|
+
- UIGraphicsEndImageContext();
|
|
72
|
+
+ // Convert CIImage to UIImage with high quality using CIContext
|
|
73
|
+
+ CIContext *ciContext = [CIContext contextWithOptions:@{kCIContextUseSoftwareRenderer: @(NO)}];
|
|
74
|
+
+
|
|
75
|
+
+ // Apply rotation to match device orientation
|
|
76
|
+
+ CGAffineTransform transform = CGAffineTransformMakeRotation(-M_PI_2);
|
|
77
|
+
+ enhancedImage = [enhancedImage imageByApplyingTransform:transform];
|
|
78
|
+
+
|
|
79
|
+
+ // Convert to CGImage first for better quality
|
|
80
|
+
+ CGImageRef cgImage = [ciContext createCGImage:enhancedImage fromRect:enhancedImage.extent];
|
|
81
|
+
+ UIImage *image = [UIImage imageWithCGImage:cgImage scale:1.0 orientation:UIImageOrientationUp];
|
|
82
|
+
+ CGImageRelease(cgImage);
|
|
83
|
+
+
|
|
84
|
+
+ UIImage *initialImage = [UIImage imageWithData:imageData];
|
|
85
|
+
|
|
86
|
+
[weakSelf hideGLKView:NO completion:nil];
|