我在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_START
或2
- CaptureResult.CONTROL_AF_STATE_PASSIVE_FOCUSED
问题是:我的代码有什么不同?为什么我在一个案例中获得0
而在另一个案例中获得1 or 2
?
答案 0 :(得分:1)
我知道这是一个老问题,但我遇到了同样的问题。阅读有关ControlAfState的Android文档(对于那些不知情的人,AF =自动对焦,就像我一样)。如果自动聚焦模式(afMode)设置为AF_MODE_OFF,您将获得无效的ControlAfState。