Android SurfaceView Preview Blurry

两盒软妹~` 提交于 2019-12-04 05:58:40

There are two reason why your image and preview may appear blurry

1) the way you are settings the picture size and preview size is wrong. You have to query the supported sizes and decide which is the best size for you and set size from the list that your have got. You cannot give arbit values. Check this sample app for implementation details - https://github.com/josnidhin/Android-Camera-Example

2) you have to put your camera in auto foucs mode so that it will focus automatically. (better is to implement a touch to focus with a proper ui). Once your camera starts just set the below

private void setCamFocusMode(){

    if(null == mCamera) {
        return;
     }

    /* Set Auto focus */ 
    Parameters parameters = mCamera.getParameters();
    List<String>    focusModes = parameters.getSupportedFocusModes();
    if(focusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)){
        parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);   
    } else 
    if(focusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO)){
        parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
    }   

    mCamera.setParameters(parameters);
}

make sure your have the proper permission in your manifest

Hope this helps

Regards, Shrish

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