|
|
@ -35,7 +35,7 @@ public class Full2PictureRecorder extends PictureRecorder implements ImageReader |
|
|
|
private static final CameraLogger LOG = CameraLogger.create(TAG); |
|
|
|
private static final CameraLogger LOG = CameraLogger.create(TAG); |
|
|
|
|
|
|
|
|
|
|
|
private static final int STATE_IDLE = 0; |
|
|
|
private static final int STATE_IDLE = 0; |
|
|
|
private static final int STATE_WAITING_FOCUS_LOCK = 1; |
|
|
|
private static final int STATE_WAITING_AUTOFOCUS = 1; |
|
|
|
private static final int STATE_WAITING_PRECAPTURE_START = 2; |
|
|
|
private static final int STATE_WAITING_PRECAPTURE_START = 2; |
|
|
|
private static final int STATE_WAITING_PRECAPTURE_END = 3; |
|
|
|
private static final int STATE_WAITING_PRECAPTURE_END = 3; |
|
|
|
private static final int STATE_WAITING_CAPTURE = 4; |
|
|
|
private static final int STATE_WAITING_CAPTURE = 4; |
|
|
@ -74,10 +74,10 @@ public class Full2PictureRecorder extends PictureRecorder implements ImageReader |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void take() { |
|
|
|
public void take() { |
|
|
|
runFocusLock(); |
|
|
|
runAutoFocus(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean supportsFocusLock() { |
|
|
|
private boolean supportsAutoFocus() { |
|
|
|
//noinspection ConstantConditions
|
|
|
|
//noinspection ConstantConditions
|
|
|
|
int afMode = mBuilder.get(CaptureRequest.CONTROL_AF_MODE); |
|
|
|
int afMode = mBuilder.get(CaptureRequest.CONTROL_AF_MODE); |
|
|
|
// Exclude OFF and EDOF as per their docs.
|
|
|
|
// Exclude OFF and EDOF as per their docs.
|
|
|
@ -87,10 +87,10 @@ public class Full2PictureRecorder extends PictureRecorder implements ImageReader |
|
|
|
|| afMode == CameraCharacteristics.CONTROL_AF_MODE_MACRO; |
|
|
|
|| afMode == CameraCharacteristics.CONTROL_AF_MODE_MACRO; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void runFocusLock() { |
|
|
|
private void runAutoFocus() { |
|
|
|
if (supportsFocusLock()) { |
|
|
|
if (supportsAutoFocus()) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
mState = STATE_WAITING_FOCUS_LOCK; |
|
|
|
mState = STATE_WAITING_AUTOFOCUS; |
|
|
|
mBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CaptureRequest.CONTROL_AF_TRIGGER_START); |
|
|
|
mBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CaptureRequest.CONTROL_AF_TRIGGER_START); |
|
|
|
mSession.capture(mBuilder.build(), mCallback, null); |
|
|
|
mSession.capture(mBuilder.build(), mCallback, null); |
|
|
|
} catch (CameraAccessException e) { |
|
|
|
} catch (CameraAccessException e) { |
|
|
@ -180,7 +180,7 @@ public class Full2PictureRecorder extends PictureRecorder implements ImageReader |
|
|
|
private void process(@NonNull CaptureResult result) { |
|
|
|
private void process(@NonNull CaptureResult result) { |
|
|
|
switch (mState) { |
|
|
|
switch (mState) { |
|
|
|
case STATE_IDLE: break; |
|
|
|
case STATE_IDLE: break; |
|
|
|
case STATE_WAITING_FOCUS_LOCK: { |
|
|
|
case STATE_WAITING_AUTOFOCUS: { |
|
|
|
Integer afState = result.get(CaptureResult.CONTROL_AF_STATE); |
|
|
|
Integer afState = result.get(CaptureResult.CONTROL_AF_STATE); |
|
|
|
if (afState == null |
|
|
|
if (afState == null |
|
|
|
|| afState == CaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED |
|
|
|
|| afState == CaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED |
|
|
@ -261,7 +261,7 @@ public class Full2PictureRecorder extends PictureRecorder implements ImageReader |
|
|
|
} catch (IOException ignore) { } |
|
|
|
} catch (IOException ignore) { } |
|
|
|
|
|
|
|
|
|
|
|
// Before leaving, unlock focus.
|
|
|
|
// Before leaving, unlock focus.
|
|
|
|
if (supportsFocusLock()) { |
|
|
|
if (supportsAutoFocus()) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
mBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, |
|
|
|
mBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, |
|
|
|
CaptureRequest.CONTROL_AF_TRIGGER_CANCEL); |
|
|
|
CaptureRequest.CONTROL_AF_TRIGGER_CANCEL); |
|
|
|