转换android.media.Image(YUV_420_888)为位图 [英] Convert android.media.Image (YUV_420_888) to Bitmap

查看:5076
本文介绍了转换android.media.Image(YUV_420_888)为位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用摄像机2 API来实现摄像头preVIEW图像数据处理如下建议:<一href="http://stackoverflow.com/questions/25462277/camera-$p$pview-image-data-processing-with-android-l-and-camera2-api">Camera preVIEW图像数据处理与Android L和摄像机2 API 。

I'm trying to implement camera preview image data processing using camera2 api as proposed here: Camera preview image data processing with Android L and Camera2 API.

我成功地接收使用onImageAvailableListener回调,但对于未来的处理我需要从YUV_420_888 android.media.Image得到位图。我搜索了类似的问题,但没有人帮助。

I successfully receive callbacks using onImageAvailableListener, but for future processing I need to obtain bitmap from YUV_420_888 android.media.Image. I searched for similar questions, but none of them helped.

能否请你建议我如何转换android.media.Image(YUV_420_888)为位图或者有听力为preVIEW帧更好的办法?

Could you please suggest me how to convert android.media.Image (YUV_420_888) to Bitmap or maybe there's a better way of listening for preview frames?

推荐答案

我写了一些code关于这一点,它的YUV DATAS preVIEW和昌它为JPEG DATAS,我可以用它来保存为位图,byte []的,还是其他人。(你可以看到类分配)。

和SDK文件说:
对于高效的YUV处理与android.renderscript:创建一个RenderScript分配具有受支持的YUV类型,IO_INPUT标志,和由getOutputSizes(Allocation.class)返回的尺寸之一,然后获得表面采用getSurface()。

这里是code,希望它会帮助你:的https://github.com/pinguo-yuyidong/Camera2/blob/master/camera2/src/main/rs/yuv2rgb.rs

I write some code about this, and it's the YUV datas preview and chang it to JPEG datas ,and I can use it to save as bitmap ,byte[] ,or others.(You can see the class "Allocation" ).

And SDK document says:
"For efficient YUV processing with android.renderscript: Create a RenderScript Allocation with a supported YUV type, the IO_INPUT flag, and one of the sizes returned by getOutputSizes(Allocation.class), Then obtain the Surface with getSurface()."

here is the code, hope it will help you:https://github.com/pinguo-yuyidong/Camera2/blob/master/camera2/src/main/rs/yuv2rgb.rs

这篇关于转换android.media.Image(YUV_420_888)为位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆