我应该如何为自定义相机设置曝光和白平衡值 [英] How should I set exposure and white balance values for custom camera

查看:19
本文介绍了我应该如何为自定义相机设置曝光和白平衡值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在Android自定义相机中初始化相机参数时没有设置曝光和白平衡会发生什么情况.相机是自己处理这些还是我需要在相机初始化时指定值?

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.

我设置了以下代码:

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);
    }

我了解到,当应用 autoExposureLock 和 autoWhiteBalanceLock 时,自动曝光和自动白平衡更新周期会停止.为什么以及如何在我的相机代码中使用这些锁定?

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?

推荐答案

根据我自己的开发,曝光和白平衡默认设置为自动":自动曝光和自动白平衡".

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"));

并检查当前模式:

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);

这篇关于我应该如何为自定义相机设置曝光和白平衡值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆