react-native-rectangle-doc-scanner 10.3.0 → 10.5.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.
|
@@ -80,6 +80,12 @@ class CameraController(
|
|
|
80
80
|
return
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
// Check lifecycle state
|
|
84
|
+
Log.d(TAG, "[CAMERAX] Current lifecycle state: ${lifecycleOwner.lifecycle.currentState}")
|
|
85
|
+
if (lifecycleOwner.lifecycle.currentState != androidx.lifecycle.Lifecycle.State.RESUMED) {
|
|
86
|
+
Log.w(TAG, "[CAMERAX] Lifecycle is not RESUMED, camera stream may not start")
|
|
87
|
+
}
|
|
88
|
+
|
|
83
89
|
// Select camera
|
|
84
90
|
val cameraSelector = if (useFrontCamera) {
|
|
85
91
|
CameraSelector.DEFAULT_FRONT_CAMERA
|
|
@@ -125,15 +131,36 @@ class CameraController(
|
|
|
125
131
|
// Unbind all use cases before rebinding
|
|
126
132
|
cameraProvider.unbindAll()
|
|
127
133
|
|
|
128
|
-
// Bind use cases to camera
|
|
134
|
+
// Bind use cases to camera - start with Preview and ImageCapture only
|
|
135
|
+
Log.d(TAG, "[CAMERAX] Binding Preview and ImageCapture first...")
|
|
129
136
|
camera = cameraProvider.bindToLifecycle(
|
|
130
137
|
lifecycleOwner,
|
|
131
138
|
cameraSelector,
|
|
132
139
|
preview,
|
|
133
|
-
imageAnalyzer,
|
|
134
140
|
imageCapture
|
|
135
141
|
)
|
|
136
142
|
|
|
143
|
+
Log.d(TAG, "[CAMERAX] Preview and ImageCapture bound successfully")
|
|
144
|
+
|
|
145
|
+
// Add ImageAnalysis after a short delay to avoid timeout
|
|
146
|
+
if (detectionEnabled) {
|
|
147
|
+
previewView.post {
|
|
148
|
+
try {
|
|
149
|
+
Log.d(TAG, "[CAMERAX] Adding ImageAnalysis...")
|
|
150
|
+
camera = cameraProvider.bindToLifecycle(
|
|
151
|
+
lifecycleOwner,
|
|
152
|
+
cameraSelector,
|
|
153
|
+
preview,
|
|
154
|
+
imageCapture,
|
|
155
|
+
imageAnalyzer
|
|
156
|
+
)
|
|
157
|
+
Log.d(TAG, "[CAMERAX] ImageAnalysis added successfully")
|
|
158
|
+
} catch (e: Exception) {
|
|
159
|
+
Log.e(TAG, "[CAMERAX] Failed to add ImageAnalysis", e)
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
137
164
|
Log.d(TAG, "[CAMERAX] Camera bound successfully")
|
|
138
165
|
|
|
139
166
|
// Monitor preview stream state
|
package/android/src/camera2/kotlin/com/reactnativerectangledocscanner/DocumentScannerView.kt
CHANGED
|
@@ -87,7 +87,7 @@ class DocumentScannerView(context: ThemedReactContext) : FrameLayout(context), L
|
|
|
87
87
|
layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
|
|
88
88
|
visibility = View.VISIBLE
|
|
89
89
|
keepScreenOn = true
|
|
90
|
-
implementationMode = PreviewView.ImplementationMode.
|
|
90
|
+
implementationMode = PreviewView.ImplementationMode.COMPATIBLE // Use TextureView - more compatible with React Native
|
|
91
91
|
scaleType = PreviewView.ScaleType.FILL_CENTER // Fill and center the preview
|
|
92
92
|
}
|
|
93
93
|
Log.d(TAG, "[INIT] PreviewView created: $previewView")
|