How should I set exposure and white balance values

2019-03-25 07:23发布

问题:

What would happen if I do not set the exposure and white balance when initializing the camera parameters in an Android custom camera.Does the Camera handle these by itself or do I need to specify values when the camera is initialized?

I have had trouble with the flash in the past,would setting exposure and white balance to specific values help me overcome these problems.I do not have any plans to let the user manually tinker with the exposure and/or white balance settings.

I have the following code set up:

if(isSupported(Camera.Parameters.SCENE_MODE_AUTO, mParameters.getSupportedSceneModes()))
    {
        mSceneMode=Camera.Parameters.SCENE_MODE_AUTO;
        mParameters.setSceneMode(mSceneMode);
    }

    int min=mParameters.getMinExposureCompensation();
    int max=mParameters.getMaxExposureCompensation();
    float step=mParameters.getExposureCompensationStep();
    //do i need to setExposureCompensation here??
    if(mSceneMode==Camera.Parameters.SCENE_MODE_AUTO && isSupported(Camera.Parameters.FLASH_MODE_AUTO,mParameters.getSupportedFlashModes()))
    {
            //ususally when I let the flash fire,the image is filled with light
            //all that does is make everything else undecipherable...  
        mFlashMode=Camera.Parameters.FLASH_MODE_AUTO;
        mParameters.setFlashMode(mFlashMode);
    }

        if(isSupported(Camera.Parameters.WHITE_BALANCE_AUTO,mParameters.getSupportedWhiteBalance()))
    {
        mWhiteBalanceMode=Camera.Parameters.WHITE_BALANCE_AUTO;
        mParameters.setWhiteBalance(mWhiteBalanceMode);
    }

I have read that auto-exposure and auto-white balance update cycles are stopped when autoExposureLock and autoWhiteBalanceLock are applied.Why and how should I use these locks in my camera code?

回答1:

Based on my own development, Exposure and White Balance are by default set to "Auto": Auto-exposure" and "Auto White Balance".

You can check the supported modes with:

mCameraParameters = mCamera.getParameters();
Log.i(TAG, "Supported Exposure Modes:" + mCameraParameters.get("exposure-mode-values"));    
Log.i(TAG, "Supported White Balance Modes:" + mCameraParameters.get("whitebalance-values"));

and check the current modes with:

Log.i(TAG, "Exposure setting = " + mCameraParameters.get("exposure")); 
Log.i(TAG, "White Balance setting = " + mCameraParameters.get("whitebalance")); 

if you want to use another mode you could set it like this:

mCameraParameters.set("exposure", "night");
mCamera.setParameters(mCameraParameters);