react-native-rectangle-doc-scanner 0.29.0 → 0.31.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.
@@ -179,16 +179,21 @@ const DocScanner = ({ onCapture, overlayColor = '#e7a649', autoCapture = true, m
179
179
  step = `contour_${i}_copy`;
180
180
  reportStage(step);
181
181
  const contour = react_native_fast_opencv_1.OpenCV.copyObjectFromVector(contours, i);
182
- step = `contour_${i}_area`;
182
+ // Compute absolute area first
183
+ step = `contour_${i}_area_abs`;
183
184
  reportStage(step);
184
185
  const { value: area } = react_native_fast_opencv_1.OpenCV.invoke('contourArea', contour, false);
186
+ // Skip extremely small contours, but keep threshold very low to allow distant documents
187
+ if (area < 200) {
188
+ continue;
189
+ }
190
+ step = `contour_${i}_area`; // ratio stage
191
+ reportStage(step);
185
192
  const areaRatio = area / frameArea;
186
193
  if (__DEV__) {
187
- console.log('[DocScanner] area ratio', areaRatio);
194
+ console.log('[DocScanner] area', area, 'ratio', areaRatio);
188
195
  }
189
- // Filter by area: document should be at least 0.1% and at most 98% of frame
190
- // This prevents detecting tiny noise or the entire frame
191
- if (areaRatio < 0.001 || areaRatio > 0.98) {
196
+ if (areaRatio < 0.00002 || areaRatio > 0.99) {
192
197
  continue;
193
198
  }
194
199
  step = `contour_${i}_arcLength`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "0.29.0",
3
+ "version": "0.31.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": {
@@ -202,18 +202,25 @@ export const DocScanner: React.FC<Props> = ({
202
202
  reportStage(step);
203
203
  const contour = OpenCV.copyObjectFromVector(contours, i);
204
204
 
205
- step = `contour_${i}_area`;
205
+ // Compute absolute area first
206
+ step = `contour_${i}_area_abs`;
206
207
  reportStage(step);
207
208
  const { value: area } = OpenCV.invoke('contourArea', contour, false);
209
+
210
+ // Skip extremely small contours, but keep threshold very low to allow distant documents
211
+ if (area < 200) {
212
+ continue;
213
+ }
214
+
215
+ step = `contour_${i}_area`; // ratio stage
216
+ reportStage(step);
208
217
  const areaRatio = area / frameArea;
209
218
 
210
219
  if (__DEV__) {
211
- console.log('[DocScanner] area ratio', areaRatio);
220
+ console.log('[DocScanner] area', area, 'ratio', areaRatio);
212
221
  }
213
222
 
214
- // Filter by area: document should be at least 0.1% and at most 98% of frame
215
- // This prevents detecting tiny noise or the entire frame
216
- if (areaRatio < 0.001 || areaRatio > 0.98) {
223
+ if (areaRatio < 0.00002 || areaRatio > 0.99) {
217
224
  continue;
218
225
  }
219
226