Medium Text Recognition – Extract Data

Home   »   Medium Text Recognition – Extract Data

  Future _scanImage(BuildContext context) async {
    String textFromPic = '';
    setState(() {
      _scanResults = null;
    });
    final FirebaseVisionImage visionImage =FirebaseVisionImage.fromFile(_image);
    dynamic results;
    results = await _cloudRecognizer.processImage(visionImage);
    String text = results.text;
    for (TextBlock block in results.blocks) {
      for (TextLine line in block.lines) {
        // Same getters as TextBlock
        for (TextElement element in line.elements) {
          // Same getters as TextBlock
          print(element.text);
          textFromPic = textFromPic + element.text+'\n';
        }
      }
    }
    //We show the text from the image in a dialog
    showText(context, textFromPic);
    setState(() {
      _scanResults = results;
    });
  }

Leave a Reply

Your email address will not be published. Required fields are marked *