react-native-rectangle-doc-scanner 3.205.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,9 +267,16 @@ 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
|
-
Log.d(
|
|
275
|
+
Log.d(
|
|
276
|
+
TAG,
|
|
277
|
+
"[CAMERA2] chooseCamera view=${viewWidth}x${viewHeight} ratio=$targetRatio " +
|
|
278
|
+
"sensorOrientation=$sensorOrientation preview=$previewSize analysis=$analysisSize"
|
|
279
|
+
)
|
|
273
280
|
}
|
|
274
281
|
|
|
275
282
|
private fun openCamera() {
|
|
@@ -320,6 +327,12 @@ class CameraController(
|
|
|
320
327
|
val previewSize = sizes.first ?: return
|
|
321
328
|
val analysisSize = sizes.second ?: previewSize
|
|
322
329
|
|
|
330
|
+
Log.d(
|
|
331
|
+
TAG,
|
|
332
|
+
"[CAMERA2] createPreviewSession view=${previewView.width}x${previewView.height} " +
|
|
333
|
+
"preview=${previewSize.width}x${previewSize.height} analysis=${analysisSize.width}x${analysisSize.height}"
|
|
334
|
+
)
|
|
335
|
+
|
|
323
336
|
texture.setDefaultBufferSize(previewSize.width, previewSize.height)
|
|
324
337
|
val previewSurface = Surface(texture)
|
|
325
338
|
|
|
@@ -396,6 +409,11 @@ class CameraController(
|
|
|
396
409
|
analysisSize = newAnalysis
|
|
397
410
|
}
|
|
398
411
|
|
|
412
|
+
Log.d(
|
|
413
|
+
TAG,
|
|
414
|
+
"[CAMERA2] ensurePreviewSizes view=${viewWidth}x${viewHeight} ratio=$targetRatio " +
|
|
415
|
+
"preview=${previewSize?.width}x${previewSize?.height} analysis=${analysisSize?.width}x${analysisSize?.height}"
|
|
416
|
+
)
|
|
399
417
|
return Pair(previewSize, analysisSize)
|
|
400
418
|
}
|
|
401
419
|
|
|
@@ -439,6 +457,11 @@ class CameraController(
|
|
|
439
457
|
matrix.postTranslate(viewWidth / 2f, viewHeight / 2f)
|
|
440
458
|
|
|
441
459
|
previewView.setTransform(matrix)
|
|
460
|
+
Log.d(
|
|
461
|
+
TAG,
|
|
462
|
+
"[CAMERA2] transform view=${viewWidth}x${viewHeight} buffer=${bufferWidth}x${bufferHeight} " +
|
|
463
|
+
"rotated=${rotatedBufferWidth}x${rotatedBufferHeight} rotation=$rotationDegrees scale=$scale"
|
|
464
|
+
)
|
|
442
465
|
}
|
|
443
466
|
|
|
444
467
|
private fun ensureMatchParent() {
|
|
@@ -462,6 +485,7 @@ class CameraController(
|
|
|
462
485
|
layoutParams.gravity = Gravity.CENTER
|
|
463
486
|
previewView.layoutParams = layoutParams
|
|
464
487
|
}
|
|
488
|
+
Log.d(TAG, "[CAMERA2] parent=${parentWidth}x${parentHeight} previewView=${previewView.width}x${previewView.height}")
|
|
465
489
|
}
|
|
466
490
|
|
|
467
491
|
private fun handleImage(image: Image) {
|
|
@@ -638,6 +662,48 @@ class CameraController(
|
|
|
638
662
|
return sorted.first()
|
|
639
663
|
}
|
|
640
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
|
+
|
|
641
707
|
private fun startBackgroundThread() {
|
|
642
708
|
if (backgroundThread != null) {
|
|
643
709
|
return
|
package/package.json
CHANGED