如何在camera2 api中控制flash?

时间:2017-04-24 06:02:57

标签: android android-camera2 camera2

我正在使用https://github.com/googlesamples/android-Camera2Basic项目来创建我自己的应用程序,但是当我添加代码来控制闪存(开,关,自动)时。

private void setAutoFlash(CaptureRequest.Builder requestBuilder) {
    if (mFlashSupported) {

        if(FLASH_STATUS == 0) {
            requestBuilder.set(CaptureRequest.CONTROL_AE_MODE,
                    CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH);
        }
        else if(FLASH_STATUS == 1){
            requestBuilder.set(CaptureRequest.FLASH_MODE,
                    CaptureRequest.FLASH_MODE_SINGLE);
        }else if (FLASH_STATUS == 2){
            requestBuilder.set(CaptureRequest.FLASH_MODE,
                    CaptureRequest.FLASH_MODE_OFF);
        }

    }
}

在不同的设备上表现不同。是否有任何解决方案在每台设备上表现一致?

0 个答案:

没有答案