gpt4 book ai didi

java.lang.RuntimeException : ImageReaderContext is not initialized

转载 作者:行者123 更新时间:2023-12-04 13:48:06 26 4
gpt4 key购买 nike

mImageReader = ImageReader.newInstance(mWidth, mHeight, PixelFormat.RGBA_8888, 4);
mVirtualDisplay = mMediaProjection.createVirtualDisplay(TAG, mWidth, mHeight, mDPI,DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR, mImageReader.getSurface(), getimg(), null);
image = mImageReader.acquireLatestImage();

12-14 13:57:06.893: W/System.err(15177): java.lang.RuntimeException: ImageReaderContext is not initialized 12-14 13:57:06.927: W/System.err(15177): at android.media.ImageReader.nativeImageSetup(Native Method) 12-14 13:57:06.961: W/System.err(15177): at android.media.ImageReader.acquireNextSurfaceImage(ImageReader.java:298) 12-14 13:57:06.992: W/System.err(15177): at android.media.ImageReader.acquireNextImage(ImageReader.java:344) 12-14 13:57:07.024: W/System.err(15177): at com.zed1.luaservice.ScreenService.acquireLatestImage(ScreenService.java:109) 12-14 13:57:07.056: W/System.err(15177): at com.top.colour.ColorUtil.snap(ColorUtil.java:89) 12-14 13:57:07.087: W/System.err(15177): at com.top.colour.FindImageFuzzy.execute(FindImageFuzzy.java:55) 12-14 13:57:07.111: W/System.err(15177): at org.keplerproject.luajava.LuaState._call(Native Method) 12-14 13:57:07.138: W/System.err(15177): at org.keplerproject.luajava.LuaState.call(LuaState.java:602) 12-14 13:57:07.165: W/System.err(15177): at com.zed1.server.LuaService.call(LuaService.java:33) 12-14 13:57:07.193: W/System.err(15177): at com.zed1.server.LuaThread.callLua(LuaThread.java:71) 12-14 13:57:07.220: W/System.err(15177): at com.zed1.server.LuaThread.run(LuaThread.java:49)

最佳答案

我遇到了同样的问题,但不是在我的设备上,而是在我的一位客户身上。我在 this 上发现了一些东西地点。他们使用以下代码:

Image image;
try {
image = mImageReader.acquireLatestImage();
} catch (RuntimeException e) {
/* In API level 23 or below, it will throw "java.lang.RuntimeException:
ImageReaderContext is not initialized" when ImageReader is closed. To make the
behavior consistent as newer API levels, we make it return null Image instead.*/
if (isImageReaderContextNotInitializedException(e)) {
image = null;
} else {
throw e; // only catch RuntimeException:ImageReaderContext is not initialized
}
}
if (image == null) {
return null;
}



private boolean isImageReaderContextNotInitializedException(RuntimeException e) {
return "ImageReaderContext is not initialized".equals(e.getMessage());
}
我还不知道它是否能解决问题,因为我的设备上没有发生崩溃。让我知道它是否有帮助。

关于java.lang.RuntimeException : ImageReaderContext is not initialized,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41136391/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com