![]() |
VOOZH | about |
Nowadays many apps using Machine Learning inside their apps to make most of the tasks easier. We have seen many apps that detect text from any image. This image may include number plates, images, and many more. In this article, we will take a look at the implementation of Text Detector in Android using Firebase ML Kit.
We will be building a simple application in which we will be capturing an image of any text inside our app and we will then extract the text from that particular image and display that text inside a text field. A sample video is given below to get an idea about what we are going to do in this article. Note that we are going to implement this project using the Java language.
To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. Note that select Java as the programming language.
After creating a new project in Android Studio connect your app to Firebase. For connecting your app to firebase. Navigate to Tools on the top bar. After that click on Firebase. A new window will open on the right side. Inside that window click on Firebase ML and then click on Use Firebase ML to recognize text in the image. You can see the option below screenshot.
👁 ImageAfter clicking on this option you will get to see the below screen. On this screen click on Connect to Firebase option to connect your app to Firebase. You will get to see the below screen.
👁 ImageClick on Connect option to connect your app to Firebase and add the below dependency to your build.gradle file.
Navigate to the app > Gradle Scripts > build.gradle file and add the below code to it. Comments are added in the code to get to know in more detail.
Note: Use the following version(15.0.0) for the firebase ML kit if you are getting some error in the MainActivity.java file.
// dependency for firebase ml kit
implementation 'com.google.firebase:firebase-ml-vision:15.0.0'// dependency for firebase core.
implementation'com.google.firebase:firebase-core:15.0.2'
Navigate to the app > AndroidManifest.xml file and add the below code to it. Comments are added in the code to get to know in more detail.
Navigate to the app > res > layout > activity_main.xml and add the below code to that file. Below is the code for the activity_main.xml file.
Go to the MainActivity.java file and refer to the following code. Below is the code for the MainActivity.java file. Comments are added inside the code to understand the code in more detail.
Now run your app and see the output of the app.