react-native-rectangle-doc-scanner 3.222.0 → 3.223.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.
|
@@ -175,21 +175,11 @@ class CameraController(
|
|
|
175
175
|
|
|
176
176
|
val rotation = previewView.display?.rotation ?: Surface.ROTATION_0
|
|
177
177
|
|
|
178
|
-
// Build Preview
|
|
178
|
+
// Build Preview ONLY - this device cannot handle 2 simultaneous surfaces
|
|
179
179
|
preview = Preview.Builder()
|
|
180
180
|
.setTargetResolution(Size(1280, 720))
|
|
181
181
|
.setTargetRotation(rotation)
|
|
182
182
|
.build()
|
|
183
|
-
.also {
|
|
184
|
-
it.setSurfaceProvider(previewView.surfaceProvider)
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// Build ImageCapture for periodic frame capture (instead of ImageAnalysis)
|
|
188
|
-
imageCapture = ImageCapture.Builder()
|
|
189
|
-
.setTargetResolution(Size(640, 480))
|
|
190
|
-
.setTargetRotation(rotation)
|
|
191
|
-
.setCaptureMode(ImageCapture.CAPTURE_MODE_MINIMIZE_LATENCY)
|
|
192
|
-
.build()
|
|
193
183
|
|
|
194
184
|
val cameraSelector = if (useFrontCamera) {
|
|
195
185
|
CameraSelector.DEFAULT_FRONT_CAMERA
|
|
@@ -197,25 +187,76 @@ class CameraController(
|
|
|
197
187
|
CameraSelector.DEFAULT_BACK_CAMERA
|
|
198
188
|
}
|
|
199
189
|
|
|
200
|
-
// Bind Preview
|
|
190
|
+
// Bind Preview ONLY first
|
|
201
191
|
try {
|
|
192
|
+
camera = provider.bindToLifecycle(
|
|
193
|
+
lifecycleOwner,
|
|
194
|
+
cameraSelector,
|
|
195
|
+
preview
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
// Set surface provider AFTER binding
|
|
199
|
+
preview?.setSurfaceProvider(previewView.surfaceProvider)
|
|
200
|
+
|
|
201
|
+
Log.d(TAG, "[CAMERAX-V7] Preview ONLY bound successfully")
|
|
202
|
+
|
|
203
|
+
// Wait for preview to stabilize, then try adding ImageCapture
|
|
204
|
+
android.os.Handler(android.os.Looper.getMainLooper()).postDelayed({
|
|
205
|
+
tryAddImageCapture(provider, cameraSelector, rotation)
|
|
206
|
+
}, 3000)
|
|
207
|
+
|
|
208
|
+
} catch (e: Exception) {
|
|
209
|
+
Log.e(TAG, "[CAMERAX-V7] Failed to bind preview", e)
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
private fun tryAddImageCapture(provider: ProcessCameraProvider, cameraSelector: CameraSelector, rotation: Int) {
|
|
214
|
+
Log.d(TAG, "[CAMERAX-V7] Attempting to add ImageCapture...")
|
|
215
|
+
|
|
216
|
+
// Build ImageCapture with minimal resolution
|
|
217
|
+
imageCapture = ImageCapture.Builder()
|
|
218
|
+
.setTargetResolution(Size(320, 240))
|
|
219
|
+
.setTargetRotation(rotation)
|
|
220
|
+
.setCaptureMode(ImageCapture.CAPTURE_MODE_MINIMIZE_LATENCY)
|
|
221
|
+
.build()
|
|
222
|
+
|
|
223
|
+
try {
|
|
224
|
+
// Unbind and rebind with both
|
|
225
|
+
provider.unbindAll()
|
|
226
|
+
|
|
202
227
|
camera = provider.bindToLifecycle(
|
|
203
228
|
lifecycleOwner,
|
|
204
229
|
cameraSelector,
|
|
205
230
|
preview,
|
|
206
231
|
imageCapture
|
|
207
232
|
)
|
|
208
|
-
Log.d(TAG, "[CAMERAX-V6] Preview + ImageCapture bound successfully")
|
|
209
233
|
|
|
210
|
-
|
|
234
|
+
preview?.setSurfaceProvider(previewView.surfaceProvider)
|
|
235
|
+
|
|
236
|
+
Log.d(TAG, "[CAMERAX-V7] ImageCapture added successfully")
|
|
237
|
+
|
|
238
|
+
// Start periodic frame capture
|
|
211
239
|
if (detectionEnabled) {
|
|
212
240
|
isAnalysisActive = true
|
|
213
|
-
analysisHandler.postDelayed(analysisRunnable, 500)
|
|
214
|
-
Log.d(TAG, "[CAMERAX-
|
|
241
|
+
analysisHandler.postDelayed(analysisRunnable, 500)
|
|
242
|
+
Log.d(TAG, "[CAMERAX-V7] Started periodic frame capture")
|
|
215
243
|
}
|
|
216
244
|
|
|
217
245
|
} catch (e: Exception) {
|
|
218
|
-
Log.e(TAG, "[CAMERAX-
|
|
246
|
+
Log.e(TAG, "[CAMERAX-V7] Failed to add ImageCapture, keeping Preview only", e)
|
|
247
|
+
|
|
248
|
+
// Fallback: Keep preview only and disable detection
|
|
249
|
+
try {
|
|
250
|
+
camera = provider.bindToLifecycle(
|
|
251
|
+
lifecycleOwner,
|
|
252
|
+
cameraSelector,
|
|
253
|
+
preview
|
|
254
|
+
)
|
|
255
|
+
preview?.setSurfaceProvider(previewView.surfaceProvider)
|
|
256
|
+
Log.d(TAG, "[CAMERAX-V7] Fallback: Preview only mode (detection disabled)")
|
|
257
|
+
} catch (fallbackException: Exception) {
|
|
258
|
+
Log.e(TAG, "[CAMERAX-V7] Fallback failed", fallbackException)
|
|
259
|
+
}
|
|
219
260
|
}
|
|
220
261
|
}
|
|
221
262
|
|
package/package.json
CHANGED