react-native-rectangle-doc-scanner 10.25.0 → 10.26.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 = 1280 // Max dimension for analysis
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(1280, 960)) // Limit resolution for analysis
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,12 @@ 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
+ clahe.release()
178
+
173
179
  // Apply a light blur to reduce noise without killing small edges.
174
180
  Imgproc.GaussianBlur(grayMat, blurredMat, Size(5.0, 5.0), 0.0)
175
181
 
@@ -202,8 +208,8 @@ class DocumentDetector {
202
208
 
203
209
  val median = computeMedian(blurredMat)
204
210
  val sigma = 0.33
205
- val cannyLow = max(20.0, (1.0 - sigma) * median)
206
- val cannyHigh = max(60.0, (1.0 + sigma) * median)
211
+ val cannyLow = max(40.0, (1.0 - sigma) * median)
212
+ val cannyHigh = max(120.0, (1.0 + sigma) * median)
207
213
 
208
214
  // Apply Canny edge detection with adaptive thresholds for better corner detection.
209
215
  Imgproc.Canny(blurredMat, cannyMat, cannyLow, cannyHigh)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "10.25.0",
3
+ "version": "10.26.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",