react-native-rectangle-doc-scanner 3.225.0 → 3.227.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.
|
@@ -9,7 +9,6 @@ import android.graphics.Matrix
|
|
|
9
9
|
import android.graphics.Rect
|
|
10
10
|
import android.graphics.YuvImage
|
|
11
11
|
import android.util.Log
|
|
12
|
-
import android.util.Size
|
|
13
12
|
import android.view.Surface
|
|
14
13
|
import androidx.camera.core.AspectRatio
|
|
15
14
|
import androidx.camera.core.Camera
|
|
@@ -44,6 +43,7 @@ class CameraController(
|
|
|
44
43
|
private val cameraExecutor: ExecutorService = Executors.newSingleThreadExecutor()
|
|
45
44
|
private val lastFrame = AtomicReference<LastFrame?>()
|
|
46
45
|
private var analysisBound = false
|
|
46
|
+
private var pendingBindAttempts = 0
|
|
47
47
|
|
|
48
48
|
private var useFrontCamera = false
|
|
49
49
|
private var detectionEnabled = true
|
|
@@ -168,6 +168,18 @@ class CameraController(
|
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
private fun bindCameraUseCases() {
|
|
171
|
+
if (!previewView.isAttachedToWindow || previewView.width == 0 || previewView.height == 0) {
|
|
172
|
+
if (pendingBindAttempts < 5) {
|
|
173
|
+
pendingBindAttempts++
|
|
174
|
+
Log.d(TAG, "[CAMERAX-V9] PreviewView not ready (attached=${previewView.isAttachedToWindow}, w=${previewView.width}, h=${previewView.height}), retrying...")
|
|
175
|
+
previewView.post { bindCameraUseCases() }
|
|
176
|
+
} else {
|
|
177
|
+
Log.w(TAG, "[CAMERAX-V9] PreviewView still not ready after retries, aborting bind")
|
|
178
|
+
}
|
|
179
|
+
return
|
|
180
|
+
}
|
|
181
|
+
pendingBindAttempts = 0
|
|
182
|
+
|
|
171
183
|
val provider = cameraProvider ?: return
|
|
172
184
|
provider.unbindAll()
|
|
173
185
|
analysisBound = false
|
|
@@ -175,9 +187,9 @@ class CameraController(
|
|
|
175
187
|
|
|
176
188
|
val rotation = previewView.display?.rotation ?: Surface.ROTATION_0
|
|
177
189
|
|
|
178
|
-
// Build Preview
|
|
190
|
+
// Build Preview without a fixed size to avoid unsupported stream configs.
|
|
179
191
|
preview = Preview.Builder()
|
|
180
|
-
.
|
|
192
|
+
.setTargetAspectRatio(AspectRatio.RATIO_4_3)
|
|
181
193
|
.setTargetRotation(rotation)
|
|
182
194
|
.build()
|
|
183
195
|
.also {
|
|
@@ -78,7 +78,8 @@ class DocumentScannerView(context: ThemedReactContext) : FrameLayout(context), L
|
|
|
78
78
|
layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
|
|
79
79
|
visibility = View.VISIBLE
|
|
80
80
|
keepScreenOn = true
|
|
81
|
-
|
|
81
|
+
// SurfaceView path is more stable on some devices during session config.
|
|
82
|
+
implementationMode = PreviewView.ImplementationMode.PERFORMANCE
|
|
82
83
|
scaleType = PreviewView.ScaleType.FILL_CENTER
|
|
83
84
|
}
|
|
84
85
|
Log.d(TAG, "[INIT] PreviewView created: $previewView")
|
package/package.json
CHANGED