【Android Camera1】Camera1 Parameters参数详解(二)—— 3A算法 (对焦、曝光、白平衡)

一、简介

本篇文章将介绍Camera1 Parameters参数设置里和3A算法相关的具体Key。3A算法的理论知识可参看:Camera理论知识和基本原理

注意:

  1. 本篇文章只涉及对相关的参数以及参数设置后的效果进行介绍。不涉及到具体3A相关功能的开发。
  2. 对焦功能、曝光功能、闪光灯功能、白平衡功能都是极其复杂的庞大需求。需要单独系统性的去讲解
  3. 强烈建议在参看本文时和后续Camera1系列文章之对焦、曝光、闪光灯、白平衡一起浏览。

1.1 后续相关文章预告:

  • 【Android Camera1】Camera1 对焦(一) 对焦之UI坐标系和相机坐标系
  • 【Android Camera1】Camera1 对焦(二) 多场景下对焦区域计算【正常、缩放、拍照、视频、闪光灯】
  • 【Android Camera1】Camera1 对焦(三) 对焦区域计算的几种方式
  • 【Android Camera1】Camera1 对焦(四) 对焦标准化转换流程
  • 【Android Camera1】Camera1 对焦(五) 拍照场景下的对焦处理
  • 【Android Camera1】Camera1 闪光灯系列文章

1.2 3A算法补充介绍

在Android Camera中,实际的3A 算法取决于 HAL 实现。应用层可通过设置不同的模式,或者触发不同的3A算法状态转换来针对不同场景实现对应的效果。

  1. Camera1中对3A算法相关封装的很彻底,应用层只能通过仅限的几个相关Parameters来控制Lens。
  2. Camera2则提供应用层更多的操控空间,可以更加精细化的操作。

1.3 相关Parameter KEY

Key变量名 Key变量值
KEY_FLASH_MODE flash-mode
KEY_FOCUS_MODE focus-mode
KEY_FOCUS_AREAS focus-areas
KEY_MAX_NUM_FOCUS_AREAS max-num-focus-areas
KEY_EXPOSURE_COMPENSATION exposure-compensation
KEY_MAX_EXPOSURE_COMPENSATION max-exposure-compensation
KEY_MIN_EXPOSURE_COMPENSATION min-exposure-compensation
KEY_EXPOSURE_COMPENSATION_STEP exposure-compensation-step
KEY_AUTO_EXPOSURE_LOCK auto-exposure-lock
KEY_AUTO_EXPOSURE_LOCK_SUPPORTED auto-exposure-lock-supported
KEY_AUTO_WHITEBALANCE_LOCK auto-whitebalance-lock
KEY_AUTO_WHITEBALANCE_LOCK_SUPPORTED auto-whitebalance-lock-supported
KEY_WHITE_BALANCE whitebalance
KEY_METERING_AREAS metering-areas
KEY_MAX_NUM_METERING_AREAS max-num-metering-areas
KEY_FOCUS_DISTANCES focus-distances

二 AF:对焦

2.1 对焦模式

对焦模式
FOCUS_MODE_AUTO
FOCUS_MODE_INFINITY
FOCUS_MODE_MACRO
FOCUS_MODE_FIXED
FOCUS_MODE_EDOF
FOCUS_MODE_CONTINUOUS_VIDEO
FOCUS_MODE_CONTINUOUS_PICTURE

2.2 对焦模式说明

以上对焦模式中最常用的是

  • FOCUS_MODE_AUTO
  • FOCUS_MODE_CONTINUOUS_PICTURE
  • FOCUS_MODE_CONTINUOUS_VIDEO

其他对焦模式几乎在实际使用场景中使用不到,具体的对焦模式跟Lens有关系,因此切换到对应对焦模式时,要判断该Camera Lens是否支持相应的对焦模式。

2.2.1 FOCUS_MODE_AUTO(“auto”)

语义上可以把该模式理解为单次对焦

/**
 * Auto-focus mode. Applications should call {@link
 * #autoFocus(AutoFocusCallback)} to start the focus in this mode.
 */
public static final String FOCUS_MODE_AUTO = "auto";

分析:

  1. 最常见的对焦模式,通常使用在自动触发中心区域对焦点击区域对焦
  2. 切换到该模式之前要判断相机是否支持该模式即如下代码1。不支持则返回
  3. 切换至该模式通常配合Parameter Keysfocus-mode focus-areas max-num-focus-areas 使用,设置对应的对焦区域。
  4. 一般只有后置Lens支持该模式。前置Lens不支持。
  5. 切换到该模式,且设置相关参数,需要代码2触发使用,具体详细的对焦功能开发,请移至对焦相关文章参看。

代码1:


mCameraParameters.getSupportedFocusModes()?.contains(FOCUS_MODE_AUTO);

代码2:

//1.切换到auto模式
//2.设置相关参数
mCamera.autoFocus(new Camera.AutoFocusCallback() {
    
    
    @Override
    public void onAutoFocus(boolean success, Camera camera) {
    
    
        //......
    }
});

2.2.2 FOCUS_MODE_CONTINUOUS_PICTURE(“continuous-picture”)

语义上可以把该模式理解为连续对焦

/**
  * Continuous auto focus mode intended for taking pictures. The camera
  * continuously tries to focus. The speed of focus change is more
  * aggressive than {@link #FOCUS_MODE_CONTINUOUS_VIDEO}. Auto focus
  * starts when the parameter is set.
  *
  * <p>Applications can call {@link #autoFocus(AutoFocusCallback)} in
  * this mode. If the autofocus is in the middle of scanning, the focus
  * callback will return when it completes. If the autofocus is not
  * scanning, the focus callback will immediately return with a boolean
  * that indicates whether the focus is sharp or not. The apps can then
  * decide if they want to take a picture immediately or to change the
  * focus mode to auto, and run a full autofocus cycle. The focus
  * position is locked after autoFocus call. If applications want to
  * resume the continuous focus, cancelAutoFocus must be called.
  * Restarting the preview will not resume the continuous autofocus. To
  * stop continuous focus, applications should change the focus mode to
  * other modes.
  *
  * @see #FOCUS_MODE_CONTINUOUS_VIDEO
  */
 public static final String FOCUS_MODE_CONTINUOUS_PICTURE = "continuous-picture";

分析

  1. 默认在非录制视频场景下使用该模式
  2. 该模式为持续不断自动触发对焦流程
  3. 自动触发对焦过程中,正好遇到用户行为响应autoFocus,当单次对焦处在扫描中,连续对焦会等单次对焦完成对焦流程返回。
  4. 如果单次对焦没有处在扫描中,连续对焦会立马返回是否对焦成功
  5. 单次对焦autoFocus call会锁定住对焦点通过设置对应Parameter Key
  6. 单次对焦切换至连续对焦 需要调用cancelAutoFocus

2.2.3 FOCUS_MODE_CONTINUOUS_VIDEO(“continuous-video”)

语义上可以把该模式理解为视频模式下的连续对焦

/**
 * Continuous auto focus mode intended for video recording. The camera
 * continuously tries to focus. This is the best choice for video
 * recording because the focus changes smoothly . Applications still can
 * call {@link #takePicture(Camera.ShutterCallback,
 * Camera.PictureCallback, Camera.PictureCallback)} in this mode but the
 * subject may not be in focus. Auto focus starts when the parameter is
 * set.
 *
 * <p>Since API level 14, applications can call {@link
 * #autoFocus(AutoFocusCallback)} in this mode. The focus callback will
 * immediately return with a boolean that indicates whether the focus is
 * sharp or not. The focus position is locked after autoFocus call. If
 * applications want to resume the continuous focus, cancelAutoFocus
 * must be called. Restarting the preview will not resume the continuous
 * autofocus. To stop continuous focus, applications should change the
 * focus mode to other modes.
 *
 * @see #FOCUS_MODE_CONTINUOUS_PICTURE
 */
public static final String FOCUS_MODE_CONTINUOUS_VIDEO = "continuous-video";

分析

  1. 推荐在录制视频场景下使用该模式
  2. 因为是录制视频,the focus changes smoothly;其他和continuous-picture类似

2.2.4 FOCUS_MODE_MACRO(“macro”)

语义上可以把该模式理解为近距离下的单次对焦

 /**
  * Macro (close-up) focus mode. Applications should call
  * {@link #autoFocus(AutoFocusCallback)} to start the focus in this
  * mode.
  */
 public static final String FOCUS_MODE_MACRO = "macro";

分析:

  1. 实际场景中,几乎不会使用该模式

2.2.5 FOCUS_MODE_EDOF(“edof”)

/**
 * Macro (close-up) focus mode. Applications should call
 * {@link #autoFocus(AutoFocusCallback)} to start the focus in this
 * mode.
 */
public static final String FOCUS_MODE_MACRO = "macro";

分析:

  1. 高级扩展景深对焦。该模式下没有自动对焦扫描,因此触发或取消操作均无效
  2. 实际场景中,不会使用该模式,不考虑

2.2.6 FOCUS_MODE_FIXED(“fixed”)

/**
 * Focus is fixed. The camera is always in this mode if the focus is not
 * adjustable. If the camera has auto-focus, this mode can fix the
 * focus, which is usually at hyperfocal distance. Applications should
 * not call {@link #autoFocus(AutoFocusCallback)} in this mode.
 */
public static final String FOCUS_MODE_FIXED = "fixed";

分析:

  1. 固定焦距下对焦模式
  2. 实际场景中,不会使用该模式,不考虑

2.3 相关Parameters Key

说明: AF相关
相关KEY focus-mode
focus-mode-values
focus-areas
max-num-focus-areas
focus-distances
方法 public List getFocusAreas()
public int getMaxNumFocusAreas()
public void getFocusDistances(float[] output)
public void setFocusAreas(List focusAreas)
public void setFocusMode(String value)
public List getSupportedFocusModes()
public String getFocusMode()

2.3.1 FOCUS-MODE

/**
 * Gets the current focus mode setting.
 *
 * @return current focus mode. This method will always return a non-null
 *         value. Applications should call {@link
 *         #autoFocus(AutoFocusCallback)} to start the focus if focus
 *         mode is FOCUS_MODE_AUTO or FOCUS_MODE_MACRO.
 * @see #FOCUS_MODE_AUTO
 * @see #FOCUS_MODE_INFINITY
 * @see #FOCUS_MODE_MACRO
 * @see #FOCUS_MODE_FIXED
 * @see #FOCUS_MODE_EDOF
 * @see #FOCUS_MODE_CONTINUOUS_VIDEO
 */
public String getFocusMode() {
    
    
    return get(KEY_FOCUS_MODE);
}

/**
 * Gets the supported focus modes.
 *
 * @return a list of supported focus modes. This method will always
 *         return a list with at least one element.
 * @see #getFocusMode()
 */
public List<String> getSupportedFocusModes() {
    
    
    String str = get(KEY_FOCUS_MODE + SUPPORTED_VALUES_SUFFIX);
    return split(str);
}

/**
 * Sets the focus mode.
 *
 * @param value focus mode.
 * @see #getFocusMode()
 */
public void setFocusMode(String value) {
    
    
    set(KEY_FOCUS_MODE, value);
}

分析:

  1. 通过getSupportedFocusModes()方法获取当前Camera Lens支持的focus-mode
  2. 通过setFocusMode()方法设置对应的对焦模式。具体的对焦模式可参看上文具体的分析

2.3.2 FOCUS-AREA

/**
 * <p>Gets the current focus areas. Camera driver uses the areas to decide
 * focus.</p>
 *
 * <p>Before using this API or {@link #setFocusAreas(List)}, apps should
 * call {@link #getMaxNumFocusAreas()} to know the maximum number of
 * focus areas first. If the value is 0, focus area is not supported.</p>
 *
 * <p>Each focus area is a rectangle with specified weight. The direction
 * is relative to the sensor orientation, that is, what the sensor sees.
 * The direction is not affected by the rotation or mirroring of
 * {@link #setDisplayOrientation(int)}. Coordinates of the rectangle
 * range from -1000 to 1000. (-1000, -1000) is the upper left point.
 * (1000, 1000) is the lower right point. The width and height of focus
 * areas cannot be 0 or negative.</p>
 *
 * <p>The weight must range from 1 to 1000. The weight should be
 * interpreted as a per-pixel weight - all pixels in the area have the
 * specified weight. This means a small area with the same weight as a
 * larger area will have less influence on the focusing than the larger
 * area. Focus areas can partially overlap and the driver will add the
 * weights in the overlap region.</p>
 *
 * <p>A special case of a {@code null} focus area list means the driver is
 * free to select focus targets as it wants. For example, the driver may
 * use more signals to select focus areas and change them
 * dynamically. Apps can set the focus area list to {@code null} if they
 * want the driver to completely control focusing.</p>
 *
 * <p>Focus areas are relative to the current field of view
 * ({@link #getZoom()}). No matter what the zoom level is, (-1000,-1000)
 * represents the top of the currently visible camera frame. The focus
 * area cannot be set to be outside the current field of view, even
 * when using zoom.</p>
 *
 * <p>Focus area only has effect if the current focus mode is
 * {@link #FOCUS_MODE_AUTO}, {@link #FOCUS_MODE_MACRO},
 * {@link #FOCUS_MODE_CONTINUOUS_VIDEO}, or
 * {@link #FOCUS_MODE_CONTINUOUS_PICTURE}.</p>
 *
 * @return a list of current focus areas
 */
public List<Area> getFocusAreas() {
    
    
    return splitArea(get(KEY_FOCUS_AREAS));
}

public void setFocusAreas(List<Area> focusAreas) {
    
    
    set(KEY_FOCUS_AREAS, focusAreas);
}


/**
 * Gets the maximum number of focus areas supported. This is the maximum
 * length of the list in {@link #setFocusAreas(List)} and
 * {@link #getFocusAreas()}.
 *
 * @return the maximum number of focus areas supported by the camera.
 * @see #getFocusAreas()
 */
public int getMaxNumFocusAreas() {
    
    
    return getInt(KEY_MAX_NUM_FOCUS_AREAS, 0);
}

分析:

  1. getMaxNumFocusAreas()获取当前Camera Lens支持对焦区域的个数。如果为0则表示不支持对焦固定的输入区域
  2. 通过设置focus-area来控制Camera Lens针对特定的区域进行对焦
  3. focus-area是一个rect。范围为【-1000,1000】,weight:【1,1000】,可参看Camera1源码分析【Java层】【2.1】
  4. setFocusAreas(null) -> 交给Camera自己控制
  5. 和zoom值没关系。区域对应的始终是zoom=1.0x的画面。详细可参看后续Camera1对焦之zoom

2.3.3 focus-distance

/**
 * <p>Gets the distances from the camera to where an object appears to be
 * in focus. The object is sharpest at the optimal focus distance. The
 * depth of field is the far focus distance minus near focus distance.</p>
 *
 * <p>Focus distances may change after calling {@link
 * #autoFocus(AutoFocusCallback)}, {@link #cancelAutoFocus}, or {@link
 * #startPreview()}. Applications can call {@link #getParameters()}
 * and this method anytime to get the latest focus distances. If the
 * focus mode is FOCUS_MODE_CONTINUOUS_VIDEO, focus distances may change
 * from time to time.</p>
 *
 * <p>This method is intended to estimate the distance between the camera
 * and the subject. After autofocus, the subject distance may be within
 * near and far focus distance. However, the precision depends on the
 * camera hardware, autofocus algorithm, the focus area, and the scene.
 * The error can be large and it should be only used as a reference.</p>
 *
 * <p>Far focus distance >= optimal focus distance >= near focus distance.
 * If the focus distance is infinity, the value will be
 * {@code Float.POSITIVE_INFINITY}.</p>
 *
 * @param output focus distances in meters. output must be a float
 *        array with three elements. Near focus distance, optimal focus
 *        distance, and far focus distance will be filled in the array.
 * @see #FOCUS_DISTANCE_NEAR_INDEX
 * @see #FOCUS_DISTANCE_OPTIMAL_INDEX
 * @see #FOCUS_DISTANCE_FAR_INDEX
 */
public void getFocusDistances(float[] output) {
    
    
    if (output == null || output.length != 3) {
    
    
        throw new IllegalArgumentException(
                "output must be a float array with three elements.");
    }
    splitFloat(get(KEY_FOCUS_DISTANCES), output);
}

分析

  1. 评估对焦成功画面物体离Camera Lens的距离
  2. 只读,无法设置。

三 AE:曝光

3.1 相关Parameter Keys

说明: AE相关
相关KEY auto-exposure-lock-supported
exposure-compensation
max-exposure-compensation
min-exposure-compensation
exposure-compensation-step
auto-exposure-lock
metering-areas
max-num-metering-areas
方法 public int getExposureCompensation()
public void setExposureCompensation(int value)
public int getMaxExposureCompensation()
public int getMinExposureCompensation()
public float getExposureCompensationStep()
public void setAutoExposureLock(boolean toggle)
public boolean getAutoExposureLock()
public boolean isAutoExposureLockSupported()
public boolean getAutoExposureLock()
public List getMeteringAreas()
public int getMaxNumMeteringAreas()
public void setMeteringAreas(List meteringAreas)

3.2 ExposureCompensation

用户通过设置曝光补偿来额外调节预览和拍照过程中的画面亮度。

/**
 * Sets the exposure compensation index.
 *
 * @param value exposure compensation index. The valid value range is
 *        from {@link #getMinExposureCompensation} (inclusive) to {@link
 *        #getMaxExposureCompensation} (inclusive). 0 means exposure is
 *        not adjusted. Application should call
 *        getMinExposureCompensation and getMaxExposureCompensation to
 *        know if exposure compensation is supported.
 */
public void setExposureCompensation(int value) {
    
    
    set(KEY_EXPOSURE_COMPENSATION, value);
}

/**
 * Gets the exposure compensation step.
 *
 * @return exposure compensation step. Applications can get EV by
 *         multiplying the exposure compensation index and step. Ex: if
 *         exposure compensation index is -6 and step is 0.333333333, EV
 *         is -2.
 */
public float getExposureCompensationStep() {
    
    
    return getFloat(KEY_EXPOSURE_COMPENSATION_STEP, 0);
}

分析:

  1. setExposureCompensation 首先需要通过getMinExposureCompensation和getMaxExposureCompensation来判断是否支持。
  2. EV(Exposure Value) = getExposureCompensationStep() * getExposureCompensation()

3.3 AutoExposureLock

/**
 * <p>Sets the auto-exposure lock state. Applications should check
 * {@link #isAutoExposureLockSupported} before using this method.</p>
 *
 * <p>If set to true, the camera auto-exposure routine will immediately
 * pause until the lock is set to false. Exposure compensation settings
 * changes will still take effect while auto-exposure is locked.</p>
 *
 * <p>If auto-exposure is already locked, setting this to true again has
 * no effect (the driver will not recalculate exposure values).</p>
 *
 * <p>Stopping preview with {@link #stopPreview()}, or triggering still
 * image capture with {@link #takePicture(Camera.ShutterCallback,
 * Camera.PictureCallback, Camera.PictureCallback)}, will not change the
 * lock.</p>
 *
 * <p>Exposure compensation, auto-exposure lock, and auto-white balance
 * lock can be used to capture an exposure-bracketed burst of images,
 * for example.</p>
 *
 * <p>Auto-exposure state, including the lock state, will not be
 * maintained after camera {@link #release()} is called.  Locking
 * auto-exposure after {@link #open()} but before the first call to
 * {@link #startPreview()} will not allow the auto-exposure routine to
 * run at all, and may result in severely over- or under-exposed
 * images.</p>
 *
 * @param toggle new state of the auto-exposure lock. True means that
 *        auto-exposure is locked, false means that the auto-exposure
 *        routine is free to run normally.
 *
 * @see #getAutoExposureLock()
 */
public void setAutoExposureLock(boolean toggle) {
    
    
    set(KEY_AUTO_EXPOSURE_LOCK, toggle ? TRUE : FALSE);
}

/**
 * Gets the state of the auto-exposure lock. Applications should check
 * {@link #isAutoExposureLockSupported} before using this method. See
 * {@link #setAutoExposureLock} for details about the lock.
 *
 * @return State of the auto-exposure lock. Returns true if
 *         auto-exposure is currently locked, and false otherwise.
 *
 * @see #setAutoExposureLock(boolean)
 *
 */
public boolean getAutoExposureLock() {
    
    
    String str = get(KEY_AUTO_EXPOSURE_LOCK);
    return TRUE.equals(str);
}

/**
 * Returns true if auto-exposure locking is supported. Applications
 * should call this before trying to lock auto-exposure. See
 * {@link #setAutoExposureLock} for details about the lock.
 *
 * @return true if auto-exposure lock is supported.
 * @see #setAutoExposureLock(boolean)
 *
 */
public boolean isAutoExposureLockSupported() {
    
    
    String str = get(KEY_AUTO_EXPOSURE_LOCK_SUPPORTED);
    return TRUE.equals(str);
}

分析:

  1. 相机会自动进行AE的控制
  2. 如果设置setAutoExposureLock(true)AE会锁住失效,通过EV设置控制
  3. setAutoExposureLock前通过isAutoExposureLockSupported()判断是否支持

3.4 METER-AREA

/**
 * <p>Gets the current metering areas. Camera driver uses these areas to
 * decide exposure.</p>
 *
 * <p>Before using this API or {@link #setMeteringAreas(List)}, apps should
 * call {@link #getMaxNumMeteringAreas()} to know the maximum number of
 * metering areas first. If the value is 0, metering area is not
 * supported.</p>
 *
 * <p>Each metering area is a rectangle with specified weight. The
 * direction is relative to the sensor orientation, that is, what the
 * sensor sees. The direction is not affected by the rotation or
 * mirroring of {@link #setDisplayOrientation(int)}. Coordinates of the
 * rectangle range from -1000 to 1000. (-1000, -1000) is the upper left
 * point. (1000, 1000) is the lower right point. The width and height of
 * metering areas cannot be 0 or negative.</p>
 *
 * <p>The weight must range from 1 to 1000, and represents a weight for
 * every pixel in the area. This means that a large metering area with
 * the same weight as a smaller area will have more effect in the
 * metering result.  Metering areas can partially overlap and the driver
 * will add the weights in the overlap region.</p>
 *
 * <p>A special case of a {@code null} metering area list means the driver
 * is free to meter as it chooses. For example, the driver may use more
 * signals to select metering areas and change them dynamically. Apps
 * can set the metering area list to {@code null} if they want the
 * driver to completely control metering.</p>
 *
 * <p>Metering areas are relative to the current field of view
 * ({@link #getZoom()}). No matter what the zoom level is, (-1000,-1000)
 * represents the top of the currently visible camera frame. The
 * metering area cannot be set to be outside the current field of view,
 * even when using zoom.</p>
 *
 * <p>No matter what metering areas are, the final exposure are compensated
 * by {@link #setExposureCompensation(int)}.</p>
 *
 * @return a list of current metering areas
 */
public List<Area> getMeteringAreas() {
    
    
    return splitArea(get(KEY_METERING_AREAS));
}

/**
 * Sets metering areas. See {@link #getMeteringAreas()} for
 * documentation.
 *
 * @param meteringAreas the metering areas
 * @see #getMeteringAreas()
 */
public void setMeteringAreas(List<Area> meteringAreas) {
    
    
    set(KEY_METERING_AREAS, meteringAreas);
}

/**
 * Gets the maximum number of detected faces supported. This is the
 * maximum length of the list returned from {@link FaceDetectionListener}.
 * If the return value is 0, face detection of the specified type is not
 * supported.
 *
 * @return the maximum number of detected face supported by the camera.
 * @see #startFaceDetection()
 */
public int getMaxNumDetectedFaces() {
    
    
    return getInt(KEY_MAX_NUM_DETECTED_FACES_HW, 0);
}

分析:

  1. 参看【2.3.2】focus-area;逻辑基本是一致的
  2. 区别是该区域是用来测光的

四、AWB 白平衡

4.1 相关Parameter Key

说明: AWB相关
相关KEY auto-whitebalance-lock
auto-whitebalance-lock-supported
whitebalance
方法 public String getWhiteBalance()
public List getSupportedWhiteBalance()
public boolean getAutoWhiteBalanceLock()
public void setWhiteBalance(String value)
public void setAutoWhiteBalanceLock(boolean toggle)

4.2 AWB Lock

lock基本用法和AE类似,就不具体阐述了

  /**
   * <p>Sets the auto-white balance lock state. Applications should check
   * {@link #isAutoWhiteBalanceLockSupported} before using this
   * method.</p>
   *
   * <p>If set to true, the camera auto-white balance routine will
   * immediately pause until the lock is set to false.</p>
   *
   * <p>If auto-white balance is already locked, setting this to true
   * again has no effect (the driver will not recalculate white balance
   * values).</p>
   *
   * <p>Stopping preview with {@link #stopPreview()}, or triggering still
   * image capture with {@link #takePicture(Camera.ShutterCallback,
   * Camera.PictureCallback, Camera.PictureCallback)}, will not change the
   * the lock.</p>
   *
   * <p> Changing the white balance mode with {@link #setWhiteBalance}
   * will release the auto-white balance lock if it is set.</p>
   *
   * <p>Exposure compensation, AE lock, and AWB lock can be used to
   * capture an exposure-bracketed burst of images, for example.
   * Auto-white balance state, including the lock state, will not be
   * maintained after camera {@link #release()} is called.  Locking
   * auto-white balance after {@link #open()} but before the first call to
   * {@link #startPreview()} will not allow the auto-white balance routine
   * to run at all, and may result in severely incorrect color in captured
   * images.</p>
   *
   * @param toggle new state of the auto-white balance lock. True means
   *        that auto-white balance is locked, false means that the
   *        auto-white balance routine is free to run normally.
   *
   * @see #getAutoWhiteBalanceLock()
   * @see #setWhiteBalance(String)
   */
  public void setAutoWhiteBalanceLock(boolean toggle) {
    
    
      set(KEY_AUTO_WHITEBALANCE_LOCK, toggle ? TRUE : FALSE);
  }

  /**
   * Gets the state of the auto-white balance lock. Applications should
   * check {@link #isAutoWhiteBalanceLockSupported} before using this
   * method. See {@link #setAutoWhiteBalanceLock} for details about the
   * lock.
   *
   * @return State of the auto-white balance lock. Returns true if
   *         auto-white balance is currently locked, and false
   *         otherwise.
   *
   * @see #setAutoWhiteBalanceLock(boolean)
   *
   */
  public boolean getAutoWhiteBalanceLock() {
    
    
      String str = get(KEY_AUTO_WHITEBALANCE_LOCK);
      return TRUE.equals(str);
  }

  /**
   * Returns true if auto-white balance locking is supported. Applications
   * should call this before trying to lock auto-white balance. See
   * {@link #setAutoWhiteBalanceLock} for details about the lock.
   *
   * @return true if auto-white balance lock is supported.
   * @see #setAutoWhiteBalanceLock(boolean)
   *
   */
  public boolean isAutoWhiteBalanceLockSupported() {
    
    
      String str = get(KEY_AUTO_WHITEBALANCE_LOCK_SUPPORTED);
      return TRUE.equals(str);
  }

4.2 AWB Mode

/**
 * Gets the current white balance setting.
 *
 * @return current white balance. null if white balance setting is not
 *         supported.
 * @see #WHITE_BALANCE_AUTO
 * @see #WHITE_BALANCE_INCANDESCENT
 * @see #WHITE_BALANCE_FLUORESCENT
 * @see #WHITE_BALANCE_WARM_FLUORESCENT
 * @see #WHITE_BALANCE_DAYLIGHT
 * @see #WHITE_BALANCE_CLOUDY_DAYLIGHT
 * @see #WHITE_BALANCE_TWILIGHT
 * @see #WHITE_BALANCE_SHADE
 *
 */
public String getWhiteBalance() {
    
    
    return get(KEY_WHITE_BALANCE);
}

场景:白织灯光下的墙面
1.不同AWB模式设置下的效果

在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述

五、 END

后续将阐述:
【Android Camera1】Camera1 Parameters参数详解(三)—— Zoom,Other

猜你喜欢

转载自blog.csdn.net/Scott_S/article/details/122330341