Shainnah Jane
Shainnah Jane

Reputation: 231

Flutter Crop Image and Text recognition

Is somebody know how can I crop the captured image in the flutter. I just want to recognize the specific image text by cropping the captured image.

I just want to crop the hello world and exclude the Acer from the image. I want to crop just like this 2nd image. Any help is much-appreciated it very helpful for me, thanks in advance.

enter image description here enter image description here

This is what I have

  Future getImage() async {   //  I want to have a crop option when getting the image.
    final pickedFile = await picker.getImage(source: ImageSource.camera);
    setState(() {
      if (pickedFile != null) {
        _image = pickedFile;
      } else {
        print('No image selected');
        log('data:ELSE');
      }
    });
  }

Future scanText() async {
    final FirebaseVisionImage visionImage =
        FirebaseVisionImage.fromFile(File(_image.path));
    final TextRecognizer textRecognizer =
        FirebaseVision.instance.textRecognizer();
    final VisionText visionText =
        await textRecognizer.processImage(visionImage);

    for (TextBlock block in visionText.blocks) {
      for (TextLine line in block.lines) {
        _text += line.text + '\n';
      }
    }
    Navigator.of(context).pop();
    Navigator.of(context)
        .push(MaterialPageRoute(builder: (context) => Details(_text)));
  }

Upvotes: 4

Views: 1037

Answers (1)

Pratik Dudhatratra
Pratik Dudhatratra

Reputation: 372

The firebase_ml_vision is now discontinued. Please use the google_ml_kit package for text recognition. you can find out more from Here.

Upvotes: 1

Related Questions