react-native-rectangle-doc-scanner 0.16.0 → 0.18.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.
@@ -146,7 +146,8 @@ const DocScanner = ({ onCapture, overlayColor = '#e7a649', autoCapture = true, m
146
146
  if (__DEV__) {
147
147
  console.log('[DocScanner] area ratio', area / (width * height));
148
148
  }
149
- if (area < width * height * 0.005) {
149
+ // Lower threshold to detect smaller documents
150
+ if (area < width * height * 0.0001) {
150
151
  continue;
151
152
  }
152
153
  step = `contour_${i}_arcLength`;
@@ -154,6 +155,7 @@ const DocScanner = ({ onCapture, overlayColor = '#e7a649', autoCapture = true, m
154
155
  const { value: perimeter } = react_native_fast_opencv_1.OpenCV.invoke('arcLength', contour, true);
155
156
  const approx = react_native_fast_opencv_1.OpenCV.createObject(react_native_fast_opencv_1.ObjectType.PointVector);
156
157
  let approxArray = [];
158
+ let usedBoundingRect = false;
157
159
  let epsilonBase = 0.006 * perimeter;
158
160
  for (let attempt = 0; attempt < 10; attempt += 1) {
159
161
  const epsilon = epsilonBase * (1 + attempt);
@@ -194,6 +196,7 @@ const DocScanner = ({ onCapture, overlayColor = '#e7a649', autoCapture = true, m
194
196
  { x: rectX + rectW, y: rectY + rectH },
195
197
  { x: rectX, y: rectY + rectH },
196
198
  ];
199
+ usedBoundingRect = true;
197
200
  if (__DEV__) {
198
201
  console.log('[DocScanner] using boundingRect fallback:', approxArray);
199
202
  }
@@ -226,7 +229,8 @@ const DocScanner = ({ onCapture, overlayColor = '#e7a649', autoCapture = true, m
226
229
  x: pt.x / ratio,
227
230
  y: pt.y / ratio,
228
231
  }));
229
- if (!isConvexQuadrilateral(points)) {
232
+ // Skip convexity check for boundingRect (always forms a valid rectangle)
233
+ if (!usedBoundingRect && !isConvexQuadrilateral(points)) {
230
234
  continue;
231
235
  }
232
236
  if (area > maxArea) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "0.16.0",
3
+ "version": "0.18.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": {
@@ -167,7 +167,8 @@ export const DocScanner: React.FC<Props> = ({
167
167
  console.log('[DocScanner] area ratio', area / (width * height));
168
168
  }
169
169
 
170
- if (area < width * height * 0.005) {
170
+ // Lower threshold to detect smaller documents
171
+ if (area < width * height * 0.0001) {
171
172
  continue;
172
173
  }
173
174
 
@@ -177,6 +178,7 @@ export const DocScanner: React.FC<Props> = ({
177
178
  const approx = OpenCV.createObject(ObjectType.PointVector);
178
179
 
179
180
  let approxArray: Array<{ x: number; y: number }> = [];
181
+ let usedBoundingRect = false;
180
182
  let epsilonBase = 0.006 * perimeter;
181
183
 
182
184
  for (let attempt = 0; attempt < 10; attempt += 1) {
@@ -225,6 +227,7 @@ export const DocScanner: React.FC<Props> = ({
225
227
  { x: rectX + rectW, y: rectY + rectH },
226
228
  { x: rectX, y: rectY + rectH },
227
229
  ];
230
+ usedBoundingRect = true;
228
231
 
229
232
  if (__DEV__) {
230
233
  console.log('[DocScanner] using boundingRect fallback:', approxArray);
@@ -263,7 +266,8 @@ export const DocScanner: React.FC<Props> = ({
263
266
  y: pt.y / ratio,
264
267
  }));
265
268
 
266
- if (!isConvexQuadrilateral(points)) {
269
+ // Skip convexity check for boundingRect (always forms a valid rectangle)
270
+ if (!usedBoundingRect && !isConvexQuadrilateral(points)) {
267
271
  continue;
268
272
  }
269
273