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

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

问题描述

如果在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"));

并使用以下命令检查当前模式:

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

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

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