Hi all! This post is a continuation of my earlier series: Machine Learning on Android using Firebase ML Kit.

In this blog post, I’ll be covering the steps to create an Android app that’s able to detect and count objects from the Camera Preview in real time.

There are tons of real-time object detection tutorials out there, so you might be wondering, How is this one any different? One key difference is that, instead of just detecting objects, we’ll also be counting objects in a given frame, opening up a much wider range of possible applications.

For example, imagine you’ve developed an app that suggests recipes to users based on the items they have at their disposal. By counting objects using camera-based, real-time object detection, you could empower your users to simply point the camera at the ingredients they have, and voilá!

Using an algorithm like this, the app would not only detect the ingredients but also identify the correct amounts needed for a recipe. So for instance, users could easily and seamlessly determine they don’t have enough apples for a pie or that they need more garlic for a delicious pasta sauce.

The magic of mobile machine learning has just made your users’ cooking or baking experience more convenient, more personalized, and more fun.

The best part about counting objects using real-time object detection is that inference happens on the device, without an active Internet connection (thanks to the Object Detection API provided by Fritz AI^). And the good news for us developers is, it won’t take us very long to do! We’ll try to finish the app in less than 5 minutes of coding!

Here’s a video showing what the finished app will look like:

Some Screenshots :