从Android 17开始,它提供了android.media.effect包,用于处理具有许多效果的图像。并且使用官方样本'HelloEffect',它仅适用于图像。
现在我想要为Android相机预览框架应用效果,我使用SurfaceTexture
和GL_TEXTURE_EXTERNAL_OES
纹理从相机渲染帧。
但问题是如何在这个特殊纹理上应用效果:GL_TEXTURE_EXTERNAL_OES
,它显示错误,似乎无法从这种特殊纹理中采样。
错误:
01-06 15:46:35.425: D/libEGL(14021): loaded /vendor/lib/egl/libEGL_adreno.so 01-06 15:46:35.435: D/libEGL(14021): loaded /vendor/lib/egl/libGLESv1_CM_adreno.so 01-06 15:46:35.435: D/libEGL(14021): loaded /vendor/lib/egl/libGLESv2_adreno.so 01-06 15:46:35.435: I/Adreno-EGL(14021): : EGL 1.4 QUALCOMM build: _msm8974_refs/tags/AU_LINUX_ANDROID_JB_3.1.2.04.02.02.125.032_CL3849330_release_AU (CL3849330) 01-06 15:46:35.435: I/Adreno-EGL(14021): OpenGL ES Shader Compiler Version: 17.01.10.SPL 01-06 15:46:35.435: I/Adreno-EGL(14021): Build Date: 10/21/13 Mon 01-06 15:46:35.435: I/Adreno-EGL(14021): Local Branch: jb_3.1.2 01-06 15:46:35.435: I/Adreno-EGL(14021): Remote Branch: quic/4da73f3b691eea7a9356efff8d609916f1975107 01-06 15:46:35.435: I/Adreno-EGL(14021): Local Patches: NONE 01-06 15:46:35.435: I/Adreno-EGL(14021): Reconstruct Branch: NOTHING 01-06 15:46:35.565: D/OpenGLRenderer(14021): Enabling debug mode 0 01-06 15:46:36.295: W/Adreno-ES20(14021): : GL_INVALID_OPERATION 01-06 15:46:36.295: E/MCA(14021): GL Error: Operation 'Binding Texture' caused GL error (0x502) 01-06 15:46:36.295: E/MCA(14021): BindInputTextures failed 01-06 15:46:36.295: E/MCA(14021): Unable to render frame 01-06 15:46:36.295: E/MCA(14021): ShaderProgram: error processing shader! 01-06 15:46:36.305: W/dalvikvm(14021): threadid=11: thread exiting with uncaught exception (group=0x419fd898) 01-06 15:46:36.345: E/AndroidRuntime(14021): FATAL EXCEPTION: GLThread 97443 01-06 15:46:36.345: E/AndroidRuntime(14021): java.lang.RuntimeException: Error executing ShaderProgram! 01-06 15:46:36.345: E/AndroidRuntime(14021): at android.filterfw.core.ShaderProgram.process(ShaderProgram.java:123) 01-06 15:46:36.345: E/AndroidRuntime(14021): at android.filterfw.core.Program.process(Program.java:32) 01-06 15:46:36.345: E/AndroidRuntime(14021): at android.filterpacks.imageproc.LomoishFilter.process(LomoishFilter.java:200) 01-06 15:46:36.345: E/AndroidRuntime(14021): at android.filterfw.core.Filter.performProcess(Filter.java:474) 01-06 15:46:36.345: E/AndroidRuntime(14021): at android.filterfw.core.FilterFunction.execute(FilterFunction.java:80) 01-06 15:46:36.345: E/AndroidRuntime(14021): at android.filterfw.core.FilterFunction.executeWithArgList(FilterFunction.java:97) 01-06 15:46:36.345: E/AndroidRuntime(14021): at android.media.effect.SingleFilterEffect.apply(SingleFilterEffect.java:76) 01-06 15:46:36.345: E/AndroidRuntime(14021): at com.csz.camerafilters.activity.render.SurfaceRenderer.applyEffect(SurfaceRenderer.java:73) 01-06 15:46:36.345: E/AndroidRuntime(14021): at com.csz.camerafilters.activity.render.SurfaceRenderer.onDrawFrame(SurfaceRenderer.java:63) 01-06 15:46:36.345: E/AndroidRuntime(14021): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1531) 01-06 15:46:36.345: E/AndroidRuntime(14021): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1248)
答案 0 :(得分:3)
我可以使用适用于Android的OpenCV SDK在相机框架上应用效果。他们有一个现成的样本显示。
答案 1 :(得分:3)
Android效果将纹理绑定为GL_TEXTURE2D
,但您的纹理为GL_TEXTURE_EXTERNAL_OES
,这就是原因。生成GL_TEXTURE2D
的另一个纹理,在其上绘制相机框架,并一直使用此纹理。试试吧,这只是一个理论(基于我的OpenGL知识)。
答案 2 :(得分:1)
是的,在大多数设备中,您需要在着色器中启用 GL_OES_EGL_image_external 扩展名。查看sgxperf代码中的pszFragEGLImageShader
字符串https://github.com/prabindh/sgxperf/blob/master/sgxperf_gles20_vg.cpp
另请参阅Android OpenGL combination of SurfaceTexture (external image) and ordinary texture