Android App Development
iOS App Development
Flutter App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 126.96.36.199 release ready!
Updated 27 April 2023
In this article, we are going to learn Text recognition from the camera in Flutter.
Recognizes the text from the image/ real-time camera. The ML Kit Text Recognition API can recognize text in any Latin-based character set. Please check Google ML Kit for more on Text recognition.
Check out more about our Flutter app development.
For text recognition in Flutter, we are going to use these flutter plugins: google_ml_kit and camera.
google_ml_kit: for the text recognition and many more, please check the official pub here.
camera: for accessing the device cameras, image stream which we are going to use later and for more check here.
Before we get started read about the platform-specific requirements here and known issues of the google_ml_kit plugin here.
And for the camera plugin platform-specific requirements check here and for the known issues check here.
We start by adding these plugins to our project’s pubspec.yaml file:
After adding the plugins, import them into your camera_screen.dart file like:
Now define your camera controller and initialize it inside initState method and Initialize TextDetector like this:
Once the camera is initialized, we start streaming images from the platform camera using the startImageStream method and pass the _processCameraImage method which is defined below as the parameter to it:
As you can see in the above code, textDetector.processImage(inputImage) is the main method for recognizing the text from the image and requires an InputImage type image as a parameter so first, we need to get the InputImage for the recognition from the CameraImage and we are getting this using getInputImage(image) method defined below:
Now create your CameraPreview widget for creating a preview widget for the given camera controller. and pass the above-defined CameraController like:
And put the above camera preview widget inside your build method like any other widget and that’s it.
Thanks for reading.
Happy Coding 🙂
For more Flutter tutorials visit Mobikul Blogs.
Your email address will not be published. Required fields are marked*
Save my name email and website in this browser for the next time I comment.
Yes, it supports live text recognition. You can try it by making a sample app from the above code.
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.