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.
- package/dist/DocScanner.js +10 -5
- package/package.json +1 -1
- package/src/DocScanner.tsx +12 -5
package/dist/DocScanner.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
package/src/DocScanner.tsx
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
|