react-native-rectangle-doc-scanner 7.62.0 → 7.64.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.
|
@@ -355,11 +355,13 @@ class CameraController(
|
|
|
355
355
|
captureSize = chooseBestSize(captureSizes, previewAspect, null, preferClosestAspect = true)
|
|
356
356
|
?: captureSizes?.maxByOrNull { it.width * it.height }
|
|
357
357
|
|
|
358
|
-
val
|
|
358
|
+
val viewAspectNormalized = max(viewAspect, 1.0 / viewAspect)
|
|
359
|
+
val previewAspectNormalized = max(previewAspect, 1.0 / previewAspect)
|
|
360
|
+
val previewDiff = abs(previewAspectNormalized - viewAspectNormalized)
|
|
359
361
|
Log.d(
|
|
360
362
|
TAG,
|
|
361
|
-
"[SIZE_SELECTION] targetAspect=$
|
|
362
|
-
"previewAspect=$
|
|
363
|
+
"[SIZE_SELECTION] targetAspect=$viewAspectNormalized viewAspect=$viewAspectNormalized " +
|
|
364
|
+
"previewAspect=$previewAspectNormalized diff=$previewDiff selected=${previewSize?.width}x${previewSize?.height}"
|
|
363
365
|
)
|
|
364
366
|
|
|
365
367
|
setupImageReaders()
|
|
@@ -662,35 +664,26 @@ class CameraController(
|
|
|
662
664
|
|
|
663
665
|
val rotationDegrees = computeRotationDegrees()
|
|
664
666
|
val displayRotation = displayRotationDegrees()
|
|
665
|
-
Log.d(
|
|
666
|
-
TAG,
|
|
667
|
-
"[TRANSFORM] rotations sensor=$sensorOrientation display=$displayRotation computed=$rotationDegrees view=${viewWidth}x${viewHeight} preview=${preview.width}x${preview.height}"
|
|
668
|
-
)
|
|
669
667
|
|
|
670
|
-
val matrix = Matrix()
|
|
671
668
|
val viewRect = RectF(0f, 0f, viewWidth, viewHeight)
|
|
672
669
|
val centerX = viewRect.centerX()
|
|
673
670
|
val centerY = viewRect.centerY()
|
|
674
671
|
|
|
675
|
-
val
|
|
676
|
-
val
|
|
677
|
-
val
|
|
672
|
+
val appliedRotation = rotationDegrees
|
|
673
|
+
val swap = appliedRotation == 90 || appliedRotation == 270
|
|
674
|
+
val bufferWidth = if (swap) preview.height.toFloat() else preview.width.toFloat()
|
|
675
|
+
val bufferHeight = if (swap) preview.width.toFloat() else preview.height.toFloat()
|
|
678
676
|
val bufferRect = RectF(0f, 0f, bufferWidth, bufferHeight)
|
|
679
677
|
bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY())
|
|
680
678
|
|
|
679
|
+
val matrix = Matrix()
|
|
681
680
|
matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL)
|
|
682
681
|
val scale = max(viewWidth / bufferRect.width(), viewHeight / bufferRect.height())
|
|
683
682
|
matrix.postScale(scale, scale, centerX, centerY)
|
|
684
|
-
if (
|
|
685
|
-
matrix.postRotate(
|
|
683
|
+
if (appliedRotation != 0) {
|
|
684
|
+
matrix.postRotate(appliedRotation.toFloat(), centerX, centerY)
|
|
686
685
|
}
|
|
687
686
|
|
|
688
|
-
previewView.setTransform(matrix)
|
|
689
|
-
latestTransform = Matrix(matrix)
|
|
690
|
-
latestBufferWidth = preview.width
|
|
691
|
-
latestBufferHeight = preview.height
|
|
692
|
-
latestTransformRotation = rotationDegrees
|
|
693
|
-
|
|
694
687
|
val pts = floatArrayOf(
|
|
695
688
|
0f, 0f,
|
|
696
689
|
bufferWidth, 0f,
|
|
@@ -698,6 +691,19 @@ class CameraController(
|
|
|
698
691
|
bufferWidth, bufferHeight
|
|
699
692
|
)
|
|
700
693
|
matrix.mapPoints(pts)
|
|
694
|
+
|
|
695
|
+
Log.d(
|
|
696
|
+
TAG,
|
|
697
|
+
"[TRANSFORM] rotations sensor=$sensorOrientation display=$displayRotation computed=$rotationDegrees applied=$appliedRotation " +
|
|
698
|
+
"view=${viewWidth}x${viewHeight} preview=${preview.width}x${preview.height}"
|
|
699
|
+
)
|
|
700
|
+
|
|
701
|
+
previewView.setTransform(matrix)
|
|
702
|
+
latestTransform = Matrix(matrix)
|
|
703
|
+
latestBufferWidth = preview.width
|
|
704
|
+
latestBufferHeight = preview.height
|
|
705
|
+
latestTransformRotation = appliedRotation
|
|
706
|
+
|
|
701
707
|
Log.d(
|
|
702
708
|
TAG,
|
|
703
709
|
"[TRANSFORM] viewClass=${previewView.javaClass.name} isTextureView=${previewView is TextureView} " +
|
|
@@ -742,7 +748,9 @@ class CameraController(
|
|
|
742
748
|
fun aspectDiff(size: Size): Double {
|
|
743
749
|
val w = size.width.toDouble()
|
|
744
750
|
val h = size.height.toDouble()
|
|
745
|
-
|
|
751
|
+
val aspect = max(w, h) / min(w, h)
|
|
752
|
+
val target = max(targetAspect, 1.0 / targetAspect)
|
|
753
|
+
return abs(aspect - target)
|
|
746
754
|
}
|
|
747
755
|
|
|
748
756
|
if (preferClosestAspect) {
|