为什么我得到result.get(CaptureResult.CONTROL_AF_STATE); ==不活跃?

时间:2016-10-22 11:50:48

标签: java android camera android-camera

我在Samsung S5上使用camera2API,如果我尝试获得焦点状态,我会得到值0,等于CaptureResult.CONTROL_AF_STATE_INACTIVE ......

有代码片段:

private void process(CaptureResult result) {
        switch (mState) {
            case CameraHelper.STATE_PREVIEW: {
                // We have nothing to do when the camera preview is working normally.

here i get ---> Integer afState = result.get(CaptureResult.CONTROL_AF_STATE);

                if (CaptureResult.CONTROL_AF_TRIGGER_START == afState) {
                    if (areWeFocused) {
                        Log.e("---!!! HERE !!!--- :", String.valueOf(areWeFocused));
                    }else {
                    }
                }

                if (CaptureResult.CONTROL_AF_STATE_PASSIVE_FOCUSED == afState) {
                    areWeFocused = true;
                } else {
                    areWeFocused = false;
                }

                break;
            }

但我也尝试在Meizu MX5上测试它,然后我得到1 - CaptureResult.CONTROL_AF_TRIGGER_START2 - CaptureResult.CONTROL_AF_STATE_PASSIVE_FOCUSED

问题是:我的代码有什么不同?为什么我在一个案例中获得0而在另一个案例中获得1 or 2

1 个答案:

答案 0 :(得分:1)

我知道这是一个老问题,但我遇到了同样的问题。阅读有关ControlAfState的Android文档(对于那些不知情的人,AF =自动对焦,就像我一样)。如果自动聚焦模式(afMode)设置为AF_MODE_OFF,您将获得无效的ControlAfState。

Android CaptureResult.CONTROL_AF_STATE