react-native-rectangle-doc-scanner 10.40.0 → 10.42.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.
|
@@ -185,7 +185,7 @@ class CameraController(
|
|
|
185
185
|
// ImageAnalysis UseCase for document detection
|
|
186
186
|
imageAnalyzer = ImageAnalysis.Builder()
|
|
187
187
|
.setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
|
|
188
|
-
.
|
|
188
|
+
.setTargetResolution(android.util.Size(1280, 960))
|
|
189
189
|
.setTargetRotation(targetRotation) // Match preview rotation
|
|
190
190
|
.build()
|
|
191
191
|
.also {
|
|
@@ -495,6 +495,7 @@ class CameraController(
|
|
|
495
495
|
return
|
|
496
496
|
}
|
|
497
497
|
|
|
498
|
+
val sensorOrientation = getCameraSensorOrientation()
|
|
498
499
|
val displayRotationDegrees = when (textureView.display?.rotation ?: Surface.ROTATION_0) {
|
|
499
500
|
Surface.ROTATION_0 -> 0
|
|
500
501
|
Surface.ROTATION_90 -> 90
|
|
@@ -506,16 +507,33 @@ class CameraController(
|
|
|
506
507
|
Log.d(
|
|
507
508
|
TAG,
|
|
508
509
|
"[TRANSFORM] View: ${viewWidth}x${viewHeight}, Buffer: ${bufferWidth}x${bufferHeight}, " +
|
|
509
|
-
"Display: ${displayRotationDegrees}°"
|
|
510
|
+
"Sensor: ${sensorOrientation}°, Display: ${displayRotationDegrees}°"
|
|
510
511
|
)
|
|
511
512
|
|
|
512
513
|
val matrix = android.graphics.Matrix()
|
|
513
514
|
val centerX = viewWidth / 2f
|
|
514
515
|
val centerY = viewHeight / 2f
|
|
515
516
|
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
517
|
+
val rotationDegrees = if (sensorOrientation == 0) {
|
|
518
|
+
displayRotationDegrees.toFloat()
|
|
519
|
+
} else {
|
|
520
|
+
sensorOrientation.toFloat()
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
if (rotationDegrees != 0f) {
|
|
524
|
+
matrix.postRotate(rotationDegrees, centerX, centerY)
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
val rotatedBufferWidth = if (rotationDegrees == 90f || rotationDegrees == 270f) {
|
|
528
|
+
bufferHeight
|
|
529
|
+
} else {
|
|
530
|
+
bufferWidth
|
|
531
|
+
}
|
|
532
|
+
val rotatedBufferHeight = if (rotationDegrees == 90f || rotationDegrees == 270f) {
|
|
533
|
+
bufferWidth
|
|
534
|
+
} else {
|
|
535
|
+
bufferHeight
|
|
536
|
+
}
|
|
519
537
|
|
|
520
538
|
// Scale to fill the view while maintaining aspect ratio (center-crop).
|
|
521
539
|
val scaleX = viewWidth.toFloat() / rotatedBufferWidth.toFloat()
|
package/package.json
CHANGED