Win a copy of Java Challengers this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

Why isn't Google ML Kit Object Detection deteting objects?

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Marshal
Posts: 72657
317
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I didn't notice, but somebody else did, that this is an Andoird question, so I shall move you to our Android forum. And welcome to the Ranch
 
Bartender
Posts: 1304
39
IBM DB2 Netbeans IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Mason Buchanan
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@CampbellRitchie thank you very much! I'm so new to the site it means a lot that you were able to redirect my question to the proper place it needs to be asked.

@ClaudeMoore also, I thank you so much for your detailed response! I have been scouring the internet for even a semblance of guidance in resolving this question. I should probably add that I'm quite new to developing Java (and coding in general), and so my guidance in creating this application was through using this CameraX documentation for implementing a CameraX preview as well as this aforementioned Google ML Kit documentation on object detection. Would it be possible to isolate the two elements of image acquiring and object detection within the same MainActivity.java class?

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!
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic