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

iPhone SE 2nd Generation in portrait mode unable to recognise text on image #1336

Closed
3 of 4 tasks
jhonghena opened this issue Nov 9, 2022 · 2 comments
Closed
3 of 4 tasks
Labels
🐛 bug Something isn't working

Comments

@jhonghena
Copy link

What were you trying to do?

I am using MLKitTextRecognition for recognising text on image.
Added code below which I am trying for text recognition.
Only iPhone SE 2nd Generation in portrait mode unable to recognise text on image.
Though on iPhone SE 2nd Generation in landscape mode text recognition works perfect and all other iOS devices working perfect.
I think there is an issue with frame passed in iPhone SE 2nd Generation in portrait mode, will you please help me?
Thanks in advance.

Reproduceable Code

import AVKit
import Vision
import MLKitVision
import MLKitTextRecognition 


@objc(ExamplePluginSwift)

public class ExamplePluginSwift: NSObject, FrameProcessorPluginBase {
    private static var textRecognizer = TextRecognizer.textRecognizer()

    @objc

    public static func callback(_ frame: Frame!, withArgs args: [Any]!) -> Any! {

        guard let imageBuffer = CMSampleBufferGetImageBuffer(frame.buffer) else {

            return nil

        }

        NSLog("ExamplePlugin: \(CVPixelBufferGetWidth(imageBuffer)) x \(CVPixelBufferGetHeight(imageBuffer)) Image. Logging \(args.count) parameters:")



        args.forEach { arg in

            var string = "\(arg)"

            if let array = arg as? NSArray {

                string = (array as Array).description

            } else if let map = arg as? NSDictionary {

                string = (map as Dictionary).description

            }

            NSLog("ExamplePlugin:   -> \(string) (\(type(of: arg)))")

        }

               let visionImage = VisionImage(buffer: frame.buffer)
               visionImage.orientation = .up
            
               textRecognizer.process(visionImage){result, error in
                   guard error == nil, let result = result else {
                    return
                  }

                  print(# Result text = \(result.text)
               }
    



        return [

            "example_str": "Test",

            "example_bool": true,

            "example_double": 5.3,

            "example_array": [

                "Hello",

                true,

                17.38,

            ],

        ]

    }

}

What happened instead?

on iPhone SE 2nd Generation in landscape mode text recognition works perfect and all other iOS devices working perfect.

Relevant log output

No response

Device

iPhone SE 2nd Generation (iOS 14.0.1)

VisionCamera Version

2.14.0

Additional information

@jhonghena jhonghena added the 🐛 bug Something isn't working label Nov 9, 2022
@mrousavy
Copy link
Owner

Closing as this is a stale issue - this might have been fixed with the full rewrite in VisionCamera V3 (🥳) - if not, please create a new issue.

If your issue has been fixed, consider sponsoring me on GitHub to say thanks 💖

@mrousavy
Copy link
Owner

Hey - I'm tracking Orientation in this feature request/issue now: #1891

Make sure to upvote or sponsor to support this feature, and leave a comment if you have any additional thoughts/ideas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants