react-native-rectangle-doc-scanner 11.2.0 → 11.3.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.
|
@@ -280,10 +280,11 @@ class CameraController(
|
|
|
280
280
|
}
|
|
281
281
|
|
|
282
282
|
// Use the same rotation logic as updateTextureViewTransform
|
|
283
|
+
val tabletUpsideDownFix = if (sensorOrientation == 0 && displayRotationDegrees == 90) 180 else 0
|
|
283
284
|
val effectiveRotation = if (sensorOrientation == 0) {
|
|
284
|
-
displayRotationDegrees
|
|
285
|
+
(displayRotationDegrees + tabletUpsideDownFix) % 360
|
|
285
286
|
} else {
|
|
286
|
-
sensorOrientation
|
|
287
|
+
sensorOrientation
|
|
287
288
|
}
|
|
288
289
|
|
|
289
290
|
Log.d(TAG, "[ANALYZE] Sensor: $sensorOrientation°, Display: $displayRotationDegrees°, Effective: $effectiveRotation°")
|
|
@@ -259,7 +259,7 @@ class DocumentDetector {
|
|
|
259
259
|
|
|
260
260
|
var largestRectangle: Rectangle? = null
|
|
261
261
|
var bestScore = 0.0
|
|
262
|
-
val minArea = max(
|
|
262
|
+
val minArea = max(350.0, (srcMat.rows() * srcMat.cols()) * 0.0005)
|
|
263
263
|
|
|
264
264
|
debugStats.contours = contours.size
|
|
265
265
|
|
|
@@ -289,7 +289,7 @@ class DocumentDetector {
|
|
|
289
289
|
val rect = Imgproc.minAreaRect(MatOfPoint2f(*points))
|
|
290
290
|
val rectArea = rect.size.area()
|
|
291
291
|
val rectangularity = if (rectArea > 1.0) contourArea / rectArea else 0.0
|
|
292
|
-
if (rectangularity >= 0.
|
|
292
|
+
if (rectangularity >= 0.5 && isCandidateValid(ordered, srcMat)) {
|
|
293
293
|
debugStats.candidates += 1
|
|
294
294
|
val score = contourArea * rectangularity
|
|
295
295
|
if (score > bestScore) {
|
|
@@ -313,7 +313,7 @@ class DocumentDetector {
|
|
|
313
313
|
val rectArea = rotated.size.area()
|
|
314
314
|
if (rectArea > 1.0) {
|
|
315
315
|
val rectangularity = contourArea / rectArea
|
|
316
|
-
if (rectangularity >= 0.
|
|
316
|
+
if (rectangularity >= 0.5) {
|
|
317
317
|
debugStats.candidates += 1
|
|
318
318
|
val boxPoints = Array(4) { Point() }
|
|
319
319
|
rotated.points(boxPoints)
|
|
@@ -497,16 +497,16 @@ class DocumentDetector {
|
|
|
497
497
|
val rectHeight = max(leftEdgeLength, rightEdgeLength)
|
|
498
498
|
val rectArea = rectWidth * rectHeight
|
|
499
499
|
|
|
500
|
-
// Check if rectangle is too small (less than
|
|
501
|
-
// or too large (more than
|
|
500
|
+
// Check if rectangle is too small (less than 6% of view area)
|
|
501
|
+
// or too large (more than 95% - likely detecting screen instead of document)
|
|
502
502
|
val areaRatio = rectArea / viewArea
|
|
503
|
-
if (areaRatio < 0.
|
|
503
|
+
if (areaRatio < 0.06) {
|
|
504
504
|
if (BuildConfig.DEBUG) {
|
|
505
505
|
Log.d(TAG, "[QUALITY] TOO_FAR (small): area=${String.format("%.1f", rectArea)}, ratio=${String.format("%.2f", areaRatio)}")
|
|
506
506
|
}
|
|
507
507
|
return RectangleQuality.TOO_FAR
|
|
508
508
|
}
|
|
509
|
-
if (areaRatio > 0.
|
|
509
|
+
if (areaRatio > 0.95) {
|
|
510
510
|
if (BuildConfig.DEBUG) {
|
|
511
511
|
Log.d(TAG, "[QUALITY] TOO_FAR (large): area=${String.format("%.1f", rectArea)}, ratio=${String.format("%.2f", areaRatio)} - likely detecting screen")
|
|
512
512
|
}
|