react-native-rectangle-doc-scanner 0.15.0 → 0.16.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.
@@ -177,22 +177,15 @@ const DocScanner = ({ onCapture, overlayColor = '#e7a649', autoCapture = true, m
177
177
  }
178
178
  if (approxArray.length !== 4) {
179
179
  // fallback: boundingRect (axis-aligned) so we always have 4 points
180
- if (__DEV__) {
181
- console.log('[DocScanner] attempting boundingRect fallback, current length:', approxArray.length);
182
- }
183
180
  try {
184
181
  const rect = react_native_fast_opencv_1.OpenCV.invoke('boundingRect', contour);
185
- const rectValue = rect?.value ?? rect;
186
- if (__DEV__) {
187
- console.log('[DocScanner] boundingRect result:', JSON.stringify(rectValue));
188
- }
189
- const rectX = rectValue.x ?? rectValue?.topLeft?.x ?? 0;
190
- const rectY = rectValue.y ?? rectValue?.topLeft?.y ?? 0;
191
- const rectW = rectValue.width ?? rectValue?.size?.width ?? 0;
192
- const rectH = rectValue.height ?? rectValue?.size?.height ?? 0;
193
- if (__DEV__) {
194
- console.log('[DocScanner] parsed rect:', { x: rectX, y: rectY, w: rectW, h: rectH });
195
- }
182
+ // Convert the rect object to JS value to get actual coordinates
183
+ const rectJS = react_native_fast_opencv_1.OpenCV.toJSValue(rect);
184
+ const rectValue = rectJS?.value ?? rectJS;
185
+ const rectX = rectValue?.x ?? 0;
186
+ const rectY = rectValue?.y ?? 0;
187
+ const rectW = rectValue?.width ?? 0;
188
+ const rectH = rectValue?.height ?? 0;
196
189
  // Validate that we have a valid rectangle
197
190
  if (rectW > 0 && rectH > 0) {
198
191
  approxArray = [
@@ -202,18 +195,13 @@ const DocScanner = ({ onCapture, overlayColor = '#e7a649', autoCapture = true, m
202
195
  { x: rectX, y: rectY + rectH },
203
196
  ];
204
197
  if (__DEV__) {
205
- console.log('[DocScanner] boundingRect fallback success', approxArray);
206
- }
207
- }
208
- else {
209
- if (__DEV__) {
210
- console.warn('[DocScanner] boundingRect has invalid dimensions');
198
+ console.log('[DocScanner] using boundingRect fallback:', approxArray);
211
199
  }
212
200
  }
213
201
  }
214
202
  catch (err) {
215
203
  if (__DEV__) {
216
- console.warn('[DocScanner] boundingRect fallback exception', err);
204
+ console.warn('[DocScanner] boundingRect fallback failed:', err);
217
205
  }
218
206
  }
219
207
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": {
@@ -206,25 +206,16 @@ export const DocScanner: React.FC<Props> = ({
206
206
 
207
207
  if (approxArray.length !== 4) {
208
208
  // fallback: boundingRect (axis-aligned) so we always have 4 points
209
- if (__DEV__) {
210
- console.log('[DocScanner] attempting boundingRect fallback, current length:', approxArray.length);
211
- }
212
209
  try {
213
210
  const rect = OpenCV.invoke('boundingRect', contour);
214
- const rectValue = rect?.value ?? rect;
215
-
216
- if (__DEV__) {
217
- console.log('[DocScanner] boundingRect result:', JSON.stringify(rectValue));
218
- }
211
+ // Convert the rect object to JS value to get actual coordinates
212
+ const rectJS = OpenCV.toJSValue(rect);
213
+ const rectValue = rectJS?.value ?? rectJS;
219
214
 
220
- const rectX = rectValue.x ?? rectValue?.topLeft?.x ?? 0;
221
- const rectY = rectValue.y ?? rectValue?.topLeft?.y ?? 0;
222
- const rectW = rectValue.width ?? rectValue?.size?.width ?? 0;
223
- const rectH = rectValue.height ?? rectValue?.size?.height ?? 0;
224
-
225
- if (__DEV__) {
226
- console.log('[DocScanner] parsed rect:', { x: rectX, y: rectY, w: rectW, h: rectH });
227
- }
215
+ const rectX = rectValue?.x ?? 0;
216
+ const rectY = rectValue?.y ?? 0;
217
+ const rectW = rectValue?.width ?? 0;
218
+ const rectH = rectValue?.height ?? 0;
228
219
 
229
220
  // Validate that we have a valid rectangle
230
221
  if (rectW > 0 && rectH > 0) {
@@ -236,16 +227,12 @@ export const DocScanner: React.FC<Props> = ({
236
227
  ];
237
228
 
238
229
  if (__DEV__) {
239
- console.log('[DocScanner] boundingRect fallback success', approxArray);
240
- }
241
- } else {
242
- if (__DEV__) {
243
- console.warn('[DocScanner] boundingRect has invalid dimensions');
230
+ console.log('[DocScanner] using boundingRect fallback:', approxArray);
244
231
  }
245
232
  }
246
233
  } catch (err) {
247
234
  if (__DEV__) {
248
- console.warn('[DocScanner] boundingRect fallback exception', err);
235
+ console.warn('[DocScanner] boundingRect fallback failed:', err);
249
236
  }
250
237
  }
251
238
  }