我在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
? 最佳答案
我知道这是一个老问题,但我遇到了同样的问题。阅读有关ControlAfState的Android文档(对于那些像我一样不知道的人,AF =自动对焦)。如果将自动对焦模式(afMode)设置为AF_MODE_OFF,您将获得ControlAfState为非 Activity 状态。
Android CaptureResult.CONTROL_AF_STATE