Android App Development
iOS 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 18.104.22.168 release ready!
In this article, we are going to learn Image recognition from the camera in Flutter.
Image labeling gives you insight into the content of images. With ML Kit’s image labeling APIs, we can detect and extract information about entities in an image across a broad group of categories. The default image labeling model can identify general objects, places, activities, animal species, products, and more. Please check Google ML Kit for more on Image Labeling.
For text recognition using Google ML Kit check out this blog.
For image labeling 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.
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 ImageLabeler 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, imageLabeler.processImage(inputImage) is the main method for labeling 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.
Be the first to comment.
Webkul is a truly trusted and supported IT Company to develop business ideas for e-commerce. They provide professional support after deploying the solution to production and be responsible to act for fixing the reported issues or system errors. We highly encourage to deal with Webkul for business development.
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.