捕捉图片Android Camera 2 Api时保持手电筒模式的问题?

时间:2018-01-10 08:30:33

标签: android android-camera2

我正在尝试使用Android Camera2 Api捕捉图片。一切都很顺利。但是,我遇到了一个问题。因此,当我的应用加载时,火炬会在预览会话期间打开。但我的目标是当我拍照时,火炬不会消失。现在,当我拍照时,它会切换到闪光模式然后再回到手电筒模式。我不希望它闪光,而是火炬在相机捕捉期间保持开启状态。我该怎么做呢?

 mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
                                if(autoflashstate==0){
                                    //turn on torch
                                   mPreviewRequestBuilder.set(CaptureRequest.FLASH_MODE, CameraMetadata.FLASH_MODE_TORCH);
                                    mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_REGIONS, new MeteringRectangle[]{focusAreaTouch});
                                    mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_REGIONS, new MeteringRectangle[]{insideFocusAreaTouch});

                                }

                              /*  else{
                                    //turn off flash light and then turn on torch
                                    unlockAutoFlash(mPreviewRequestBuilder);
                                    mPreviewRequestBuilder.set(CaptureRequest.FLASH_MODE, CameraMetadata.FLASH_MODE_TORCH);
                                    mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_REGIONS, new MeteringRectangle[]{focusAreaTouch});
                                    mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_REGIONS, new MeteringRectangle[]{insideFocusAreaTouch});



                                }*/

1 个答案:

答案 0 :(得分:3)

您是否还在静态捕获请求中将FLASH_MODE设置为TORCH?

同时确保你的AE_MODE只是ON,而不是ON_AUTO_FLASH或ON_ALWAYS_FLASH,因为它们会覆盖FLASH_MODE设置。