Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot recognise texts when the orientation is not portrait #5

Open
hikmert opened this issue May 11, 2022 · 3 comments
Open

Cannot recognise texts when the orientation is not portrait #5

hikmert opened this issue May 11, 2022 · 3 comments

Comments

@hikmert
Copy link

hikmert commented May 11, 2022

I've installed the plugin correctly and it works pretty well if the orientation of the device is 'portrait'. However, when I either turn the text or device, it doesn't recognise the texts. Although I played a bit with the orientation property of the camera, no improvements achieved so far. When I looked into the pod of VisionCameraOCR, I came across with a todo as:
` @objc
public static func callback(_ frame: Frame!, withArgs _: [Any]!) -> Any! {

    guard (CMSampleBufferGetImageBuffer(frame.buffer) != nil) else {
      print("Failed to get image buffer from sample buffer.")
      return nil
    }

    let visionImage = VisionImage(buffer: frame.buffer)
    
    // TODO: Get camera orientation state
    visionImage.orientation = .up`

I'd highly appreciate any advices or hints. Thanks in advance!

@romancxx
Copy link

I find out that by modifying this line for Android :

 val image = InputImage.fromMediaImage(mediaImage, frame.imageInfo.rotationDegrees) // frame.imageInfo.rotationDegrees = 90 

To :

 val image = InputImage.fromMediaImage(mediaImage, 0)  // or 180

The OCR can recognize text vertically.
I haven’t been able to test but I think it's the same for iOS, if you change .up to .left or .right it should work. As mentioned in the documentation : https://developers.google.com/ml-kit/vision/text-recognition/ios

I am also looking forward to changing the orientation by passing a param. I don't know if that's something that could be added to this package.

@hikmert
Copy link
Author

hikmert commented May 23, 2022

Hey @Nazort, thanks for your reply.

I'm working on iOS at the moment, so as a workaround I removed the lines ` // TODO: Get camera orientation state
visionImage.orientation = .up`` and I passed the orientation of the device through listening to the device acceloremeter.

@tomerh2001
Copy link

Hey @Nazort, thanks for your reply.

I'm working on iOS at the moment, so as a workaround I removed the lines ` // TODO: Get camera orientation state visionImage.orientation = .up`` and I passed the orientation of the device through listening to the device acceloremeter.

Hi, can you share the code? I'm having the issue, almost 2 years later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@romancxx @tomerh2001 @hikmert and others