react-native-rectangle-doc-scanner 13.4.0 → 13.6.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.
|
@@ -210,8 +210,10 @@ class DocumentDetector {
|
|
|
210
210
|
|
|
211
211
|
val median = computeMedian(blurredMat)
|
|
212
212
|
val sigma = 0.33
|
|
213
|
-
|
|
214
|
-
|
|
213
|
+
// Balanced thresholds for high-res (1280x960)
|
|
214
|
+
// Lower than before to detect document edges, but higher than default to reduce noise
|
|
215
|
+
val cannyLow = max(50.0, (1.0 - sigma) * median).coerceAtLeast(60.0)
|
|
216
|
+
val cannyHigh = max(150.0, (1.0 + sigma) * median).coerceAtLeast(120.0)
|
|
215
217
|
|
|
216
218
|
// Apply Canny edge detection with adaptive thresholds for better corner detection.
|
|
217
219
|
Imgproc.Canny(blurredMat, cannyMat, cannyLow, cannyHigh)
|
|
@@ -437,21 +439,9 @@ class DocumentDetector {
|
|
|
437
439
|
return false
|
|
438
440
|
}
|
|
439
441
|
|
|
440
|
-
//
|
|
441
|
-
//
|
|
442
|
-
|
|
443
|
-
return false
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
// Enhanced validation: Check edge straightness
|
|
447
|
-
// Made more lenient: 20° tolerance (was 15°)
|
|
448
|
-
if (!hasValidEdgeStraightness(rectangle, srcMat)) {
|
|
449
|
-
return false
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
// Enhanced validation: Check margin from view edges (avoid detecting screen borders)
|
|
453
|
-
// Made more lenient: 3% margin (was 5%)
|
|
454
|
-
val margin = minDim * 0.03
|
|
442
|
+
// Check margin from view edges to avoid detecting screen borders
|
|
443
|
+
// Use smaller margin (2%) to be less restrictive
|
|
444
|
+
val margin = minDim * 0.02
|
|
455
445
|
if (rectangle.topLeft.x < margin || rectangle.topLeft.y < margin ||
|
|
456
446
|
rectangle.topRight.x > srcMat.cols() - margin || rectangle.topRight.y < margin ||
|
|
457
447
|
rectangle.bottomLeft.x < margin || rectangle.bottomLeft.y > srcMat.rows() - margin ||
|