采用了android相机创建色度键效果的第一步 [英] First steps in creating a chroma key effect using android camera

查看:291
本文介绍了采用了android相机创建色度键效果的第一步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个使用Android相机色度键效果。我并不需要一步一步来,但我想知道劫持Android相机和应用过滤器的最佳途径。我已经签出的API,并没有发现任何有关如何操作数据来自摄像机的超级权威性。起初,我看着使用表面纹理,但我不完全知道如何帮助或如何甚至使用它。然后我检查了使用GLSurfaceView,这可能是正确的方向,但真的不知道。

I'd like to create a chroma key effect using the android camera. I don't need a step by step, but I'd like to know the best way to hijack the android camera and apply the filters. I've checked out the API and haven't found anything super definitive on how to manipulate data coming from the camera. At first I looked into using a surface texture, but I'm not fully aware how that helps or how to even use it. Then I checked out using a GLSurfaceView, which may be the right direction, but not really sure.

另外,添加到我的问题,我将如何处理图像的两个preVIEW和保存?我会以最低的处理图像,两次?有一次,previewing一旦同时节省?我认为这可能是最好的解决方案。

Also, to add to my question, how would I handle both preview and saving of the image? Would I process the image at minimum, twice? Once while previewing and once while saving? I think that's probably the best solution.

最后,将有意义创建一个C / ++包装处理的处理,优化速度?

Lastly, would it make sense to create a C/++ wrapper to handle the processing to optimize speed?

任何帮助都将大大AP preciated。一些例子的链接也将是极大的AP preciated。

Any help at all would be greatly appreciated. A link to some examples would also be greatly appreciated.

感谢。

推荐答案

唯一真正的机会是使用OpenGL ES和片段着色器(它至少需要的OpenGL ES 2.0),并做GPU的色度键效果。着色器本身将是很容易的(谷歌)。

The only real chance is to use openGL ES and fragment shader (it will require at least openGL ES 2.0) and do the chroma key effect on GPU. The shader itself will be quite easy (google).

但要做到这一点,你需要回调来显示摄像机preVIEW。你将不得不实行 相机。previewCallback ,创建图像数据的缓冲区,并使用集previewCallbackWithBuffer 方法。你可以得到基本的想法从我的回答以类似的问题。需要注意的是与此自定义相机preVIEW的性能显著的问题,但它可能会在支持ES 2.0。硬件上工作

But to do that, you need to display camera preview with callback. You will have to implement Camera.PreviewCallback, create a buffer for image data and use setPreviewCallbackWithBuffer method. You can get the basic idea from my answer to a similar question. Note that there is a significant problem with performance of this custom camera preview, but it might work on hardware that supports ES 2.0.

要显示preVIEW与OpenGL,则需要扩展 GLSurfaceView 并也实现了 GLSurfaceView.Renderer 。然后你会绑定相机preVIEW框架与 glTexImage2D 纹理一些简单的矩形,其余由着色器处理。了解如何在ES 这里使用着色器,或者如果你有着色器没有经验,< A HREF =htt​​p://blog.shayanjaved.com/2011/03/13/shaders-android/相对=nofollow>本教程可能是一个良好的开端。

To display the preview with openGL, you will need to extend GLSurfaceView and also implement GLSurfaceView.Renderer. Then you will bind the camera preview frame as a texture with glTexImage2D to some simple rectangle and the rest will be handled by shaders. See how to use shaders in ES here or if you have no experience with shaders, this tutorial might be a good start.

要其他的问题:你可以节省从preVIEW当前图像,但preVIEW具有比拍摄图片分辨率较低,所以你可能会想要拍张照片,然后分别处理它(你可以使用它一样着色器)。

To the other question: you could save the current image from the preview, but the preview has lower resolution than a taken picture, so you will probably want to take a picture and then process it separately (you could use the same shader for it).

对于C ++,它的很多可疑输出额外的努力。但是,如果做得好的话,可以提高性能。尝试检查此文章,的是一个类似的话题,它描述了如何使用NDK来处理摄像头preVIEW和OpenGL显示它。但是,如果你想这样做C ++中的色度键效果,会比着色器显著慢。

As for the C++, it's a lot of additional effort with questionable output. But it can improve performance if done right. Try to check this article, it's on a similar topic, it describes how to use NDK to process camera preview and display it in openGL. But if you were thinking about doing the chroma key effect in C++, it would be significantly slower than shaders.

这篇关于采用了android相机创建色度键效果的第一步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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