react-native-rectangle-doc-scanner 0.34.0 → 0.35.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.
@@ -197,7 +197,7 @@ const DocScanner = ({ onCapture, overlayColor = '#e7a649', autoCapture = true, m
197
197
  console.log('[DocScanner] area', area, 'ratio', areaRatio);
198
198
  }
199
199
  // Skip if area ratio is too small or too large
200
- if (areaRatio < 0.01 || areaRatio > 0.95) {
200
+ if (areaRatio < 0.02 || areaRatio > 0.95) {
201
201
  continue;
202
202
  }
203
203
  step = `contour_${i}_arcLength`;
@@ -205,9 +205,8 @@ const DocScanner = ({ onCapture, overlayColor = '#e7a649', autoCapture = true, m
205
205
  const { value: perimeter } = react_native_fast_opencv_1.OpenCV.invoke('arcLength', contour, true);
206
206
  const approx = react_native_fast_opencv_1.OpenCV.createObject(react_native_fast_opencv_1.ObjectType.PointVector);
207
207
  let approxArray = [];
208
- // Start with smaller epsilon for more accurate corner detection
209
- // Try epsilon values from 0.5% to 5% of perimeter
210
- const epsilonValues = [0.005, 0.01, 0.015, 0.02, 0.025, 0.03, 0.035, 0.04, 0.045, 0.05];
208
+ // Try epsilon values from 0.2% to 8% of perimeter
209
+ const epsilonValues = [0.002, 0.004, 0.006, 0.008, 0.01, 0.015, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08];
211
210
  for (let attempt = 0; attempt < epsilonValues.length; attempt += 1) {
212
211
  const epsilon = epsilonValues[attempt] * perimeter;
213
212
  step = `contour_${i}_approxPolyDP_attempt_${attempt}`;
@@ -95,25 +95,13 @@ const Overlay = ({ quad, color = '#e7a649', frameSize }) => {
95
95
  skPath.close();
96
96
  return skPath;
97
97
  }, [quad, color, screenWidth, screenHeight, frameSize]);
98
- // Test path - always visible for debugging
99
- const testPath = (0, react_1.useMemo)(() => {
100
- const tp = react_native_skia_1.Skia.Path.Make();
101
- tp.moveTo(100, 100);
102
- tp.lineTo(300, 100);
103
- tp.lineTo(300, 300);
104
- tp.lineTo(100, 300);
105
- tp.close();
106
- return tp;
107
- }, []);
108
98
  if (__DEV__) {
109
99
  console.log('[Overlay] rendering Canvas with dimensions:', screenWidth, 'x', screenHeight);
110
100
  }
111
101
  return (react_1.default.createElement(react_native_1.View, { style: styles.container, pointerEvents: "none" },
112
- react_1.default.createElement(react_native_skia_1.Canvas, { style: { width: screenWidth, height: screenHeight } },
113
- react_1.default.createElement(react_native_skia_1.Path, { path: testPath, color: "red", style: "stroke", strokeWidth: 4 }),
114
- path && (react_1.default.createElement(react_1.default.Fragment, null,
115
- react_1.default.createElement(react_native_skia_1.Path, { path: path, color: color, style: "stroke", strokeWidth: 8 }),
116
- react_1.default.createElement(react_native_skia_1.Path, { path: path, color: "rgba(231, 166, 73, 0.2)", style: "fill" }))))));
102
+ react_1.default.createElement(react_native_skia_1.Canvas, { style: { width: screenWidth, height: screenHeight } }, path && (react_1.default.createElement(react_1.default.Fragment, null,
103
+ react_1.default.createElement(react_native_skia_1.Path, { path: path, color: color, style: "stroke", strokeWidth: 8 }),
104
+ react_1.default.createElement(react_native_skia_1.Path, { path: path, color: "rgba(231, 166, 73, 0.2)", style: "fill" }))))));
117
105
  };
118
106
  exports.Overlay = Overlay;
119
107
  const styles = react_native_1.StyleSheet.create({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "0.34.0",
3
+ "version": "0.35.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": {
@@ -225,7 +225,7 @@ export const DocScanner: React.FC<Props> = ({
225
225
  }
226
226
 
227
227
  // Skip if area ratio is too small or too large
228
- if (areaRatio < 0.01 || areaRatio > 0.95) {
228
+ if (areaRatio < 0.02 || areaRatio > 0.95) {
229
229
  continue;
230
230
  }
231
231
 
@@ -236,9 +236,8 @@ export const DocScanner: React.FC<Props> = ({
236
236
 
237
237
  let approxArray: Array<{ x: number; y: number }> = [];
238
238
 
239
- // Start with smaller epsilon for more accurate corner detection
240
- // Try epsilon values from 0.5% to 5% of perimeter
241
- const epsilonValues = [0.005, 0.01, 0.015, 0.02, 0.025, 0.03, 0.035, 0.04, 0.045, 0.05];
239
+ // Try epsilon values from 0.2% to 8% of perimeter
240
+ const epsilonValues = [0.002, 0.004, 0.006, 0.008, 0.01, 0.015, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08];
242
241
 
243
242
  for (let attempt = 0; attempt < epsilonValues.length; attempt += 1) {
244
243
  const epsilon = epsilonValues[attempt] * perimeter;
@@ -79,17 +79,6 @@ export const Overlay: React.FC<OverlayProps> = ({ quad, color = '#e7a649', frame
79
79
  return skPath;
80
80
  }, [quad, color, screenWidth, screenHeight, frameSize]);
81
81
 
82
- // Test path - always visible for debugging
83
- const testPath = useMemo(() => {
84
- const tp = Skia.Path.Make();
85
- tp.moveTo(100, 100);
86
- tp.lineTo(300, 100);
87
- tp.lineTo(300, 300);
88
- tp.lineTo(100, 300);
89
- tp.close();
90
- return tp;
91
- }, []);
92
-
93
82
  if (__DEV__) {
94
83
  console.log('[Overlay] rendering Canvas with dimensions:', screenWidth, 'x', screenHeight);
95
84
  }
@@ -97,10 +86,6 @@ export const Overlay: React.FC<OverlayProps> = ({ quad, color = '#e7a649', frame
97
86
  return (
98
87
  <View style={styles.container} pointerEvents="none">
99
88
  <Canvas style={{ width: screenWidth, height: screenHeight }}>
100
- {/* Debug: always show a test rectangle */}
101
- <Path path={testPath} color="red" style="stroke" strokeWidth={4} />
102
-
103
- {/* Actual quad overlay */}
104
89
  {path && (
105
90
  <>
106
91
  <Path path={path} color={color} style="stroke" strokeWidth={8} />