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());
        }
    });
}
daedsidog
  • 1,732
  • 2
  • 17
  • 36
Hossein Yousefpour
  • 3,827
  • 3
  • 23
  • 35
  • @Barns I added the code. – Hossein Yousefpour Dec 26 '18 at 17:43
  • I have a similar problem when scanning codes like "01234-5" It will always ignore the last digit. – Kaizie May 21 '19 at 08:40
  • did you resolve your issue? I had same problem but cannot find any valuable answer – woochuck Jun 24 '19 at 14:22
  • @woochuck 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! – Hossein Yousefpour Jul 03 '19 at 17:43
  • 1
    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. – woochuck Jul 04 '19 at 06:42
  • I run across this same issue as well. With lines like " 1 itemname price", the "1" part is never detected. – Peterdk Mar 02 '20 at 14:46

0 Answers0