react-native-rectangle-doc-scanner 4.10.0 → 4.11.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,12 +590,16 @@ 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
+
594
598
  val bestDiff = pool.minOf { aspectDiff(it) }
595
- val close = pool.filter { aspectDiff(it) <= bestDiff + 0.05 }
599
+ // Allow slightly more tolerance for aspect ratio (0.15 instead of 0.05) to find better matches
600
+ val close = pool.filter { aspectDiff(it) <= bestDiff + 0.15 }
601
+
602
+ // Return the highest resolution among good aspect ratio matches
596
603
  return close.maxByOrNull { it.width * it.height } ?: pool.maxByOrNull { it.width * it.height }
597
604
  }
598
605
 
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.11.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",