react-native-rectangle-doc-scanner 3.251.0 → 4.1.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.
|
@@ -580,7 +580,7 @@ class CameraController(
|
|
|
580
580
|
val uprightWidth = if (rotationDegrees == 90 || rotationDegrees == 270) imageHeight else imageWidth
|
|
581
581
|
val uprightHeight = if (rotationDegrees == 90 || rotationDegrees == 270) imageWidth else imageHeight
|
|
582
582
|
val openCvRect = if (mlBox != null) {
|
|
583
|
-
val expanded = expandRect(mlBox, uprightWidth, uprightHeight, 0.
|
|
583
|
+
val expanded = expandRect(mlBox, uprightWidth, uprightHeight, 0.1f)
|
|
584
584
|
DocumentDetector.detectRectangleInYUVWithRoi(
|
|
585
585
|
nv21,
|
|
586
586
|
imageWidth,
|
|
@@ -592,7 +592,7 @@ class CameraController(
|
|
|
592
592
|
DocumentDetector.detectRectangleInYUV(nv21, imageWidth, imageHeight, rotationDegrees)
|
|
593
593
|
}
|
|
594
594
|
if (openCvRect == null) {
|
|
595
|
-
mlBox?.let { boxToRectangle(it) }
|
|
595
|
+
mlBox?.let { boxToRectangle(insetBox(it, 0.85f)) }
|
|
596
596
|
} else {
|
|
597
597
|
openCvRect
|
|
598
598
|
}
|
|
@@ -621,6 +621,18 @@ class CameraController(
|
|
|
621
621
|
return Rect(left, top, right, bottom)
|
|
622
622
|
}
|
|
623
623
|
|
|
624
|
+
private fun insetBox(box: Rect, ratio: Float): Rect {
|
|
625
|
+
if (ratio >= 1f) return box
|
|
626
|
+
val insetX = ((1f - ratio) * box.width() / 2f).toInt()
|
|
627
|
+
val insetY = ((1f - ratio) * box.height() / 2f).toInt()
|
|
628
|
+
return Rect(
|
|
629
|
+
box.left + insetX,
|
|
630
|
+
box.top + insetY,
|
|
631
|
+
box.right - insetX,
|
|
632
|
+
box.bottom - insetY
|
|
633
|
+
)
|
|
634
|
+
}
|
|
635
|
+
|
|
624
636
|
private fun smoothRectangle(current: Rectangle?): Rectangle? {
|
|
625
637
|
val now = System.currentTimeMillis()
|
|
626
638
|
val last = lastRectangle
|
|
@@ -356,7 +356,7 @@ class DocumentScannerView(context: ThemedReactContext) : FrameLayout(context), L
|
|
|
356
356
|
}
|
|
357
357
|
|
|
358
358
|
// Process image with detected rectangle
|
|
359
|
-
val shouldCrop = detectedRectangle != null
|
|
359
|
+
val shouldCrop = detectedRectangle != null
|
|
360
360
|
val processed = ImageProcessor.processImage(
|
|
361
361
|
imagePath = imageFile.absolutePath,
|
|
362
362
|
rectangle = detectedRectangle,
|
package/dist/FullDocScanner.js
CHANGED
|
@@ -527,7 +527,7 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
|
|
|
527
527
|
const stableCounter = event.stableCounter ?? 0;
|
|
528
528
|
const rectangleCoordinates = event.rectangleOnScreen ?? event.rectangleCoordinates;
|
|
529
529
|
const hasRectangle = Boolean(rectangleCoordinates);
|
|
530
|
-
const captureReady = hasRectangle && event.lastDetectionType === 0 && stableCounter >= 1;
|
|
530
|
+
const captureReady = hasRectangle && (react_native_1.Platform.OS === 'android' || (event.lastDetectionType === 0 && stableCounter >= 1));
|
|
531
531
|
const scheduleClear = (ref, clearFn) => {
|
|
532
532
|
if (ref.current) {
|
|
533
533
|
clearTimeout(ref.current);
|
package/package.json
CHANGED
package/src/FullDocScanner.tsx
CHANGED
|
@@ -718,7 +718,7 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
|
|
|
718
718
|
const stableCounter = event.stableCounter ?? 0;
|
|
719
719
|
const rectangleCoordinates = event.rectangleOnScreen ?? event.rectangleCoordinates;
|
|
720
720
|
const hasRectangle = Boolean(rectangleCoordinates);
|
|
721
|
-
const captureReady = hasRectangle && event.lastDetectionType === 0 && stableCounter >= 1;
|
|
721
|
+
const captureReady = hasRectangle && (Platform.OS === 'android' || (event.lastDetectionType === 0 && stableCounter >= 1));
|
|
722
722
|
|
|
723
723
|
const scheduleClear = (
|
|
724
724
|
ref: React.MutableRefObject<ReturnType<typeof setTimeout> | null>,
|