本文介绍了修改和更新通过GLSurfaceView画幅相机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用 GLSurfaceView 活动的工作,以显示在Android设备上的摄像头帧。正如我在的OpenGL ES我福利局,我想知道我怎么可以得到图像缓冲区并修改它,然后显示在手机上修改后的框架?

在我的渲染器类,它实现 GLSurfaceView.Renderer ,我调用本机的功能:

 公共类实现渲染{GLSurfaceView.Renderer
  公共无效onDrawFrame(GL10 GL){
    MyJNINative.render();
  }
...
}

API 我有工作,但前提是能够通过一些访问图像缓冲区像<$一个 connectCallBack 方法C $ C> onFrameAvailableNow 。
所以,我已经在图像缓冲区是不幸为const 键入。所以,我修改它不会体现出来。

现在我的问题是如何添加一些 GL 的方法来修改可以在显示屏上得到体现图像缓冲区?

我的本地渲染器:

  Java_com_project_MyJNINative_render(
        JNIEnv的*,jobject){
    //比方说,我这里有图像缓冲区称为uint_8t *缓冲区
    glClearColor(1.0F,1.0F,1.0F,1.0F);
    glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);    glViewport(0,0,宽度,高度);    // UpdateTexture()
    api_handler.UpdateTexture());
    gl_vid_obj-&GT;渲染(GLM :: mat4(1.0F),GLM :: mat4(1.0F));
    ///我需要一些code这里设置缓冲GL
}


解决方案

法登解释的,你不能改变$被连接到表面纹理p $ PVIEW缓冲器。但是,你的可以的获得与<一的preVIEW缓冲区href=\"http://developer.android.com/reference/android/hardware/Camera.$p$pviewCallback.html#on$p$pviewFrame(byte[],%20android.hardware.Camera)\"相对=nofollow> 上previewFrame() ,修改并推动通过结果的。有两个缺陷:你应该隐藏实际的preVIEW(可能将其连接到会不会对你的GL表面可见纹理),你应该做的所有的处理速度足够快(至少为$ P 20 FPS $ PVIEW看起来更自然)。

I am working with a GLSurfaceView activity to display the camera frame on an android device. As I am newb in OpenGl Es, I wondered how I can get the image buffer and modify it, then display the modified frame on the phone?

In my Renderer class which implements GLSurfaceView.Renderer, I call a native function:

public class Renderer implements GLSurfaceView.Renderer {
  public void onDrawFrame(GL10 gl) {
    MyJNINative.render();
  }
...
}

The API I am working with, provided a connectCallBack method that enables accessing image buffer via something like onFrameAvailableNow.So I have already the image buffer which is unfortunately of const type. So my modifications to it will not get reflected.

Now my question is how to add some gl methods to modify the image buffer that can be reflected on the display?

My native renderer:

Java_com_project_MyJNINative_render(
        JNIEnv*, jobject) {
    // Let's say I have image buffer here called "uint_8t* buffer"
    glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
    glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);

    glViewport(0, 0, width, height);

    // UpdateTexture() 
    api_handler.UpdateTexture());
    gl_vid_obj->Render(glm::mat4(1.0f), glm::mat4(1.0f));    
    /// I NEED SOME CODE HERE TO set gl buffer
}
解决方案

As fadden explained, you cannot change the preview buffer that is connected to SurfaceTexture. But you can obtain the preview buffers with onPreviewFrame(), modify it and push the result to OpenGL via glTexSubImage2D(). There are two pitfalls: you should hide the actual preview (probably connecting it to a texture that will not be visible on your GL surface), and you should do all processing fast enough (20 FPS at least for the "preview" to look natural).

这篇关于修改和更新通过GLSurfaceView画幅相机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 00:58