You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
InputImage from "fromMediaImage" method will lead Internal error after feed into FaceDetector while "fromBitmap" work as expected #4
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.
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.
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.
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
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
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.
Activity
thatfiredev commentedon Jun 4, 2020
@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().cs-googler commentedon Jun 8, 2020
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 commentedon 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 commentedon 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
Byte-Snipper commentedon Aug 20, 2020
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 herecs-googler commentedon Jan 20, 2021
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.