I'm currently working on a mobile application using CameraX and Google ML Kit written in Java (on Android Studio). The purpose of the application is to detect objects with a real time camera preview. I was able to build the base CameraX Preview which works absolutely fine. After doing this, I implemented ML Kit using this guide aptly titled "Detect and track objects with ML Kit on Android" (base model option) to detect objects in successive frames within the application.
However, upon running the application, it launches on my device and the camera preview continues to work but the application does not carry out its intended effect of actually detecting objects and displaying it on my screen. In an attempt to resolve it, I debugged the onSuccess within my process method using Log.d(..) in order to determine the size of the returned object list. However, upon running the application, the Android Studio logcat had printed D/TAG: onSuccess0 upwards of up to 20 times within several seconds of running the application. Would this mean that the application is not detecting any objects? This has bugged me since I had followed the documentation exactly.
Here is the necessary code within my MainActivity:
Any resolution or even indication as to why the ML Kit Object Detector isn't working would help tons. Any additional information needed to supplement this question will be provided upon request.
Welcome to the ranch ! I'm not an Android expert, but the first thing I suggest you to to is to clearly separate object detection task from image acquiring.
Google ML Kit you're using is unlikely to be buggy. I'd try to create a plain Java SE regular program and experiment with it passing to the kit static images from some folder; I would put the whole process of recognizing images in a separate helper class to be used later on Android app.
Once you verified that you're using Google ML Kit correctly - sorry to say that, but with ML very often the devil is in little details , I would try to use the same helper class on Android.
This way you should be able to isolate the culprit.
Also, the application does acquire images within the camera preview. According to my attempt in debugging onSuccess within the analyze() method, the application does not return any object list size (as evidenced by the Logcat printing D/TAG: onSuccess0) allowing me to arrive at that conclusion. Once again, any further guidance would be greatly appreciated, even though I understand your expertise doesn't lay fully within Android development!
A "dutch baby" is not a baby. But this tiny ad is baby sized: