首页 > 解决方案 > Camerax 如何将自动白平衡锁定设置为 true,extender.setCaptureRequestOption 不起作用

问题描述

我正在尝试在 camerax 中实现自动白平衡锁定,但我遇到了一种情况。当我想将自动白平衡锁定设置为真并拍照时,我的照片只有黑色。我正在为此工作很长时间。有什么我错过的吗?

这是我使用扩展器设置camerax属性的方法:

注意:自动曝光锁定正在工作。

 private void setExtender(Camera2Interop.Extender<?> extender) {
    /* if exposure compensation set before it sets compensation value, if not sets auto exposure */
    if (mIsSetExposureCompensation) {
        camera.getCameraControl().setExposureCompensationIndex(exposureCompensation);
        extender.setCaptureRequestOption(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, exposureCompensation);
    }
    // when setExposureCompensation is true then getAutoExposureLock will return true
    extender.setCaptureRequestOption(CaptureRequest.CONTROL_AE_LOCK, getAutoExposureLock());
    /* sets auto white balance */
    extender.setCaptureRequestOption(CaptureRequest.CONTROL_AWB_MODE, CaptureRequest.CONTROL_AWB_MODE_AUTO);
    extender.setCaptureRequestOption(CaptureRequest.CONTROL_AWB_LOCK, getAutoWhiteBalanceLock());
}

标签: androidandroid-camera2android-cameraxextender

解决方案


推荐阅读