Skip to content

InputImage from "fromMediaImage" method will lead Internal error after feed into FaceDetector while "fromBitmap" work as expected #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rideflag-yankai-tian opened this issue Jun 4, 2020 · 6 comments
Labels
android bug-library Potential bug in one of the ML Kit libraries

Comments

@rideflag-yankai-tian
Copy link

Platform: Android

Error occurs when feed InputImage from Camera2 by using InputImage.fromMediaImage() into FaceDetector.

com.google.mlkit.common.MlKitException: Internal error has occurred when executing ML Kit tasks at com.google.mlkit.common.sdkinternal.ModelResource.zza(com.google.mlkit:common@@16.0.0:28) at com.google.mlkit.common.sdkinternal.zzn.call(Unknown Source:6) at com.google.mlkit.common.sdkinternal.zzm.run(com.google.mlkit:common@@16.0.0:5) at com.google.mlkit.common.sdkinternal.zzq.run(com.google.mlkit:common@@16.0.0:3) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at com.google.android.gms.internal.mlkit_common.zzb.dispatchMessage(com.google.mlkit:common@@16.0.0:6) at android.os.Looper.loop(Looper.java:359) at android.os.HandlerThread.run(HandlerThread.java:67) Caused by: java.lang.IllegalStateException: Image is already closed at android.media.Image.throwISEIfImageIsInvalid(Image.java:72) at android.media.ImageReader$SurfaceImage$SurfacePlane.getBuffer(ImageReader.java:965) at com.google.android.gms.vision.Frame$Builder.setPlanes(com.google.android.gms:play-services-vision-common@@19.1.0:14) at com.google.mlkit.vision.face.internal.zza.zza(com.google.android.gms:play-services-mlkit-face-detection@@16.0.0:56) at com.google.mlkit.vision.face.internal.zza.zza(com.google.android.gms:play-services-mlkit-face-detection@@16.0.0:85) at com.google.mlkit.vision.face.internal.zza.run(com.google.android.gms:play-services-mlkit-face-detection@@16.0.0:164) at com.google.mlkit.vision.common.internal.MobileVisionBase.zza(com.google.mlkit:vision-common@@16.0.0:23) at com.google.mlkit.vision.common.internal.zzb.call(Unknown Source:4) at com.google.mlkit.common.sdkinternal.ModelResource.zza(com.google.mlkit:common@@16.0.0:26) at com.google.mlkit.common.sdkinternal.zzn.call(Unknown Source:6)  at com.google.mlkit.common.sdkinternal.zzm.run(com.google.mlkit:common@@16.0.0:5)  at com.google.mlkit.common.sdkinternal.zzq.run(com.google.mlkit:common@@16.0.0:3)  at android.os.Handler.handleCallback(Handler.java:883)  at android.os.Handler.dispatchMessage(Handler.java:100)  at com.google.android.gms.internal.mlkit_common.zzb.dispatchMessage(com.google.mlkit:common@@16.0.0:6)  at android.os.Looper.loop(Looper.java:359)  at android.os.HandlerThread.run(HandlerThread.java:67) 

In contrast, If convert preview frame to bitmap then create InputImage by using fromBitmap, everything works fine.

@thatfiredev
Copy link

@rideflag-yankai-tian it would be helpful if you could provide a Minimum Complete Verifiable Example Code so that we can see how you're using fromMediaImage().

@calren calren added bug-library Potential bug in one of the ML Kit libraries android labels Jun 6, 2020
@cs-googler
Copy link

Hi, could you provide some code snippets that show where you call image.close()? It is likely that you close the image too soon before mlkit is done with processing it.

@calren
Copy link
Collaborator

calren commented Jun 16, 2020

Hey @rideflag-yankai-tian, have you gotten a chance to follow up on this yet? This seems like a problem around when image.close() is called, so we were hoping you could provide the relevant code snippets to help us verify that.

@calren
Copy link
Collaborator

calren commented Jul 17, 2020

Hey @rideflag-yankai-tian , this issue hasn't had any activity for a month, so we'll consider it resolved for now! Feel free to reopen this issue if you are still able to reproduce it

@calren calren closed this as completed Jul 17, 2020
@Byte-Snipper
Copy link

Hey @calren, I had the same problem. And below is some code snippets.
Image image = reader.acquireLatestImage(); InputImage inputImage = InputImage.fromMediaImage(image, 0); image.close(); //handle inputImage here

@cs-googler
Copy link

Hi, the image is used for processing in the ML pipeline. You should close it in the detector's onComplete() listener instead to make sure the pipeline does not need it anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android bug-library Potential bug in one of the ML Kit libraries
Projects
None yet
Development

No branches or pull requests

5 participants