结合使用与表面纹理RenderScript [英] Using SurfaceTexture in combination with RenderScript

查看:277
本文介绍了结合使用与表面纹理RenderScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要做的摄像头图像处理上的android的GPU。

I want to do camera image processing on the GPU on android.

在我目前的设置我用的表面纹理捕获来自摄像机的图像流作为OpenGL ES的纹理帧。这是一种有效的方式来让相机入店流在我的着色器。 (<一href="http://developer.android.com/reference/android/graphics/SurfaceTexture.html">http://developer.android.com/reference/android/graphics/SurfaceTexture.html)

In my current set-up I use a SurfaceTexture to capture frames from the camera image stream as an OpenGL ES texture. This is an efficient way to get the camera stream accesible in my shaders. (http://developer.android.com/reference/android/graphics/SurfaceTexture.html)

现在我想开始使用直接OenGL ES使用的新RenderScript API代替。 (<一href="http://developer.android.com/guide/topics/renderscript/index.html">http://developer.android.com/guide/topics/renderscript/index.html)

Now i would like to start using the new RenderScript API instead of direct OenGL ES usage. (http://developer.android.com/guide/topics/renderscript/index.html)

但要创造一个表面纹理,我需要对OpenGL纹理ID传递给构造函数。不幸的是,纹理ID是不可用(RenderScript使用配置类别加载纹理,其不暴露纹理ID)。所以,我不能够使用RenderScript何时创建表面纹理。

But to create a SurfaceTexture, i need to pass the openGl Texture ID to the constructor. Unfortunately the texture ID is not available (RenderScript uses the Allocation class to load textures, which does not expose the texture ID). So i am not able to create a SurfaceTexture when using RenderScript.

我已经阅读renderscript所有文件(这仍然是pretty的稀疏),并看了看样品,但他们有没有关于该问题的信息。

I have read all documentation on renderscript (which is still pretty sparse) and looked at the samples, but they have no information on the subject.

所以我的问题是: 是否有可能使用表面纹理结合RenderScript,或者是有在一个RenderScript图形脚本中使用的现场摄像机流其他一些有效的方法?

So my question is: Is it possible to use SurfaceTexture in combination with RenderScript, or is there some other efficient way to use the live camera stream in a RenderScript Graphics script?

推荐答案

如果我理解正确的话,你已经使用表面纹理。然后,您可以注册一个回调<一个href="http://developer.android.com/reference/android/graphics/SurfaceTexture.html#setOnFrameAvailableListener%28android.graphics.SurfaceTexture.OnFrameAvailableListener%29"相对=nofollow> setOnFrameAvailableListener 。

If I understand correctly, you already use SurfaceTexture. You can then register a callback with setOnFrameAvailableListener.

我看到两种解决方案:

  1. 实现你自己的 RSTextureView ,它继承了<一个href="http://developer.android.com/reference/android/graphics/SurfaceTexture.OnFrameAvailableListener.html"相对=nofollow> SurfaceTexture.OnFrameAvailableListener 。注册您的视图作为表面纹理回调。 每次你的表面看法是由相机流的更新,你的 RSTextureView 将被告知,你可以处理它,你想​​要的方式。

  1. Implements you own RSTextureView, which inherits from SurfaceTexture.OnFrameAvailableListener. Register your view as the SurfaceTexture callback. Every time your surface view is updated by the camera stream, your RSTextureView will be notified and you can handle it the way you want.

另一种解决办法是实现自己的 RenderScriptGL (仍然继承 SurfaceTexture.OnFrameAvailableListener )和叫<一href="http://developer.android.com/reference/android/renderscript/RenderScriptGL.html#setSurfaceTexture%28android.graphics.SurfaceTexture,%20int,%20int%29"相对=nofollow> setSurfaceTexture 回调时被调用。

Another solution would be to implement your own RenderScriptGL (still inheriting from SurfaceTexture.OnFrameAvailableListener) and call setSurfaceTexture when the callback is called.

您应该能够 RenderScript 组合与表面纹理这两个解决方案中的至少一个。

You should be able to combine RenderScript with a SurfaceTexture with at least one of these two solutions.

这篇关于结合使用与表面纹理RenderScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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