react-native-rectangle-doc-scanner 3.206.0 → 3.207.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.
|
@@ -267,6 +267,9 @@ class CameraController(
|
|
|
267
267
|
null
|
|
268
268
|
}
|
|
269
269
|
|
|
270
|
+
logSizeCandidates("preview", previewChoices, targetRatio)
|
|
271
|
+
logSizeCandidates("analysis", analysisChoices, targetRatio)
|
|
272
|
+
|
|
270
273
|
previewSize = choosePreviewSize(previewChoices, targetRatio)
|
|
271
274
|
analysisSize = chooseAnalysisSize(analysisChoices, targetRatio)
|
|
272
275
|
Log.d(
|
|
@@ -659,6 +662,48 @@ class CameraController(
|
|
|
659
662
|
return sorted.first()
|
|
660
663
|
}
|
|
661
664
|
|
|
665
|
+
private fun logSizeCandidates(
|
|
666
|
+
label: String,
|
|
667
|
+
choices: Array<Size>,
|
|
668
|
+
targetRatio: Float?
|
|
669
|
+
) {
|
|
670
|
+
if (choices.isEmpty()) {
|
|
671
|
+
Log.d(TAG, "[CAMERA2] $label sizes: none")
|
|
672
|
+
return
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
if (targetRatio == null) {
|
|
676
|
+
Log.d(TAG, "[CAMERA2] $label sizes: ${choices.size}, targetRatio=null")
|
|
677
|
+
return
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
val normalizedTarget = targetRatio
|
|
681
|
+
val sorted = choices.sortedWith(
|
|
682
|
+
compareBy<Size> { size ->
|
|
683
|
+
val ratio = if (normalizedTarget < 1f) {
|
|
684
|
+
size.height.toFloat() / size.width.toFloat()
|
|
685
|
+
} else {
|
|
686
|
+
size.width.toFloat() / size.height.toFloat()
|
|
687
|
+
}
|
|
688
|
+
kotlin.math.abs(ratio - normalizedTarget)
|
|
689
|
+
}.thenByDescending { size ->
|
|
690
|
+
size.width * size.height
|
|
691
|
+
}
|
|
692
|
+
)
|
|
693
|
+
|
|
694
|
+
val top = sorted.take(5).joinToString { size ->
|
|
695
|
+
val ratio = if (normalizedTarget < 1f) {
|
|
696
|
+
size.height.toFloat() / size.width.toFloat()
|
|
697
|
+
} else {
|
|
698
|
+
size.width.toFloat() / size.height.toFloat()
|
|
699
|
+
}
|
|
700
|
+
val diff = kotlin.math.abs(ratio - normalizedTarget)
|
|
701
|
+
"${size.width}x${size.height}(r=${"%.3f".format(ratio)},d=${"%.3f".format(diff)})"
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
Log.d(TAG, "[CAMERA2] $label sizes: ${choices.size}, target=${"%.3f".format(normalizedTarget)} top=$top")
|
|
705
|
+
}
|
|
706
|
+
|
|
662
707
|
private fun startBackgroundThread() {
|
|
663
708
|
if (backgroundThread != null) {
|
|
664
709
|
return
|
package/package.json
CHANGED