我怎样才能正确设置CONTROL_SCENE_MODE_ACTION camera2API?

时间:2016-10-26 10:29:43

标签: android camera android-camera ip-camera

我需要为我的app camera2API设置CONTROL_SCENE_MODE_ACTION

我尝试在captureStillPicture()方法中设置lockFocus()方法,然后在stateCallback中设置{但不起作用...

在文档中我只找到解释它是什么,但是任何行都必须如何设置这个模式......

有两个问题:

  1. 我需要设置此模式
  2. 我如何检查它是否正常工作
  3. 或许你可以建议我如何减少曝光时间......

    提前致谢

1 个答案:

答案 0 :(得分:0)

您可以通过添加行

Camera2BasicFragment修改Google Camera2Basic sample

mPreviewRequestBuilder.set(CaptureRequest.CONTROL_SCENE_MODE, CaptureRequest.CONTROL_SCENE_MODE_ACTION);

在行

之后

mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);

onConfigured()示例方法

@Override
public void onConfigured(@NonNull CameraCaptureSession cameraCaptureSession) {
    // The camera is already closed
    if (null == mCameraDevice) {
        return;
    }

    // When the session is ready, we start displaying the preview.
    mCaptureSession = cameraCaptureSession;
    try {
        // Auto focus should be continuous for camera preview.
        mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE,
                CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
        mPreviewRequestBuilder.set(CaptureRequest.CONTROL_SCENE_MODE,
                CaptureRequest.CONTROL_SCENE_MODE_ACTION);
        // Flash is automatically enabled when necessary.
        setAutoFlash(mPreviewRequestBuilder);

        // Finally, we start displaying the camera preview.
        mPreviewRequest = mPreviewRequestBuilder.build();
        mCaptureSession.setRepeatingRequest(mPreviewRequest,
                mCaptureCallback, mBackgroundHandler);
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}