Hide camera preview but still receive preview callbacks

萝らか妹 提交于 2019-12-02 01:19:54

问题


I want to show filtered camera preview in my application.

I'm using Camera.setPreviewCallback() for this. I managed to process callback data and show filtered image in OpenGL view but I have no idea how to hide original camera preview and still receive preview callbacks. Making surface view "gone" or "invisible" doesn't work, making it small enough (10x10) to hide behind GUI doesn't work either. It just stops sending callbacks with preview data.

Can you share some workaround on this? I'm testing using Galaxy S2.

Thank you in advance.


回答1:


A solution is to even though set the Preview Size to be as the actual screen, in the onMeasure of the Preview SurfaceView make it smaller, that works for me:

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
{  
   this.setMeasuredDimension(2, 2);  
}



回答2:


Create a simple View with a black background color. Position the view at the same position as the camera's SurfaceView. The camera's preview will be effectively hidden.



来源:https://stackoverflow.com/questions/9653563/hide-camera-preview-but-still-receive-preview-callbacks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!