0

UPDATED: Please mark this as duplicated of Front Camera in Camera2 not capturing image Samsung S7 front camera does not support autofocus and lockfocus() will not return anything back.

It works on other devices with API24 , not in GalaxyS7.

private CaptureRequest.Builder mPreviewRequestBuilder;
/**
 * Initiate a still image capture.
 */
private void takePicture() {
    Log.e("timer", "entered takepicture()");
    lockFocus();
    Log.e("timer", "exited lockfocus()");
}

/**
 * Lock the focus as the first step for a still image capture.
 */
private void lockFocus() {
    try {
        // This is how to tell the camera to lock focus.
        Log.e("timer", "entered lockfocus()");
        mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER,
                CameraMetadata.CONTROL_AF_TRIGGER_START);
        // Tell #mCaptureCallback to wait for the lock.
        mState = STATE_WAITING_LOCK;
        mCaptureSession.capture(mPreviewRequestBuilder.build(), mCaptureCallback,
                mBackgroundHandler);
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}

No errors/warnings in logcat.

02-10 17:52:26.626 11402-11402/xxx E/timer: entered takepicture()
02-10 17:52:26.626 11402-11402/xxx E/timer: entered lockfocus()
02-10 17:52:26.634 11402-11402/xxx E/timer: exited lockfocus()
02-10 17:52:28.652 11402-11529/xxx V/FA: Inactivity, disconnecting from the service

If you need other pieces of the code please do let me know.

czane
  • 392
  • 1
  • 6
  • 18

1 Answers1

0

Please mark this as duplicated of Front Camera in Camera2 not capturing image Samsung S7 front camera does not support autofocus and lockfocus() will not return anything back.

czane
  • 392
  • 1
  • 6
  • 18