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 3.0.3.7 release ready!
Deniel Kerr
Founder. Opencart
Top Partners
In this blog, we will learn about implementing a Text Recognizer Using Camera and Firebase ML Kit.
With the updated firebase release, the developers have released new powers to image processing in a very easy and resource-friendly way.
Now, If you want you can use image processing and machine learning techniques in your application very easily using Firebase ML kit.
ML Kit is a mobile SDK that brings Google’s machine learning expertise to Android and iOS apps in a powerful yet easy-to-use package. Whether you’re new or experienced in machine learning, you can implement the functionality you need in just a few lines of code. There’s no need to have deep knowledge of neural networks or model optimization to get started. On the other hand, if you are an experienced ML developer, ML Kit provides convenient APIs that help you use your custom TensorFlow Lite models in your mobile apps. — Firebase Developer Guide
ML Kit is a mobile SDK that brings Google’s machine learning expertise to Android and iOS apps in a powerful yet easy-to-use package. Whether you’re new or experienced in machine learning, you can implement the functionality you need in just a few lines of code. There’s no need to have deep knowledge of neural networks or model optimization to get started. On the other hand, if you are an experienced ML developer, ML Kit provides convenient APIs that help you use your custom TensorFlow Lite models in your mobile apps.
— Firebase Developer Guide
Well, the firebase ML kit contains 5 options currently, which are :
We will currently focus on how we can recognize the text using the camera of an Android device.
Just a precap of what you will be able to do after reading this blog :
With these, you are good to go.
After these initial steps, you are good to start writing code for the text recognizer.
I have named my Activity as LauncherActivity.
Xml File :->
Java Class File( LauncherActivity ) : ->
TextRecognitionProcessor : –>
ResultAdapter :–>
camera_result_item (Xml File) : –>
Some other demos :
Sources :
https://firebase.google.com/docs/ml-kit/android/recognize-text
https://github.com/firebase/quickstart-android/tree/master/mlkit/
Keep coding and Keep Sharing 🙂
Your email address will not be published. Required fields are marked*
Name*
Email*
Save my name email and website in this browser for the next time I comment.
Regarding the black screen on the camera, for this the issue is that the CameraSourcePreview class is not initiating correctly in your code. Please do debug that code or share your code with us and we will help you with the same.
Hope this helps you.
You can ask me over here the issue you are facing and I will try to reply as soon as possible for me.
For Example, i have recieved the results in the method “onSuccess” of TextRecognitionProcessor.java which is a child of VisionProcessorBase
I personally modified the constructor of TextRecognitionProcessor.java and passed the instance of Launcher activity in the constructor.
You can also implement the same using interface as well.
If you still have any doubts, do let me know, i will help you as much as i can.
Can you post the code on how to do this (including the call back to the Launcher. “I personally modified the constructor of TextRecognitionProcessor.java and passed the instance of Launcher activity in the constructor.” thanks heaps Kingsley
“I personally modified the constructor of TextRecognitionProcessor.java and passed the instance of Launcher activity in the constructor.”
including the call back to the Launcher method. thanks heaps
The constructor of TextRecognitionProcessor.java will be like : public TextRecognitionProcessor(LauncherActivity activity) { detector = FirebaseVision.getInstance().getVisionTextDetector(); activityInstance = activity; }
Now in this your onSuccess method will be something like this :
@Override protected void onSuccess( @NonNull FirebaseVisionText results, @NonNull FrameMetadata frameMetadata, @NonNull GraphicOverlay graphicOverlay) { graphicOverlay.clear(); activityInstance.updateSpinnerFromTextResults(results); }
I am also adding this file in the article as well, so that you can refer it completely.
If still you have any confusions, please feel free to ask.
But the problem you are stating is most probably due to improper use of CameraSourcePreview Object.
Please cross check that before you access the camera have you initialized the camera source and then started it in on resume of your activity.
Please do check first if you have added the camera permission in your manifest file and are also checking for it as per the android api level.
Can you share me the code as i need it as very urgent basis and the MLKIT library is outdated.
Yes, the MLKIT library dependency mentioned in the blog is outdated, but then this is quite a common thing for firebase dependencies. You can still use this version if you want or even update, it is completely up to you and your use case.
Secondly, the blog in here is a complete reference to tell you how you can use this functionality. I do not have any code other than the files shared in the blog.
Still, If you want you can share your code and I will try to help you out
What exactly is the error you are facing?
Please do share some insight about the error so that I can look into it & help you.
ResultAdapter is just a simple recycler view Adapter class in which I have just inflated a text view and a background(just to make the views presentable). I have also mentioned the same in the comment along with the declaration of the ResultAdapter object.
Still, if you face any issue, then do let me know.
Can you share the ResultAdapter code here?
Please do have a look.
I have added the same in the last section of the Blog.
We use cookies to personalize your experience. By continuing to visit this website you agree to our use of cookies. Learn more about privacy policy
Excellent work, fast, good quality and understood the brief perfectly! Quick responses developing the project and very good cooperation. I suggest to anyone.
Stathis Plakidas
USA
India
Global
Name
Email
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.