2

我正在尝试使用 camera2 api 创建一个应用程序,我需要的是创建一个我能够创建的 30 fps 的突发。

问题在于预览图像和保存的图像交错(我正在拍摄一些闪烁的 LED,因此很容易看到)。我试图禁用自动曝光并自己设置灵敏度,但没有奏效。

 private void captureStillPicture() {
    try {
        final Activity activity = getActivity();
        mPictureCounter = 0;
        if (null == activity || null == mCameraDevice) {
            return;
        }

        List<CaptureRequest> captureList = new ArrayList<CaptureRequest>();

        // This is the CaptureRequest.Builder that we use to take a picture.
        final CaptureRequest.Builder captureBuilder = mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);

        // Use the same AE and AF modes as the preview.
        captureBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_AUTO);
        captureBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, 2000);
        //Auto focus - should keep that
        captureBuilder.set(CaptureRequest.CONTROL_AE_MODE, Consts.aeMode);

        captureBuilder.addTarget(mImageReader.getSurface());

        for(int i = 0; i < Consts.frameAmount; i++) {
            captureList.add(captureBuilder.build());
        }

        CameraCaptureSession.CaptureCallback CaptureCallback = new CameraCaptureSession.CaptureCallback() {
            @Override
            public void onCaptureCompleted(@NonNull CameraCaptureSession session,
                                           @NonNull CaptureRequest request,
                                           @NonNull TotalCaptureResult result) {
                mPictureCounter++;
                unlockFocus();
            }
        };

        mCaptureSession.stopRepeating();
        mCaptureSession.captureBurst(captureList, CaptureCallback, mBackgroundHandler);

    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}

任何想法?

4

0 回答 0