react-native-rectangle-doc-scanner 7.63.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.
|
@@ -669,56 +669,28 @@ class CameraController(
|
|
|
669
669
|
val centerX = viewRect.centerX()
|
|
670
670
|
val centerY = viewRect.centerY()
|
|
671
671
|
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY())
|
|
679
|
-
|
|
680
|
-
candidate.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL)
|
|
681
|
-
val scale = max(viewWidth / bufferRect.width(), viewHeight / bufferRect.height())
|
|
682
|
-
candidate.postScale(scale, scale, centerX, centerY)
|
|
683
|
-
if (appliedRotation != 0) {
|
|
684
|
-
candidate.postRotate(appliedRotation.toFloat(), centerX, centerY)
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
val pts = floatArrayOf(
|
|
688
|
-
0f, 0f,
|
|
689
|
-
bufferWidth, 0f,
|
|
690
|
-
0f, bufferHeight,
|
|
691
|
-
bufferWidth, bufferHeight
|
|
692
|
-
)
|
|
693
|
-
candidate.mapPoints(pts)
|
|
694
|
-
return Pair(candidate, pts)
|
|
695
|
-
}
|
|
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()
|
|
676
|
+
val bufferRect = RectF(0f, 0f, bufferWidth, bufferHeight)
|
|
677
|
+
bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY())
|
|
696
678
|
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
val left = max(viewRect.left, minX)
|
|
704
|
-
val top = max(viewRect.top, minY)
|
|
705
|
-
val right = min(viewRect.right, maxX)
|
|
706
|
-
val bottom = min(viewRect.bottom, maxY)
|
|
707
|
-
val intersection = if (right > left && bottom > top) (right - left) * (bottom - top) else 0f
|
|
708
|
-
val viewArea = viewRect.width() * viewRect.height()
|
|
709
|
-
return if (viewArea > 0f) intersection / viewArea else 0f
|
|
679
|
+
val matrix = Matrix()
|
|
680
|
+
matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL)
|
|
681
|
+
val scale = max(viewWidth / bufferRect.width(), viewHeight / bufferRect.height())
|
|
682
|
+
matrix.postScale(scale, scale, centerX, centerY)
|
|
683
|
+
if (appliedRotation != 0) {
|
|
684
|
+
matrix.postRotate(appliedRotation.toFloat(), centerX, centerY)
|
|
710
685
|
}
|
|
711
686
|
|
|
712
|
-
val
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
val appliedRotation = if (scoreNeg > scorePos) negative else positive
|
|
720
|
-
val appliedMatrix = if (appliedRotation == positive) matrixPos else matrixNeg
|
|
721
|
-
val appliedPts = if (appliedRotation == positive) ptsPos else ptsNeg
|
|
687
|
+
val pts = floatArrayOf(
|
|
688
|
+
0f, 0f,
|
|
689
|
+
bufferWidth, 0f,
|
|
690
|
+
0f, bufferHeight,
|
|
691
|
+
bufferWidth, bufferHeight
|
|
692
|
+
)
|
|
693
|
+
matrix.mapPoints(pts)
|
|
722
694
|
|
|
723
695
|
Log.d(
|
|
724
696
|
TAG,
|
|
@@ -726,17 +698,17 @@ class CameraController(
|
|
|
726
698
|
"view=${viewWidth}x${viewHeight} preview=${preview.width}x${preview.height}"
|
|
727
699
|
)
|
|
728
700
|
|
|
729
|
-
previewView.setTransform(
|
|
730
|
-
latestTransform = Matrix(
|
|
701
|
+
previewView.setTransform(matrix)
|
|
702
|
+
latestTransform = Matrix(matrix)
|
|
731
703
|
latestBufferWidth = preview.width
|
|
732
704
|
latestBufferHeight = preview.height
|
|
733
705
|
latestTransformRotation = appliedRotation
|
|
734
706
|
|
|
735
707
|
Log.d(
|
|
736
708
|
TAG,
|
|
737
|
-
"[TRANSFORM]
|
|
738
|
-
"
|
|
739
|
-
"pts=[${
|
|
709
|
+
"[TRANSFORM] viewClass=${previewView.javaClass.name} isTextureView=${previewView is TextureView} " +
|
|
710
|
+
"buffer=${bufferWidth}x${bufferHeight} scale=$scale center=${centerX}x${centerY} matrix=$matrix " +
|
|
711
|
+
"pts=[${pts[0]},${pts[1]} ${pts[2]},${pts[3]} ${pts[4]},${pts[5]} ${pts[6]},${pts[7]}]"
|
|
740
712
|
)
|
|
741
713
|
val recomputed = computeRotationDegrees()
|
|
742
714
|
if (rotationDegrees != recomputed) {
|