Camera2闪光灯:自动曝光关闭时如何控制闪光灯设置(CONTROL_AE_MODE_OFF)

时间:2018-10-22 05:48:51

标签: android-camera android-camera2

我在camera2上工作,用户可以在此开关ON / OFF。用户还可以在不同的闪光模式之间切换(开,关,自动)。下面是处理相同代码的

public void updateBuilder(@NonNull CaptureRequest.Builder requestBuilder) {
        if (mIsFlashSupported) {
            switch (mFlashMode) {
            case FLASH_ON:
                requestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON_ALWAYS_FLASH);
                requestBuilder.set(CaptureRequest.FLASH_MODE, CameraMetadata.FLASH_MODE_OFF);
                break;
            case FLASH_OFF:
                requestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON);
                requestBuilder.set(CaptureRequest.FLASH_MODE, CameraMetadata.FLASH_MODE_OFF);
                break;
            case FLASH_AUTO:
                requestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON_AUTO_FLASH);
                requestBuilder.set(CaptureRequest.FLASH_MODE, CameraMetadata.FLASH_MODE_OFF);
                break;
            case TORCH:
                requestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON);
                requestBuilder.set(CaptureRequest.FLASH_MODE, CameraMetadata.FLASH_MODE_TORCH);
                break;
            }
        } else {
            requestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON);
            requestBuilder.set(CaptureRequest.FLASH_MODE, CameraMetadata.FLASH_MODE_OFF);
        }

        if (!mAutoExposure) {
            requestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_OFF);
            requestBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, (long) (mShutterSpeed * 1000000000L));
            requestBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, mIso);
            requestBuilder.set(CaptureRequest.SENSOR_FRAME_DURATION, mFrameDuration);
        }
}

问题为,当mAutoExposure设置为False(关闭自动曝光时)。 Flash停止工作,可能是因为第二行if块中的这一行

requestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_OFF);

有人可以让我知道,即使关闭自动曝光也如何启用闪光灯控制

0 个答案:

没有答案