react-native-rectangle-doc-scanner 10.2.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.
@@ -93,15 +93,18 @@ class CameraController(
93
93
  Log.d(TAG, "[CAMERAX] PreviewView scaleType: ${previewView.scaleType}")
94
94
  Log.d(TAG, "[CAMERAX] PreviewView implementationMode: ${previewView.implementationMode}")
95
95
  preview = Preview.Builder()
96
+ .setTargetResolution(android.util.Size(1920, 1080)) // 16:9 resolution
96
97
  .build()
97
- .also {
98
- it.setSurfaceProvider(previewView.surfaceProvider)
98
+ .also { previewUseCase ->
99
+ Log.d(TAG, "[CAMERAX] Setting SurfaceProvider...")
100
+ previewUseCase.setSurfaceProvider(previewView.surfaceProvider)
99
101
  Log.d(TAG, "[CAMERAX] SurfaceProvider set successfully")
100
102
  }
101
103
 
102
104
  // ImageAnalysis UseCase for document detection
103
105
  imageAnalyzer = ImageAnalysis.Builder()
104
106
  .setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
107
+ .setTargetResolution(android.util.Size(1280, 960)) // Limit resolution for analysis
105
108
  .build()
106
109
  .also {
107
110
  it.setAnalyzer(cameraExecutor) { imageProxy ->
@@ -122,15 +125,36 @@ class CameraController(
122
125
  // Unbind all use cases before rebinding
123
126
  cameraProvider.unbindAll()
124
127
 
125
- // 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...")
126
130
  camera = cameraProvider.bindToLifecycle(
127
131
  lifecycleOwner,
128
132
  cameraSelector,
129
133
  preview,
130
- imageAnalyzer,
131
134
  imageCapture
132
135
  )
133
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
+
134
158
  Log.d(TAG, "[CAMERAX] Camera bound successfully")
135
159
 
136
160
  // Monitor preview stream state
@@ -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.PERFORMANCE // Use SurfaceView internally
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")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "10.2.0",
3
+ "version": "10.4.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",