react-native-rectangle-doc-scanner 13.8.0 → 13.9.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.
|
@@ -262,10 +262,10 @@ class DocumentDetector {
|
|
|
262
262
|
var largestRectangle: Rectangle? = null
|
|
263
263
|
var bestScore = 0.0
|
|
264
264
|
val imageArea = (srcMat.rows() * srcMat.cols()).toDouble()
|
|
265
|
-
// Min:
|
|
266
|
-
// Max:
|
|
267
|
-
val minArea = max(350.0, imageArea * 0.
|
|
268
|
-
val maxArea = imageArea * 0.
|
|
265
|
+
// Min: 5% of image (documents should be reasonably sized)
|
|
266
|
+
// Max: 70% of image (avoid detecting screen borders)
|
|
267
|
+
val minArea = max(350.0, imageArea * 0.05)
|
|
268
|
+
val maxArea = imageArea * 0.70
|
|
269
269
|
|
|
270
270
|
debugStats.contours = contours.size
|
|
271
271
|
|
|
@@ -439,8 +439,10 @@ class DocumentDetector {
|
|
|
439
439
|
if (width < minEdge || height < minEdge) {
|
|
440
440
|
return false
|
|
441
441
|
}
|
|
442
|
+
// Stricter aspect ratio for typical documents (business cards, A4, etc.)
|
|
443
|
+
// Business cards: ~1.6, A4: ~0.7, allow range 0.5-2.2
|
|
442
444
|
val aspect = if (height > 0) width / height else 0.0
|
|
443
|
-
if (aspect < 0.
|
|
445
|
+
if (aspect < 0.5 || aspect > 2.2) {
|
|
444
446
|
return false
|
|
445
447
|
}
|
|
446
448
|
|