react-native-rectangle-doc-scanner 0.16.0 → 0.17.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 +4 -1
- package/package.json +1 -1
- package/src/DocScanner.tsx +4 -1
package/dist/DocScanner.js
CHANGED
|
@@ -154,6 +154,7 @@ const DocScanner = ({ onCapture, overlayColor = '#e7a649', autoCapture = true, m
|
|
|
154
154
|
const { value: perimeter } = react_native_fast_opencv_1.OpenCV.invoke('arcLength', contour, true);
|
|
155
155
|
const approx = react_native_fast_opencv_1.OpenCV.createObject(react_native_fast_opencv_1.ObjectType.PointVector);
|
|
156
156
|
let approxArray = [];
|
|
157
|
+
let usedBoundingRect = false;
|
|
157
158
|
let epsilonBase = 0.006 * perimeter;
|
|
158
159
|
for (let attempt = 0; attempt < 10; attempt += 1) {
|
|
159
160
|
const epsilon = epsilonBase * (1 + attempt);
|
|
@@ -194,6 +195,7 @@ const DocScanner = ({ onCapture, overlayColor = '#e7a649', autoCapture = true, m
|
|
|
194
195
|
{ x: rectX + rectW, y: rectY + rectH },
|
|
195
196
|
{ x: rectX, y: rectY + rectH },
|
|
196
197
|
];
|
|
198
|
+
usedBoundingRect = true;
|
|
197
199
|
if (__DEV__) {
|
|
198
200
|
console.log('[DocScanner] using boundingRect fallback:', approxArray);
|
|
199
201
|
}
|
|
@@ -226,7 +228,8 @@ const DocScanner = ({ onCapture, overlayColor = '#e7a649', autoCapture = true, m
|
|
|
226
228
|
x: pt.x / ratio,
|
|
227
229
|
y: pt.y / ratio,
|
|
228
230
|
}));
|
|
229
|
-
|
|
231
|
+
// Skip convexity check for boundingRect (always forms a valid rectangle)
|
|
232
|
+
if (!usedBoundingRect && !isConvexQuadrilateral(points)) {
|
|
230
233
|
continue;
|
|
231
234
|
}
|
|
232
235
|
if (area > maxArea) {
|
package/package.json
CHANGED
package/src/DocScanner.tsx
CHANGED
|
@@ -177,6 +177,7 @@ export const DocScanner: React.FC<Props> = ({
|
|
|
177
177
|
const approx = OpenCV.createObject(ObjectType.PointVector);
|
|
178
178
|
|
|
179
179
|
let approxArray: Array<{ x: number; y: number }> = [];
|
|
180
|
+
let usedBoundingRect = false;
|
|
180
181
|
let epsilonBase = 0.006 * perimeter;
|
|
181
182
|
|
|
182
183
|
for (let attempt = 0; attempt < 10; attempt += 1) {
|
|
@@ -225,6 +226,7 @@ export const DocScanner: React.FC<Props> = ({
|
|
|
225
226
|
{ x: rectX + rectW, y: rectY + rectH },
|
|
226
227
|
{ x: rectX, y: rectY + rectH },
|
|
227
228
|
];
|
|
229
|
+
usedBoundingRect = true;
|
|
228
230
|
|
|
229
231
|
if (__DEV__) {
|
|
230
232
|
console.log('[DocScanner] using boundingRect fallback:', approxArray);
|
|
@@ -263,7 +265,8 @@ export const DocScanner: React.FC<Props> = ({
|
|
|
263
265
|
y: pt.y / ratio,
|
|
264
266
|
}));
|
|
265
267
|
|
|
266
|
-
|
|
268
|
+
// Skip convexity check for boundingRect (always forms a valid rectangle)
|
|
269
|
+
if (!usedBoundingRect && !isConvexQuadrilateral(points)) {
|
|
267
270
|
continue;
|
|
268
271
|
}
|
|
269
272
|
|