react-native-rectangle-doc-scanner 13.7.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.
package/android/src/camera2/kotlin/com/reactnativerectangledocscanner/DocumentScannerView.kt
CHANGED
|
@@ -260,11 +260,12 @@ class DocumentScannerView(context: ThemedReactContext) : FrameLayout(context), L
|
|
|
260
260
|
}
|
|
261
261
|
val smoothedRectangleOnScreen = smoothRectangle(rectangleOnScreen, previewWidth, previewHeight)
|
|
262
262
|
lastRectangleOnScreen = smoothedRectangleOnScreen
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
263
|
+
// Quality evaluation disabled - relying on detection filters (area, rectangularity)
|
|
264
|
+
// The evaluateRectangleQualityInView function was too strict and rejecting valid documents
|
|
265
|
+
val quality = if (smoothedRectangleOnScreen != null) {
|
|
266
|
+
RectangleQuality.GOOD
|
|
267
|
+
} else {
|
|
268
|
+
RectangleQuality.TOO_FAR
|
|
268
269
|
}
|
|
269
270
|
|
|
270
271
|
post {
|
|
@@ -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
|
|