Java Code Examples for android.hardware.camera2.CaptureResult#CONTROL_AF_STATE_ACTIVE_SCAN
The following examples show how to use
android.hardware.camera2.CaptureResult#CONTROL_AF_STATE_ACTIVE_SCAN .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AutoFocusHelper.java From Camera2 with Apache License 2.0 | 6 votes |
/** * Convert reported camera2 AF state to OneCamera AutoFocusState. */ public static OneCamera.AutoFocusState stateFromCamera2State(int state) { switch (state) { case CaptureResult.CONTROL_AF_STATE_ACTIVE_SCAN: return OneCamera.AutoFocusState.ACTIVE_SCAN; case CaptureResult.CONTROL_AF_STATE_PASSIVE_SCAN: return OneCamera.AutoFocusState.PASSIVE_SCAN; case CaptureResult.CONTROL_AF_STATE_PASSIVE_FOCUSED: return OneCamera.AutoFocusState.PASSIVE_FOCUSED; case CaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED: return OneCamera.AutoFocusState.ACTIVE_FOCUSED; case CaptureResult.CONTROL_AF_STATE_PASSIVE_UNFOCUSED: return OneCamera.AutoFocusState.PASSIVE_UNFOCUSED; case CaptureResult.CONTROL_AF_STATE_NOT_FOCUSED_LOCKED: return OneCamera.AutoFocusState.ACTIVE_UNFOCUSED; default: return OneCamera.AutoFocusState.INACTIVE; } }
Example 2
Source File: AutoFocusHelper.java From Camera2 with Apache License 2.0 | 6 votes |
/** * Utility function: converts CaptureResult.CONTROL_AF_STATE to String. */ private static String controlAFStateToString(int controlAFState) { switch (controlAFState) { case CaptureResult.CONTROL_AF_STATE_INACTIVE: return "inactive"; case CaptureResult.CONTROL_AF_STATE_PASSIVE_SCAN: return "passive_scan"; case CaptureResult.CONTROL_AF_STATE_PASSIVE_FOCUSED: return "passive_focused"; case CaptureResult.CONTROL_AF_STATE_ACTIVE_SCAN: return "active_scan"; case CaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED: return "focus_locked"; case CaptureResult.CONTROL_AF_STATE_NOT_FOCUSED_LOCKED: return "not_focus_locked"; case CaptureResult.CONTROL_AF_STATE_PASSIVE_UNFOCUSED: return "passive_unfocused"; default: return "unknown"; } }
Example 3
Source File: Camera2Helper.java From DeviceConnect-Android with MIT License | 6 votes |
/** * Auto-Focus の状態を文字列に変換します。 * * @param afState Auto Focus の状態 * @return 文字列 */ static String debugAFState(Integer afState) { if (afState == null) { return "NULL"; } switch (afState) { default: return "UNKNOWN"; case CaptureResult.CONTROL_AF_STATE_ACTIVE_SCAN: return "CaptureResult.CONTROL_AF_STATE_ACTIVE_SCAN"; case CaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED: return "CaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED"; case CaptureResult.CONTROL_AF_STATE_INACTIVE: return "CaptureResult.CONTROL_AF_STATE_INACTIVE"; case CaptureResult.CONTROL_AF_STATE_NOT_FOCUSED_LOCKED: return "CaptureResult.CONTROL_AF_STATE_NOT_FOCUSED_LOCKED"; case CaptureResult.CONTROL_AF_STATE_PASSIVE_FOCUSED: return "CaptureResult.CONTROL_AF_STATE_PASSIVE_FOCUSED"; case CaptureResult.CONTROL_AF_STATE_PASSIVE_SCAN: return "CaptureResult.CONTROL_AF_STATE_PASSIVE_SCAN"; case CaptureResult.CONTROL_AF_STATE_PASSIVE_UNFOCUSED: return "CaptureResult.CONTROL_AF_STATE_PASSIVE_UNFOCUSED"; } }
Example 4
Source File: AutoFocusStateMachine.java From Camera2 with Apache License 2.0 | 4 votes |
/** * Invoke every time we get a new CaptureResult via * {@link CameraDevice.CaptureCallback#onCaptureCompleted}. * * <p>This function is responsible for dispatching updates via the * {@link AutoFocusStateListener} so without calling this on a regular basis, no * AF changes will be observed.</p> * * @param result CaptureResult */ public synchronized void onCaptureCompleted(CaptureResult result) { /** * Work-around for b/11269834 * Although these should never-ever happen, harden for ship */ if (result == null) { Log.w(TAG, "onCaptureCompleted - missing result, skipping AF update"); return; } Key<Integer> keyAfState = CaptureResult.CONTROL_AF_STATE; if (keyAfState == null) { Log.e(TAG, "onCaptureCompleted - missing android.control.afState key, " + "skipping AF update"); return; } Key<Integer> keyAfMode = CaptureResult.CONTROL_AF_MODE; if (keyAfMode == null) { Log.e(TAG, "onCaptureCompleted - missing android.control.afMode key, " + "skipping AF update"); return; } Integer afState = result.get(CaptureResult.CONTROL_AF_STATE); Integer afMode = result.get(CaptureResult.CONTROL_AF_MODE); /** * Work-around for b/11238865 * This is a HAL bug as these fields should be there always. */ if (afState == null) { Log.w(TAG, "onCaptureCompleted - missing android.control.afState !"); return; } else if (afMode == null) { Log.w(TAG, "onCaptureCompleted - missing android.control.afMode !"); return; } if (DEBUG_LOGGING) Log.d(TAG, "onCaptureCompleted - new AF mode = " + afMode + " new AF state = " + afState); if (mLastAfState == afState && afMode == mLastAfMode) { // Same AF state as last time, nothing else needs to be done. return; } if (VERBOSE_LOGGING) Log.v(TAG, "onCaptureCompleted - new AF mode = " + afMode + " new AF state = " + afState); mLastAfState = afState; mLastAfMode = afMode; switch (afState) { case CaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED: mListener.onAutoFocusSuccess(result, /*locked*/true); endTraceAsync(); break; case CaptureResult.CONTROL_AF_STATE_NOT_FOCUSED_LOCKED: mListener.onAutoFocusFail(result, /*locked*/true); endTraceAsync(); break; case CaptureResult.CONTROL_AF_STATE_PASSIVE_FOCUSED: mListener.onAutoFocusSuccess(result, /*locked*/false); break; case CaptureResult.CONTROL_AF_STATE_PASSIVE_UNFOCUSED: mListener.onAutoFocusFail(result, /*locked*/false); break; case CaptureResult.CONTROL_AF_STATE_ACTIVE_SCAN: mListener.onAutoFocusScan(result); break; case CaptureResult.CONTROL_AF_STATE_PASSIVE_SCAN: mListener.onAutoFocusScan(result); break; case CaptureResult.CONTROL_AF_STATE_INACTIVE: mListener.onAutoFocusInactive(result); break; } }