react-native-rectangle-doc-scanner 0.43.0 → 0.44.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.
@@ -107,9 +107,9 @@ const DocScanner = ({ onCapture, overlayColor = '#e7a649', autoCapture = true, m
107
107
  const REJECT_CENTER_DELTA = 145;
108
108
  const MAX_AREA_SHIFT = 0.45;
109
109
  const HISTORY_RESET_DISTANCE = 70;
110
- const MIN_AREA_RATIO = 0.0035;
110
+ const MIN_AREA_RATIO = 0.0002;
111
111
  const MAX_AREA_RATIO = 0.9;
112
- const MIN_EDGE_RATIO = 0.025;
112
+ const MIN_EDGE_RATIO = 0.015;
113
113
  const MAX_ANCHOR_MISSES = 12;
114
114
  const MIN_CONFIDENCE_TO_HOLD = 2;
115
115
  const MAX_ANCHOR_CONFIDENCE = 20;
@@ -189,10 +189,13 @@ const DocScanner = ({ onCapture, overlayColor = '#e7a649', autoCapture = true, m
189
189
  const centerDelta = Math.hypot(candidateCenter.x - anchorCenter.x, candidateCenter.y - anchorCenter.y);
190
190
  const areaShift = anchorArea > 0 ? Math.abs(anchorArea - candidateArea) / anchorArea : 0;
191
191
  if (centerDelta >= REJECT_CENTER_DELTA || areaShift > 1.2) {
192
- const handled = fallbackToAnchor(true);
193
- if (handled) {
194
- return;
195
- }
192
+ smoothingBufferRef.current = [sanitized];
193
+ lastMeasurementRef.current = sanitized;
194
+ anchorQuadRef.current = candidate;
195
+ anchorConfidenceRef.current = 1;
196
+ anchorMissesRef.current = 0;
197
+ lastQuadRef.current = candidate;
198
+ setQuad(candidate);
196
199
  return;
197
200
  }
198
201
  if (delta <= SNAP_DISTANCE && centerDelta <= SNAP_CENTER_DISTANCE && areaShift <= 0.08) {
@@ -310,7 +313,7 @@ const DocScanner = ({ onCapture, overlayColor = '#e7a649', autoCapture = true, m
310
313
  console.log('[DocScanner] area', area, 'ratio', areaRatio);
311
314
  }
312
315
  // Skip if area ratio is too small or too large
313
- if (areaRatio < 0.005 || areaRatio > 0.95) {
316
+ if (areaRatio < 0.0002 || areaRatio > 0.99) {
314
317
  continue;
315
318
  }
316
319
  // Try to use convex hull for better corner detection
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "0.43.0",
3
+ "version": "0.44.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": {
@@ -123,9 +123,9 @@ export const DocScanner: React.FC<Props> = ({
123
123
  const REJECT_CENTER_DELTA = 145;
124
124
  const MAX_AREA_SHIFT = 0.45;
125
125
  const HISTORY_RESET_DISTANCE = 70;
126
- const MIN_AREA_RATIO = 0.0035;
126
+ const MIN_AREA_RATIO = 0.0002;
127
127
  const MAX_AREA_RATIO = 0.9;
128
- const MIN_EDGE_RATIO = 0.025;
128
+ const MIN_EDGE_RATIO = 0.015;
129
129
  const MAX_ANCHOR_MISSES = 12;
130
130
  const MIN_CONFIDENCE_TO_HOLD = 2;
131
131
  const MAX_ANCHOR_CONFIDENCE = 20;
@@ -224,10 +224,13 @@ export const DocScanner: React.FC<Props> = ({
224
224
  const areaShift = anchorArea > 0 ? Math.abs(anchorArea - candidateArea) / anchorArea : 0;
225
225
 
226
226
  if (centerDelta >= REJECT_CENTER_DELTA || areaShift > 1.2) {
227
- const handled = fallbackToAnchor(true);
228
- if (handled) {
229
- return;
230
- }
227
+ smoothingBufferRef.current = [sanitized];
228
+ lastMeasurementRef.current = sanitized;
229
+ anchorQuadRef.current = candidate;
230
+ anchorConfidenceRef.current = 1;
231
+ anchorMissesRef.current = 0;
232
+ lastQuadRef.current = candidate;
233
+ setQuad(candidate);
231
234
  return;
232
235
  }
233
236
 
@@ -365,7 +368,7 @@ export const DocScanner: React.FC<Props> = ({
365
368
  }
366
369
 
367
370
  // Skip if area ratio is too small or too large
368
- if (areaRatio < 0.005 || areaRatio > 0.95) {
371
+ if (areaRatio < 0.0002 || areaRatio > 0.99) {
369
372
  continue;
370
373
  }
371
374