Why does flash drives app in stack? CONTROL_AE_MODE_ON_ALWAYS_FLASH Camera2API

人盡茶涼 提交于 2020-01-07 09:23:35

问题


There is weird situation. I took standard google sample camera2API.

I need that flash is worked permanently, regardless of outside light.

In order to accomplish it i have changed one line of code:

private void setAutoFlash(CaptureRequest.Builder requestBuilder) {
    if (mFlashSupported) {
//            requestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH);
        requestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON_ALWAYS_FLASH);
    }
}

It was CONTROL_AE_MODE_ON_AUTO_FLASH i have changed it to CONTROL_AE_MODE_ON_ALWAYS_FLASH.

And i have faced with issue, when i click Take picture button, camera is flashing and that is it. App goes to stack...

What am i doing wrong?

EDIT

I figure out next:

i have tryed tern on flash on three different device Meizu MX5, Samsung S5 and Samsung S6.

Two of them Meizu MX5, Samsung S5 work correctly with code above and app doesn't drives in stack.

Problem occur with Samsung S6, BUT ...

Method setAutoFlash() invokes within code 3 times in different places

  1. captureStillPicture()
  2. unlockFocus()
  3. onConfigured()

And trick is if i disable setAutoFlash() in captureStillPicture() for Samsung S6 it is stop stacking and flash begins to works but if i try this approach for Meizu MX5, Samsung S5 flash doesn't works...


回答1:


Eventually i found solution

As i said method

protected final void setAutoFlash(CaptureRequest.Builder requestBuilder) {
    if (isFlashSupported) {
        requestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH);
    }
}

invoked in three different places in code.

  1. captureStillPicture()
  2. unlockFocus()
  3. onConfigured()

So i implemented this line requestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH); locally in each method.

Finally that i get :

  1. unlockFocus() -> mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON_ALWAYS_FLASH);
  2. onConfigured() -> mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON_ALWAYS_FLASH);

and for this method remained auto settings

  1. captureStillPicture() -> captureBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH);

But i don't know the reason why i got such issue... If someone know the reason please let me know.



来源:https://stackoverflow.com/questions/40327476/why-does-flash-drives-app-in-stack-control-ae-mode-on-always-flash-camera2api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!