Win a copy of liveProject: Protecting User Data with Spring Security and OAuth2 this week in the Spring 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 is Google's ML Face Detection Kit crashing on .process()

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am creating a face detector app which will detect faces in real time and identify landmarks on faces. The landmarks for the faces are working perfectly fine, however my real time face detection isn't working at all.

I followed the instructions in Google's ML Kit(https://developers.google.com/ml-kit/vision/face-detection/android), but am really struggling to obtain the functionality in real time face detection.

In my debugger, the code crashes at `facedetector.process(image).addOnSuccessListener()` and instead goes into the `onFailure()`

This is cross-posted from stack overflow, so my code and error is there: https://stackoverflow.com/questions/67217419/why-is-googles-ml-face-detection-kit-crashing-on-process

Please help if possible. Thank you.
 
Saloon Keeper
Posts: 6917
163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is using ML Kit required? I've found it easy to detect faces using the camera API'S built-in face detection: https://www.bytefish.de/blog/face_detection_with_android.html
 
Joe McMillan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I was actually able to do this using ML detection already, but am struggling to get real time detection(so when the camera turns on and you move your face in real-time, the detector detects parts of your face like the nose, eyes, eyebrows, etc.). Thanks.
 
Joe McMillan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please note, I am using https://github.com/natario1/CameraView this library for CameraView and https://github.com/ArthurHub/Android-Image-Cropper this for cropping image. Thanks.
 
Joe McMillan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any help would be appreciated a lot. Thanks.
 
Tim Moores
Saloon Keeper
Posts: 6917
163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What does "I am struggling to get ..." mean? What does the code do, or what does it not do? Post the relevant code excerpts and indicate which parts work and which parts don't.
 
Joe McMillan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. The code crashes on this line:

Code excerpt:



The rest is just a bunch of for loops looping over each contour. Thanks.
 
Joe McMillan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This piece of code is supposed to detect contours on the face in real-time. This means just drawing onto the face in real-time(so as the camera moves canvas will draw onto the face to detect the left eyebrows, nose, mouth, etc.).

This piece of code isn't functional.

On the other hand, I have another detector which detects contours(nose, mouth, etc.) on a photo(so not in real-time). This piece of code is functional in my analyse method(I called this landmark paint).

Thanks.
 
Bartender
Posts: 2854
150
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Joe McMillan wrote:...In my debugger, the code crashes at `facedetector.process(image).addOnSuccessListener()` and instead goes into the `onFailure()`...


What's the error you are facing? I am pretty sure that the api should give some kind of meaningful information in the Exception message :
 
Joe McMillan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. I looked again, and now the code is crashing after the InputImage.

in my debugger the code crashes and goes into CameraView.java where it says "Frame Processor Crashed."

I've tried using Log.d("error", Log.getStackTraceString(new Exception())) after the InputMessage and in onErrorListener(), but it doesn't print out anything.
Edit: It's now printing out this:

Thanks, Krish
 
salvin francis
Bartender
Posts: 2854
150
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I could guess, the "D/" means debug logs, "W/" means warn, "I/" means Info and "E/" means error.
This narrows down to these two logger statements:


I suggest researching on EGL_BAD_ATTRIBUTE. I can't help more. Sorry.
 
Joe McMillan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I did some research, couldn't really find anything. I'm also getting this error now: call to OpenGL ES API with no current context.

I found these two posts:
https://stackoverflow.com/questions/18807857/opengl-es-2-0-context-in-android
https://stackoverflow.com/questions/11286819/opengl-es-api-with-no-current-context

...but can't really connect how this relates to my project. Any idea how to resolve this error? Thanks.
 
Marshal
Posts: 3489
494
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you running your app in the emulator or on real hardware?  The emulator might require some specific configuration for simulate the device's GPU - just a guess.
 
Joe McMillan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I tried running it on a real device through USB connection, no luck. Thanks- Krish
 
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