How i can correctly set up CONTROL_SCENE_MODE_ACTI

2019-09-14 00:26发布

问题:

I need to set up CONTROL_SCENE_MODE_ACTION for my app camera2API.

i tryed to set it captureStillPicture() method then in lockFocus() method then in stateCallback but is doesn't work...

In documentation i found only explanation what it is, but any lines how this mode have to be set up...

There are 2 question:

  1. Where exacly i have to set up this mode
  2. How i can check that it is working

Or maybe you can suggest me how to reduse expose time...

Thanks in advance

回答1:

You can modify Camera2BasicFragment from Google Camera2Basic sample by add line

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

just after line

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

in onConfigured() method of example

@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();
    }
}