react-native-rectangle-doc-scanner 10.33.0 → 10.35.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.
|
@@ -457,19 +457,26 @@ class CameraController(
|
|
|
457
457
|
else -> 0
|
|
458
458
|
}
|
|
459
459
|
|
|
460
|
-
//
|
|
461
|
-
//
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
460
|
+
// The coordinates coming from ImageAnalysis are in sensor's native orientation.
|
|
461
|
+
// For a 90° sensor (phones in portrait), the camera buffer is landscape but coordinates
|
|
462
|
+
// are in sensor space. We need to rotate coordinates to match the display orientation.
|
|
463
|
+
|
|
464
|
+
// The TextureView rotation for display
|
|
465
|
+
val tabletUpsideDownFix = if (sensorOrientation == 0 && displayRotationDegrees == 90) 180 else 0
|
|
466
|
+
val textureViewRotation = ((displayRotationDegrees + tabletUpsideDownFix) % 360).toFloat()
|
|
467
|
+
|
|
468
|
+
// For coordinate mapping: we need to account for BOTH sensor orientation AND display rotation
|
|
469
|
+
// - Sensor 90° + Display 0°: Coordinates are in landscape sensor space, need 90° rotation to portrait
|
|
470
|
+
// - Sensor 0° + Display 90°: Coordinates are in portrait, need 270° rotation (display + fix)
|
|
471
|
+
val rotationDegrees = if (sensorOrientation == 90 && displayRotationDegrees == 0) {
|
|
472
|
+
90f // Rotate coordinates 90° to match portrait display
|
|
473
|
+
} else {
|
|
474
|
+
textureViewRotation // Use TextureView rotation
|
|
469
475
|
}
|
|
470
476
|
|
|
471
477
|
Log.d(TAG, "[MAPPING] Image: ${imageWidth}x${imageHeight}, Sensor: ${sensorOrientation}°, " +
|
|
472
|
-
"Display: ${displayRotationDegrees}°,
|
|
478
|
+
"Display: ${displayRotationDegrees}°, TextureView rotation: ${textureViewRotation}°, " +
|
|
479
|
+
"Coordinate rotation: ${rotationDegrees}°")
|
|
473
480
|
|
|
474
481
|
// Apply rotation to coordinates to match display orientation
|
|
475
482
|
fun rotatePoint(point: org.opencv.core.Point): org.opencv.core.Point {
|
|
@@ -571,17 +578,10 @@ class CameraController(
|
|
|
571
578
|
val centerY = viewHeight / 2f
|
|
572
579
|
|
|
573
580
|
// Calculate rotation from buffer to display coordinates.
|
|
574
|
-
//
|
|
575
|
-
//
|
|
576
|
-
|
|
577
|
-
val rotationDegrees =
|
|
578
|
-
// Tablet with landscape sensor in portrait: add 180° fix for upside-down
|
|
579
|
-
sensorOrientation == 0 && displayRotationDegrees == 90 -> 270f
|
|
580
|
-
// Phone with 90° sensor in portrait: rotate 90° to match
|
|
581
|
-
sensorOrientation == 90 && displayRotationDegrees == 0 -> 90f
|
|
582
|
-
// Default: use display rotation
|
|
583
|
-
else -> displayRotationDegrees.toFloat()
|
|
584
|
-
}
|
|
581
|
+
// CameraX accounts for sensor orientation via targetRotation. Some tablets with landscape
|
|
582
|
+
// sensors report Display 90 in portrait but render upside down; add a 180° fix for that case.
|
|
583
|
+
val tabletUpsideDownFix = if (sensorOrientation == 0 && displayRotationDegrees == 90) 180 else 0
|
|
584
|
+
val rotationDegrees = ((displayRotationDegrees + tabletUpsideDownFix) % 360).toFloat()
|
|
585
585
|
|
|
586
586
|
Log.d(TAG, "[TRANSFORM] Applying rotation: ${rotationDegrees}°")
|
|
587
587
|
|
package/package.json
CHANGED