So, I managed to create the functionality that I wanted with the old camera, as I wanted.
With mCamera.autoFocus (autoFocusCallback); I detect when I have focus and run the required code in preview mode.
Now it’s hard for me to figure out how to do the same in Camera2 API. My first idea was that I would use
private void process(CaptureResult result) {
switch (mState) {
case STATE_PREVIEW: {
int afState = result.get(CaptureResult.CONTROL_AF_STATE);
Log.d("SOME KIND OF FOCUS", "WE HAVE");
break;
}
}
but I can’t find any condition that tells me that we got the focus. Does anyone know how to do this using the Camera2 API?
source
share