react-native-rectangle-doc-scanner 4.10.0 → 4.12.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.
@@ -234,7 +234,10 @@ class CameraController(
234
234
  Log.d(TAG, "[CAMERA2] viewAspect=$viewAspect (view: ${viewWidth}x${viewHeight})")
235
235
 
236
236
  val previewSizes = streamConfigMap.getOutputSizes(SurfaceTexture::class.java)
237
+ Log.d(TAG, "[CAMERA2] Available preview sizes: ${previewSizes?.take(10)?.joinToString { "${it.width}x${it.height}" }}")
238
+
237
239
  previewSize = chooseBestSize(previewSizes, viewAspect, null, preferClosestAspect = true)
240
+ Log.d(TAG, "[CAMERA2] Selected preview size: ${previewSize?.width}x${previewSize?.height}")
238
241
 
239
242
  val previewAspect = previewSize?.let { it.width.toDouble() / it.height.toDouble() } ?: viewAspect
240
243
  val analysisSizes = streamConfigMap.getOutputSizes(ImageFormat.YUV_420_888)
@@ -587,13 +590,24 @@ class CameraController(
587
590
  }
588
591
 
589
592
  if (preferClosestAspect) {
590
- val maxAreaOverall = capped.maxOf { it.width * it.height }
591
- val minAcceptableArea = max(640 * 480, (maxAreaOverall * 0.1).toInt())
592
- val sized = capped.filter { it.width * it.height >= minAcceptableArea }
593
- val pool = if (sized.isNotEmpty()) sized else capped
593
+ // Prefer high-resolution sizes: minimum 1080p (1920x1080 or 1080x1920)
594
+ val minAcceptableArea = 1920 * 1080
595
+ val highResSizes = capped.filter { it.width * it.height >= minAcceptableArea }
596
+ val pool = if (highResSizes.isNotEmpty()) highResSizes else capped
597
+
598
+ // Debug: log aspect ratio diff for each size
599
+ pool.forEach { size ->
600
+ val diff = aspectDiff(size)
601
+ Log.d(TAG, "[SIZE_SELECTION] ${size.width}x${size.height} aspect=${size.width.toDouble()/size.height} diff=$diff")
602
+ }
603
+
594
604
  val bestDiff = pool.minOf { aspectDiff(it) }
605
+ // Use tight tolerance (0.05) to get the best aspect ratio match
595
606
  val close = pool.filter { aspectDiff(it) <= bestDiff + 0.05 }
596
- return close.maxByOrNull { it.width * it.height } ?: pool.maxByOrNull { it.width * it.height }
607
+
608
+ val selected = close.maxByOrNull { it.width * it.height } ?: pool.maxByOrNull { it.width * it.height }
609
+ Log.d(TAG, "[SIZE_SELECTION] Best aspect diff: $bestDiff, selected: ${selected?.width}x${selected?.height}")
610
+ return selected
597
611
  }
598
612
 
599
613
  val matching = capped.filter { aspectDiff(it) <= ANALYSIS_ASPECT_TOLERANCE }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "4.10.0",
3
+ "version": "4.12.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",