react-native-rectangle-doc-scanner 10.25.0 → 10.27.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.
|
@@ -52,7 +52,7 @@ class CameraController(
|
|
|
52
52
|
|
|
53
53
|
companion object {
|
|
54
54
|
private const val TAG = "CameraController"
|
|
55
|
-
private const val ANALYSIS_TARGET_RESOLUTION =
|
|
55
|
+
private const val ANALYSIS_TARGET_RESOLUTION = 1920 // Max dimension for analysis
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
private fun getCameraSensorOrientation(): Int {
|
|
@@ -184,7 +184,7 @@ class CameraController(
|
|
|
184
184
|
// ImageAnalysis UseCase for document detection
|
|
185
185
|
imageAnalyzer = ImageAnalysis.Builder()
|
|
186
186
|
.setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
|
|
187
|
-
.setTargetResolution(android.util.Size(
|
|
187
|
+
.setTargetResolution(android.util.Size(1920, 1440)) // Higher resolution for better small-edge detection
|
|
188
188
|
.setTargetRotation(targetRotation) // Match preview rotation
|
|
189
189
|
.build()
|
|
190
190
|
.also {
|
|
@@ -170,6 +170,11 @@ class DocumentDetector {
|
|
|
170
170
|
srcMat.copyTo(grayMat)
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
+
// Boost local contrast to improve low-contrast edges (e.g., business cards).
|
|
174
|
+
val clahe = Imgproc.createCLAHE()
|
|
175
|
+
clahe.clipLimit = 2.5
|
|
176
|
+
clahe.apply(grayMat, grayMat)
|
|
177
|
+
|
|
173
178
|
// Apply a light blur to reduce noise without killing small edges.
|
|
174
179
|
Imgproc.GaussianBlur(grayMat, blurredMat, Size(5.0, 5.0), 0.0)
|
|
175
180
|
|
|
@@ -202,8 +207,8 @@ class DocumentDetector {
|
|
|
202
207
|
|
|
203
208
|
val median = computeMedian(blurredMat)
|
|
204
209
|
val sigma = 0.33
|
|
205
|
-
val cannyLow = max(
|
|
206
|
-
val cannyHigh = max(
|
|
210
|
+
val cannyLow = max(40.0, (1.0 - sigma) * median)
|
|
211
|
+
val cannyHigh = max(120.0, (1.0 + sigma) * median)
|
|
207
212
|
|
|
208
213
|
// Apply Canny edge detection with adaptive thresholds for better corner detection.
|
|
209
214
|
Imgproc.Canny(blurredMat, cannyMat, cannyLow, cannyHigh)
|
package/package.json
CHANGED