能否在与相机连接的SurfaceTexture上绘制?

4
我想在连接到相机的SurfaceTexture上绘制,通过SurfaceTextureListener可以获得SurfaceTexture。但是如果我尝试使用eglCreateWindowSurface和eglMakeCurrent,由于表面已经连接,它会失败。
1)是否有可能在此表面上绘制?或者将其绑定到相机是否使得这不可能?
2)如果不可能,该表面能否快速地用OpenGL纹理使用或复制到另一个表面中?如果可以,如何实现?
3)如果不行,获取相机预览并将其传递给OpenGL的最快方法是什么?
还要注意,给我带来连接问题的代码是受Romain Guy在这里发布的帖子所启发的:http://groups.google.com/group/android-developers/browse_thread/thread/539457146a401cf1
1个回答

6

是的,这是可能的,实际上这就是SurfaceTexture存在的原因。问题在于我当时想反了。为了让它们正常工作,你需要执行以下步骤:

1) Create a texture through OpenGL.
2) Pass this texture to the constructor of new SurfaceTexture.
3) Give this new SurfaceTexture to the camera.
4) Make sure you are using OES_External (see documentation for
details).

我的最大问题是尝试弄清楚如何进行相反的操作。也就是说,创建一个SurfaceTexture并将其传递到OpenGL中。但实际上正确的做法是相反的。


1
有趣,谢谢。你是如何创建EGL上下文来创建OpenGL纹理的?你有GLSurfaceView吗?谢谢。 - user1906
这里是用户1906发布问题并获得答案的地方:https://dev59.com/hGAg5IYBdhLWcg3wnMG3#23380229 - ToolmakerSteve

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接