相机预览的Textureview/Surface视图-Android [英] Textureview/Surface view for Camera preview - Android

查看:99
本文介绍了相机预览的Textureview/Surface视图-Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发使用相机的Android应用程序.为了显示相机预览,我观察了很多使用表面视图或纹理视图的示例.与使用ImageView来显示摄像机预览相比,为什么这些方法更受青睐?我使用Imageview来显示预览并且效果很好.

I am working on developing an Android applications that uses camera. To display the camera preview, I observed a lot of examples using surface view or texture view. Why are these preferred over using ImageView to display the camera preview? I have used Imageview to display the preview and it works fine.

谢谢.

推荐答案

请不要为此使用ImageView.这种方法效率极低,如果您能够使用这种方法生成高分辨率预览(1080p),我会感到惊讶.

Please do not use ImageView for this. It is extremely inefficient, and I'd be surprised if you are able to produce high-resolution preview (1080p) with this approach.

SurfaceView和TextureView都将零拷贝缓冲区分别从相机驱动程序直接推送到硬件编辑器或GPU.除了需要在目的地进行任何最终转换外,没有多余的缓冲区副本或转换.这样可以大大减少内存带宽和CPU开销.

SurfaceView and TextureView both directly push zero-copy buffers from the camera drivers to the hardware composer or the GPU, respectively. There are no extra buffer copies or transformations, except whatever final conversions need to be done at the destination. This reduces memory bandwidth and CPU overhead substantially.

创建位图很慢,占用大量CPU,并且每帧制作多个副本,也浪费了内存.

Creating Bitmaps is slow, CPU-hungry, and makes several copies of each frame, wasting memory as well.

这篇关于相机预览的Textureview/Surface视图-Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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