Android平台使用openGL ES 2.0实现预览摄像头数据功能

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u012218652/article/details/76889351

因为项目需要,做了一个例子实现这个功能。

参考博文:

http://blog.csdn.net/oShunz/article/details/50055057

http://blog.csdn.net/oShunz/article/category/5952777

http://blog.csdn.net/chylove5/article/details/49637535


Android中从Camera回调获取的数据是type[]类型,格式为YUV420sp,需要将格式转换为RGBA格式,以纹理贴图的形式显示在GLSurfaceView中。

本文中实现的数据格式的转换是在shader中完成的。

代码都是java中实现的,没有调用jni。


本文实现的例子发在了github上供参考:

https://github.com/linuhap/OpenGLESCameraTest

使用Smartisan T1测试通过。

测试截图:

(上面是OpenGL显示,下面是在Surfaceview中直接显示)


猜你喜欢

转载自blog.csdn.net/u012218652/article/details/76889351