react-native-rectangle-doc-scanner 10.3.0 → 10.4.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.
|
@@ -125,15 +125,36 @@ class CameraController(
|
|
|
125
125
|
// Unbind all use cases before rebinding
|
|
126
126
|
cameraProvider.unbindAll()
|
|
127
127
|
|
|
128
|
-
// Bind use cases to camera
|
|
128
|
+
// Bind use cases to camera - start with Preview and ImageCapture only
|
|
129
|
+
Log.d(TAG, "[CAMERAX] Binding Preview and ImageCapture first...")
|
|
129
130
|
camera = cameraProvider.bindToLifecycle(
|
|
130
131
|
lifecycleOwner,
|
|
131
132
|
cameraSelector,
|
|
132
133
|
preview,
|
|
133
|
-
imageAnalyzer,
|
|
134
134
|
imageCapture
|
|
135
135
|
)
|
|
136
136
|
|
|
137
|
+
Log.d(TAG, "[CAMERAX] Preview and ImageCapture bound successfully")
|
|
138
|
+
|
|
139
|
+
// Add ImageAnalysis after a short delay to avoid timeout
|
|
140
|
+
if (detectionEnabled) {
|
|
141
|
+
previewView.post {
|
|
142
|
+
try {
|
|
143
|
+
Log.d(TAG, "[CAMERAX] Adding ImageAnalysis...")
|
|
144
|
+
camera = cameraProvider.bindToLifecycle(
|
|
145
|
+
lifecycleOwner,
|
|
146
|
+
cameraSelector,
|
|
147
|
+
preview,
|
|
148
|
+
imageCapture,
|
|
149
|
+
imageAnalyzer
|
|
150
|
+
)
|
|
151
|
+
Log.d(TAG, "[CAMERAX] ImageAnalysis added successfully")
|
|
152
|
+
} catch (e: Exception) {
|
|
153
|
+
Log.e(TAG, "[CAMERAX] Failed to add ImageAnalysis", e)
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
137
158
|
Log.d(TAG, "[CAMERAX] Camera bound successfully")
|
|
138
159
|
|
|
139
160
|
// 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")
|