react-native-rectangle-doc-scanner 10.49.0 → 10.50.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.
|
@@ -506,28 +506,25 @@ class DocumentDetector {
|
|
|
506
506
|
return RectangleQuality.TOO_FAR
|
|
507
507
|
}
|
|
508
508
|
|
|
509
|
-
// Check angle quality
|
|
510
|
-
//
|
|
511
|
-
val
|
|
512
|
-
val
|
|
513
|
-
val
|
|
514
|
-
val
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
val
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
bottomYDiff > bottomAngleThreshold ||
|
|
524
|
-
leftXDiff > leftAngleThreshold ||
|
|
525
|
-
rightXDiff > rightAngleThreshold) {
|
|
509
|
+
// Check angle quality using angle ratio instead of absolute difference
|
|
510
|
+
// Edges should be roughly horizontal/vertical (not too skewed)
|
|
511
|
+
val topAngleRatio = if (topEdgeLength > 0) abs(rectangle.topRight.y - rectangle.topLeft.y) / topEdgeLength else 0.0
|
|
512
|
+
val bottomAngleRatio = if (bottomEdgeLength > 0) abs(rectangle.bottomLeft.y - rectangle.bottomRight.y) / bottomEdgeLength else 0.0
|
|
513
|
+
val leftAngleRatio = if (leftEdgeLength > 0) abs(rectangle.topLeft.x - rectangle.bottomLeft.x) / leftEdgeLength else 0.0
|
|
514
|
+
val rightAngleRatio = if (rightEdgeLength > 0) abs(rectangle.topRight.x - rectangle.bottomRight.x) / rightEdgeLength else 0.0
|
|
515
|
+
|
|
516
|
+
// Allow up to 30% skew (sin(~17°) ≈ 0.3)
|
|
517
|
+
val maxSkewRatio = 0.3
|
|
518
|
+
|
|
519
|
+
if (topAngleRatio > maxSkewRatio ||
|
|
520
|
+
bottomAngleRatio > maxSkewRatio ||
|
|
521
|
+
leftAngleRatio > maxSkewRatio ||
|
|
522
|
+
rightAngleRatio > maxSkewRatio) {
|
|
526
523
|
if (BuildConfig.DEBUG) {
|
|
527
|
-
Log.d(TAG, "[QUALITY] BAD_ANGLE (skew):
|
|
528
|
-
"
|
|
529
|
-
"
|
|
530
|
-
"
|
|
524
|
+
Log.d(TAG, "[QUALITY] BAD_ANGLE (skew): top=${String.format("%.2f", topAngleRatio)}, " +
|
|
525
|
+
"bottom=${String.format("%.2f", bottomAngleRatio)}, " +
|
|
526
|
+
"left=${String.format("%.2f", leftAngleRatio)}, " +
|
|
527
|
+
"right=${String.format("%.2f", rightAngleRatio)} > $maxSkewRatio")
|
|
531
528
|
}
|
|
532
529
|
return RectangleQuality.BAD_ANGLE
|
|
533
530
|
}
|
package/package.json
CHANGED