react-native-rectangle-doc-scanner 10.33.0 → 10.34.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,22 @@ class CameraController(
|
|
|
457
457
|
else -> 0
|
|
458
458
|
}
|
|
459
459
|
|
|
460
|
-
//
|
|
461
|
-
//
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
460
|
+
// The TextureView transform handles display rotation, but the coordinates coming from
|
|
461
|
+
// ImageAnalysis are in the sensor's native orientation. We need to map those sensor-space
|
|
462
|
+
// coordinates to the final display orientation that the user sees.
|
|
463
|
+
|
|
464
|
+
// For coordinate mapping, we need to account for how the image was rotated by the TextureView.
|
|
465
|
+
// The TextureView applies: displayRotation + tabletFix
|
|
466
|
+
val tabletUpsideDownFix = if (sensorOrientation == 0 && displayRotationDegrees == 90) 180 else 0
|
|
467
|
+
val textureViewRotation = ((displayRotationDegrees + tabletUpsideDownFix) % 360).toFloat()
|
|
468
|
+
|
|
469
|
+
// But the image analysis coordinates are in sensor orientation. So we need to apply
|
|
470
|
+
// the SAME rotation that the TextureView applies to align coordinates with display.
|
|
471
|
+
val rotationDegrees = textureViewRotation
|
|
470
472
|
|
|
471
473
|
Log.d(TAG, "[MAPPING] Image: ${imageWidth}x${imageHeight}, Sensor: ${sensorOrientation}°, " +
|
|
472
|
-
"Display: ${displayRotationDegrees}°,
|
|
474
|
+
"Display: ${displayRotationDegrees}°, TextureView rotation: ${textureViewRotation}°, " +
|
|
475
|
+
"Coordinate rotation: ${rotationDegrees}°")
|
|
473
476
|
|
|
474
477
|
// Apply rotation to coordinates to match display orientation
|
|
475
478
|
fun rotatePoint(point: org.opencv.core.Point): org.opencv.core.Point {
|
|
@@ -571,17 +574,10 @@ class CameraController(
|
|
|
571
574
|
val centerY = viewHeight / 2f
|
|
572
575
|
|
|
573
576
|
// 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
|
-
}
|
|
577
|
+
// CameraX accounts for sensor orientation via targetRotation. Some tablets with landscape
|
|
578
|
+
// sensors report Display 90 in portrait but render upside down; add a 180° fix for that case.
|
|
579
|
+
val tabletUpsideDownFix = if (sensorOrientation == 0 && displayRotationDegrees == 90) 180 else 0
|
|
580
|
+
val rotationDegrees = ((displayRotationDegrees + tabletUpsideDownFix) % 360).toFloat()
|
|
585
581
|
|
|
586
582
|
Log.d(TAG, "[TRANSFORM] Applying rotation: ${rotationDegrees}°")
|
|
587
583
|
|
package/package.json
CHANGED