react-native-rectangle-doc-scanner 3.185.0 → 3.189.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.
|
@@ -4,6 +4,7 @@ import android.content.Context
|
|
|
4
4
|
import android.graphics.ImageFormat
|
|
5
5
|
import android.util.Log
|
|
6
6
|
import android.util.Size
|
|
7
|
+
import android.view.Surface
|
|
7
8
|
import androidx.camera.core.*
|
|
8
9
|
import androidx.camera.lifecycle.ProcessCameraProvider
|
|
9
10
|
import androidx.camera.view.PreviewView
|
|
@@ -105,10 +106,14 @@ class CameraController(
|
|
|
105
106
|
}
|
|
106
107
|
Log.d(TAG, "[BIND] Camera selector: ${if (useFrontCamera) "FRONT" else "BACK"}")
|
|
107
108
|
|
|
109
|
+
val targetRotation = previewView.display?.rotation ?: Surface.ROTATION_0
|
|
110
|
+
|
|
108
111
|
// Preview use case
|
|
109
112
|
Log.d(TAG, "[BIND] Creating Preview use case...")
|
|
110
113
|
val preview = Preview.Builder()
|
|
111
|
-
.
|
|
114
|
+
// Use aspect ratio to avoid unsupported size combinations on some devices.
|
|
115
|
+
.setTargetAspectRatio(AspectRatio.RATIO_4_3)
|
|
116
|
+
.setTargetRotation(targetRotation)
|
|
112
117
|
.build()
|
|
113
118
|
Log.d(TAG, "[BIND] Preview created: $preview")
|
|
114
119
|
|
|
@@ -116,7 +121,11 @@ class CameraController(
|
|
|
116
121
|
Log.d(TAG, "[BIND] Creating ImageCapture use case...")
|
|
117
122
|
imageCapture = ImageCapture.Builder()
|
|
118
123
|
.setCaptureMode(ImageCapture.CAPTURE_MODE_MAXIMIZE_QUALITY)
|
|
119
|
-
.
|
|
124
|
+
// Use aspect ratio to avoid unsupported size combinations on some devices.
|
|
125
|
+
.setTargetAspectRatio(AspectRatio.RATIO_4_3)
|
|
126
|
+
// Cap resolution to avoid camera session timeouts on lower-end devices.
|
|
127
|
+
.setTargetResolution(Size(1280, 960))
|
|
128
|
+
.setTargetRotation(targetRotation)
|
|
120
129
|
.setFlashMode(ImageCapture.FLASH_MODE_AUTO)
|
|
121
130
|
.build()
|
|
122
131
|
Log.d(TAG, "[BIND] ImageCapture created: $imageCapture")
|
|
@@ -125,7 +134,11 @@ class CameraController(
|
|
|
125
134
|
imageAnalysis = if (enableDetection) {
|
|
126
135
|
Log.d(TAG, "[BIND] Creating ImageAnalysis use case...")
|
|
127
136
|
ImageAnalysis.Builder()
|
|
128
|
-
.
|
|
137
|
+
// Use aspect ratio to avoid unsupported size combinations on some devices.
|
|
138
|
+
.setTargetAspectRatio(AspectRatio.RATIO_4_3)
|
|
139
|
+
// Keep analysis lightweight to prevent session configuration timeouts.
|
|
140
|
+
.setTargetResolution(Size(960, 720))
|
|
141
|
+
.setTargetRotation(targetRotation)
|
|
129
142
|
.setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
|
|
130
143
|
.setOutputImageFormat(ImageAnalysis.OUTPUT_IMAGE_FORMAT_YUV_420_888)
|
|
131
144
|
.build()
|
package/package.json
CHANGED