WAITING_LOCK中的Samsung CameraCaptureSession - 需要解决方法

时间:2018-02-10 18:00:32

标签: android android-camera2 samsung-galaxy

更新:请将此标记为重复Front Camera in Camera2 not capturing image三星S7前置摄像头不支持自动对焦,而lockfocus()不会返回任何内容。

它适用于其他具有API24的设备,而不适用于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();
    }
}

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

如果您需要其他代码,请告诉我。

1 个答案:

答案 0 :(得分:0)

请将此标记为在Camera2中复制前置摄像头而不捕获图像Samsung S7前置摄像头不支持自动对焦,而lockfocus()不会返回任何内容。