react-native-rectangle-doc-scanner 13.5.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,10 +210,10 @@ class DocumentDetector {
|
|
|
210
210
|
|
|
211
211
|
val median = computeMedian(blurredMat)
|
|
212
212
|
val sigma = 0.33
|
|
213
|
-
//
|
|
214
|
-
//
|
|
215
|
-
val cannyLow = max(50.0, (1.0 - sigma) * median).coerceAtLeast(
|
|
216
|
-
val cannyHigh = max(150.0, (1.0 + sigma) * median).coerceAtLeast(
|
|
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)
|
|
217
217
|
|
|
218
218
|
// Apply Canny edge detection with adaptive thresholds for better corner detection.
|
|
219
219
|
Imgproc.Canny(blurredMat, cannyMat, cannyLow, cannyHigh)
|
|
@@ -439,28 +439,15 @@ class DocumentDetector {
|
|
|
439
439
|
return false
|
|
440
440
|
}
|
|
441
441
|
|
|
442
|
-
//
|
|
443
|
-
//
|
|
444
|
-
|
|
445
|
-
// Enhanced validation: Check corner angles (should be close to 90°)
|
|
446
|
-
if (!hasValidCornerAngles(rectangle)) {
|
|
447
|
-
return false
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
// Enhanced validation: Check edge straightness
|
|
451
|
-
if (!hasValidEdgeStraightness(rectangle, srcMat)) {
|
|
452
|
-
return false
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
// Enhanced validation: Check margin from view edges (avoid detecting screen borders)
|
|
456
|
-
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
|
|
457
445
|
if (rectangle.topLeft.x < margin || rectangle.topLeft.y < margin ||
|
|
458
446
|
rectangle.topRight.x > srcMat.cols() - margin || rectangle.topRight.y < margin ||
|
|
459
447
|
rectangle.bottomLeft.x < margin || rectangle.bottomLeft.y > srcMat.rows() - margin ||
|
|
460
448
|
rectangle.bottomRight.x > srcMat.cols() - margin || rectangle.bottomRight.y > srcMat.rows() - margin) {
|
|
461
449
|
return false
|
|
462
450
|
}
|
|
463
|
-
*/
|
|
464
451
|
|
|
465
452
|
return true
|
|
466
453
|
}
|