How to detect only one character in Firebase ML-Kit?
Asked Answered
L

0

6

I set up ML-Kit like AndroidExample and using on-device recognition mode. It's working so well. but If we have a single character like 'A','5','K','9' it can't recognize anything! it only works for more than one length of string! I need to recognize only one character. What am I missing?!

This is my Function that gets a bitmap of an image and finds the texts from it.

private void RecognizeText(Bitmap bitmap) {
    FirebaseVisionImage image = FirebaseVisionImage.fromBitmap(bitmap);
    FirebaseVisionTextRecognizer detector = FirebaseVision.getInstance()
        .getOnDeviceTextRecognizer();

    Task<FirebaseVisionText> result =
    detector.processImage(image)
        .addOnSuccessListener(new OnSuccessListener<FirebaseVisionText>() {
        @Override
        public void onSuccess(FirebaseVisionText firebaseVisionText) {
            String s = firebaseVisionText.getText() + " | " + firebaseVisionText.getText().length();
            Toast.makeText(MainActivity.this, s, Toast.LENGTH_LONG).show();

            textView.setText(s);
        }
    })
        .addOnFailureListener(
    new OnFailureListener() {
        @Override
        public void onFailure(Exception e) {
            Log.d("EEEEEEEEVVVVVV", e.toString());
        }
    });
}
Lever answered 26/12, 2018 at 17:13 Comment(6)
@Barns I added the code.Lever
I have a similar problem when scanning codes like "01234-5" It will always ignore the last digit.Stairhead
did you resolve your issue? I had same problem but cannot find any valuable answerMcgary
@Mcgary Yes! Just draw a character like 'A' before your image! When you want to send your image to the RecognizeText() function, add a bitmap of an image of character like an image of 'A'. add this before your main image bitmap and done!Lever
I did something different, I just crop part of my image (in my case this part is always at the same place, same sizes etc. so it wasn't hard) and copy it, then I make one bitmap for duplicated image so I have 2 letters, which ML kit recognize well. Then I just take one letter to my UI result. That's all.Mcgary
I run across this same issue as well. With lines like " 1 itemname price", the "1" part is never detected.Sayyid

© 2022 - 2024 — McMap. All rights reserved.