简体   繁体   中英

How to make google-mlkit text recognition work in a flutter app

I'm trying to make a flutter app that uses google-mlkit text recognition to extract the text of receipts. I got it working but there are still isues. Some single letters don't get recognized and sometimes even full words or numbers dont get picked up.

I implemented my app following this guide https://blog.codemagic.io/text-recognition-using-firebase-ml-kit-flutter/ .

In this picture you can see what i mean that some numbers and text dont get picked up. [1] [1]: https://i.stack.imgur.com/nR5SP.jpg

Does anyone know what the problem could be? Any suggestions? Thanks in advance for the help and I will list some ways i have tried to fix it.

-Changed the cameracontroller picture resolution from high to max and ultra. -Changed my dependecy to the newest version. -Changed to mlkit text recognition v2 -Tried using the google_ml_vision https://pub.dev/packages/google_ml_vision

(Its also not the case that these missing words/numbers dont get marked with a rectangle.)

You can use google_ml_kit package. It works with Google's standalone ML Kit. So no need to register project on firebase. It is a recommended package for standalone ml kit as firebase_ml_vission package is discontinued.

Recently google_ml_kit package is split into a set of packages. For text recognition, google_mlkit_text_recognition package is created.

For text recognition, you can use below code,

final textRecognizer = TextRecognizer();
final RecognizedText recognizedText = await textRecognizer.processImage(inputImage);

String text = recognizedText.text;
for (TextBlock block in recognizedText.blocks) {
  final Rect rect = block.rect;
  final List<Offset> cornerPoints = block.cornerPoints;
  final String text = block.text;
  final List<String> languages = block.recognizedLanguages;

  for (TextLine line in block.lines) {
    // Same getters as TextBlock
    for (TextElement element in line.elements) {
      // Same getters as TextBlock
    }
  }
}

To know, how to add text recognition using google_ml_kit, you can refer this link .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM