Giter Club home page Giter Club logo

Comments (3)

chunghn avatar chunghn commented on August 25, 2024

Similar issue. In my case, I managed to make boundingBox in portrait orientation. But when I rotate the phone to landscape the data is screwed.

Noted that I locked device orientation with expo-orientation

Ref

      //  check android barcode bounds
    } else if (barcode.boundingBox !== undefined) {
      barcodeBounds = {
        height: barcode.boundingBox.size.width,
        width: barcode.boundingBox.size.height,
        left:
          width - barcode.boundingBox.origin.y - barcode.boundingBox.size.width,
        top: barcode.boundingBox.origin.x,
      }
    }

from expo.

igoro00 avatar igoro00 commented on August 25, 2024

Same problem here.

It's because currently screen orientation has nothing to do with how the barcode is scanned and how the corner points are processed. The orientation is taken from rotationDegrees which are also used for creating EXIF data when taking pictures.

val rotation = CameraViewHelper.getCorrectCameraRotation(imageProxy.imageInfo.rotationDegrees, lensFacing)
val image = InputImage.fromMediaImage(mediaImage, rotation)
barcodeScanner.process(image)

Maybe I'm wrong but IMO the only real use case for corner points and bounding box is to show that to the user as an overlay. And for that we need it tied to the screen orientation and not physical orientation. Or at the very least we need to somehow get that info to javascript so we can process it ourselves.

from expo.

igoro00 avatar igoro00 commented on August 25, 2024

Update: Since my app is always portrait anyway I decided to hardcode the angle for now.
Here's my patch:

diff --git a/android/src/main/java/expo/modules/camera/analyzers/BarcodeAnalyzer.kt b/android/src/main/java/expo/modules/camera/analyzers/BarcodeAnalyzer.kt
index 8d3f8796363d4a42b440add55b2506cb0d4d556c..1328f41ac3668d41c2c5ded3e3542080ff1db5b7 100644
--- a/android/src/main/java/expo/modules/camera/analyzers/BarcodeAnalyzer.kt
+++ b/android/src/main/java/expo/modules/camera/analyzers/BarcodeAnalyzer.kt
@@ -33,7 +33,8 @@ class BarcodeAnalyzer(private val lensFacing: CameraType, formats: List<BarcodeT
     val mediaImage = imageProxy.image
 
     if (mediaImage != null) {
-      val rotation = CameraViewHelper.getCorrectCameraRotation(imageProxy.imageInfo.rotationDegrees, lensFacing)
+      val rotation = CameraViewHelper.getCorrectCameraRotation(90, lensFacing)
       val image = InputImage.fromMediaImage(mediaImage, rotation)
 
       barcodeScanner.process(image)

It was created using bun patch but you probably can patch that using other tools. Idk if custom patches work in EAS. I build apks on my own infra (docker image + some scripts) and patches are applied automatically with every bun install.

from expo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.