Camera overlay

I still have not found a suitable way to show the overlay top of the camera preview,

There is a hack where you call

setContentView(GLSurfaceView)
addContentView(MyCameraSurfaceView)

but it does not work properly, i.e. when you switch to another job and go back, the opengl layer does not appear above the camera view.

there are many tutorials and examples that use the above method, but it just doesn't work as expected

Does anyone know how they do it in layar

+5
source share
2 answers

Looks like I found a solution to my problem - its function setZOrderMediaOverlay, heres my code:

private void initViews()
{
    mFrame = new FrameLayout(this);
    initCameraView();
    initGLView();
    setContentView( mFrame );
}
private void initGLView()
{
    mRenderer = new MyGLRenderer( this );
    mGLView = new GLSurfaceView(this);
    mGLView.setZOrderMediaOverlay(true);
    mGLView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
    mGLView.setRenderer(mRenderer); 
    mGLView.getHolder().setFormat(PixelFormat.TRANSLUCENT);

    mFrame.addView( mGLView );      
}

private void initCameraView()
{
    mCameraSurfaceView = new CameraSurfaceView(this);
    mFrame.addView(mCameraSurfaceView);     
}
+9
source

- , opengl gl-?

0

All Articles