react-native-rectangle-doc-scanner 11.2.0 → 11.3.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.
@@ -280,10 +280,11 @@ class CameraController(
280
280
  }
281
281
 
282
282
  // Use the same rotation logic as updateTextureViewTransform
283
+ val tabletUpsideDownFix = if (sensorOrientation == 0 && displayRotationDegrees == 90) 180 else 0
283
284
  val effectiveRotation = if (sensorOrientation == 0) {
284
- displayRotationDegrees // Tablet: use display rotation (90°)
285
+ (displayRotationDegrees + tabletUpsideDownFix) % 360
285
286
  } else {
286
- sensorOrientation // Phone: use sensor orientation (90°)
287
+ sensorOrientation
287
288
  }
288
289
 
289
290
  Log.d(TAG, "[ANALYZE] Sensor: $sensorOrientation°, Display: $displayRotationDegrees°, Effective: $effectiveRotation°")
@@ -259,7 +259,7 @@ class DocumentDetector {
259
259
 
260
260
  var largestRectangle: Rectangle? = null
261
261
  var bestScore = 0.0
262
- val minArea = max(450.0, (srcMat.rows() * srcMat.cols()) * 0.0007)
262
+ val minArea = max(350.0, (srcMat.rows() * srcMat.cols()) * 0.0005)
263
263
 
264
264
  debugStats.contours = contours.size
265
265
 
@@ -289,7 +289,7 @@ class DocumentDetector {
289
289
  val rect = Imgproc.minAreaRect(MatOfPoint2f(*points))
290
290
  val rectArea = rect.size.area()
291
291
  val rectangularity = if (rectArea > 1.0) contourArea / rectArea else 0.0
292
- if (rectangularity >= 0.6 && isCandidateValid(ordered, srcMat)) {
292
+ if (rectangularity >= 0.5 && isCandidateValid(ordered, srcMat)) {
293
293
  debugStats.candidates += 1
294
294
  val score = contourArea * rectangularity
295
295
  if (score > bestScore) {
@@ -313,7 +313,7 @@ class DocumentDetector {
313
313
  val rectArea = rotated.size.area()
314
314
  if (rectArea > 1.0) {
315
315
  val rectangularity = contourArea / rectArea
316
- if (rectangularity >= 0.6) {
316
+ if (rectangularity >= 0.5) {
317
317
  debugStats.candidates += 1
318
318
  val boxPoints = Array(4) { Point() }
319
319
  rotated.points(boxPoints)
@@ -497,16 +497,16 @@ class DocumentDetector {
497
497
  val rectHeight = max(leftEdgeLength, rightEdgeLength)
498
498
  val rectArea = rectWidth * rectHeight
499
499
 
500
- // Check if rectangle is too small (less than 15% of view area)
501
- // or too large (more than 85% - likely detecting screen instead of document)
500
+ // Check if rectangle is too small (less than 6% of view area)
501
+ // or too large (more than 95% - likely detecting screen instead of document)
502
502
  val areaRatio = rectArea / viewArea
503
- if (areaRatio < 0.15) {
503
+ if (areaRatio < 0.06) {
504
504
  if (BuildConfig.DEBUG) {
505
505
  Log.d(TAG, "[QUALITY] TOO_FAR (small): area=${String.format("%.1f", rectArea)}, ratio=${String.format("%.2f", areaRatio)}")
506
506
  }
507
507
  return RectangleQuality.TOO_FAR
508
508
  }
509
- if (areaRatio > 0.85) {
509
+ if (areaRatio > 0.95) {
510
510
  if (BuildConfig.DEBUG) {
511
511
  Log.d(TAG, "[QUALITY] TOO_FAR (large): area=${String.format("%.1f", rectArea)}, ratio=${String.format("%.2f", areaRatio)} - likely detecting screen")
512
512
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "11.2.0",
3
+ "version": "11.3.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",