react-native-rectangle-doc-scanner 10.44.0 → 10.45.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.
@@ -258,6 +258,25 @@ class CameraController(
258
258
  val imageWidth = imageProxy.width
259
259
  val imageHeight = imageProxy.height
260
260
 
261
+ // Calculate rotation using the same logic as TextureView transform
262
+ val sensorOrientation = getCameraSensorOrientation()
263
+ val displayRotationDegrees = when (textureView.display?.rotation ?: Surface.ROTATION_0) {
264
+ Surface.ROTATION_0 -> 0
265
+ Surface.ROTATION_90 -> 90
266
+ Surface.ROTATION_180 -> 180
267
+ Surface.ROTATION_270 -> 270
268
+ else -> 0
269
+ }
270
+
271
+ // Use the same rotation logic as updateTextureViewTransform
272
+ val effectiveRotation = if (sensorOrientation == 0) {
273
+ displayRotationDegrees // Tablet: use display rotation (90°)
274
+ } else {
275
+ sensorOrientation // Phone: use sensor orientation (90°)
276
+ }
277
+
278
+ Log.d(TAG, "[ANALYZE] Sensor: $sensorOrientation°, Display: $displayRotationDegrees°, Effective: $effectiveRotation°")
279
+
261
280
  // Try ML Kit first
262
281
  val inputImage = InputImage.fromMediaImage(mediaImage, rotationDegrees)
263
282
 
@@ -265,7 +284,7 @@ class CameraController(
265
284
  .addOnSuccessListener { objects ->
266
285
  if (objects.isEmpty()) {
267
286
  // No objects detected, fallback to OpenCV
268
- fallbackToOpenCV(imageProxy, rotationDegrees)
287
+ fallbackToOpenCV(imageProxy, effectiveRotation)
269
288
  return@addOnSuccessListener
270
289
  }
271
290
 
@@ -280,7 +299,7 @@ class CameraController(
280
299
  val nv21 = imageProxyToNV21(imageProxy)
281
300
  val rectangle = if (nv21 != null) {
282
301
  try {
283
- refineWithOpenCv(nv21, imageWidth, imageHeight, rotationDegrees, mlBox)
302
+ refineWithOpenCv(nv21, imageWidth, imageHeight, effectiveRotation, mlBox)
284
303
  } catch (e: Exception) {
285
304
  Log.w(TAG, "[CAMERAX] OpenCV refinement failed", e)
286
305
  null
@@ -289,15 +308,15 @@ class CameraController(
289
308
  null
290
309
  }
291
310
 
292
- val frameWidth = if (rotationDegrees == 90 || rotationDegrees == 270) imageHeight else imageWidth
293
- val frameHeight = if (rotationDegrees == 90 || rotationDegrees == 270) imageWidth else imageHeight
311
+ val frameWidth = if (effectiveRotation == 90 || effectiveRotation == 270) imageHeight else imageWidth
312
+ val frameHeight = if (effectiveRotation == 90 || effectiveRotation == 270) imageWidth else imageHeight
294
313
 
295
314
  onFrameAnalyzed?.invoke(rectangle, frameWidth, frameHeight)
296
315
  imageProxy.close()
297
316
  }
298
317
  .addOnFailureListener { e ->
299
318
  Log.w(TAG, "[CAMERAX] ML Kit detection failed, using OpenCV", e)
300
- fallbackToOpenCV(imageProxy, rotationDegrees)
319
+ fallbackToOpenCV(imageProxy, effectiveRotation)
301
320
  }
302
321
  }
303
322
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "10.44.0",
3
+ "version": "10.45.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",