当前位置: 首页>>代码示例>>Java>>正文


Java CameraCaptureSession类代码示例

本文整理汇总了Java中android.hardware.camera2.CameraCaptureSession的典型用法代码示例。如果您正苦于以下问题:Java CameraCaptureSession类的具体用法?Java CameraCaptureSession怎么用?Java CameraCaptureSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CameraCaptureSession类属于android.hardware.camera2包,在下文中一共展示了CameraCaptureSession类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCaptureFailed

import android.hardware.camera2.CameraCaptureSession; //导入依赖的package包/类
@Override
public void onCaptureFailed(@NonNull CameraCaptureSession session,
                            @NonNull CaptureRequest request,
                            @NonNull CaptureFailure failure) {
  super.onCaptureFailed(session, request, failure);
  this.session = null;
  switch (failure.getReason()) {
    case CaptureFailure.REASON_ERROR:
      Timber.e("Capture failed: REASON_ERROR");
      break;
    case CaptureFailure.REASON_FLUSHED:
      Timber.e("Capture failed: REASON_FLUSHED");
      break;
    default:
      Timber.e("Capture failed: UNKNOWN");
      break;
  }
}
 
开发者ID:zugaldia,项目名称:android-robocar,代码行数:19,代码来源:CaptureCallback.java

示例2: setRepeatingBurst

import android.hardware.camera2.CameraCaptureSession; //导入依赖的package包/类
/**
 * Set a repeating burst request.
 */
public void setRepeatingBurst(final List<CaptureRequest> requests,
        final CameraCaptureSession.CaptureCallback listener, final Handler handler) {
    mCameraHandler.post(() -> {
        try {
            mCameraSession.setRepeatingBurst(requests, listener, handler);
        } catch (CameraAccessException e) {
            String errorMessage = mErrorDisplayer.getErrorString(e);
            mErrorDisplayer.showErrorDialog(errorMessage);
        }
    });
}
 
开发者ID:lydia-schiff,项目名称:hella-renderscript,代码行数:15,代码来源:CameraOps.java

示例3: onCaptureCompleted

import android.hardware.camera2.CameraCaptureSession; //导入依赖的package包/类
@Override
public void onCaptureCompleted(@NonNull CameraCaptureSession session, @NonNull CaptureRequest request, @NonNull TotalCaptureResult result) {
    if(request.getTag() == ("FOCUS_TAG")) {
        //The focus trigger is complete!
        //Resume repeating request, clear AF trigger.
        mAutoFocusCallback.onAutoFocus(true);
        mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, null);
        mPreviewRequestBuilder.setTag("");
        mPreviewRequest = mPreviewRequestBuilder.build();
        try {
            mCaptureSession.setRepeatingRequest(mPreviewRequest, mCaptureCallback, mBackgroundHandler);
        } catch(CameraAccessException ex) {
            Log.d(TAG, "AUTO FOCUS FAILURE: "+ex);
        }
    } else {
        process(result);
    }
}
 
开发者ID:EzequielAdrianM,项目名称:Camera2Vision,代码行数:19,代码来源:Camera2Source.java

示例4: setupCaptureRequestForPreview

import android.hardware.camera2.CameraCaptureSession; //导入依赖的package包/类
/**
 * does setup the repeating capture request for taking images for the preview
 */
@VisibleForTesting
void setupCaptureRequestForPreview(@NonNull CameraCaptureSession previewSession, @NonNull CameraDevice camera,
                                   @NonNull List<Surface> surfaces) {
    try {
        CaptureRequest.Builder previewRequestBuilder = camera.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
        for (Surface surface : surfaces) {
            previewRequestBuilder.addTarget(surface);
        }
        previewRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);

        previewSession.setRepeatingRequest(previewRequestBuilder.build(), null, null);

    } catch (CameraAccessException | IllegalStateException e) {
        throw new CameraException(e);
    }
}
 
开发者ID:BioID-GmbH,项目名称:BWS-Android,代码行数:20,代码来源:CameraHelper.java

示例5: connectPreview

import android.hardware.camera2.CameraCaptureSession; //导入依赖的package包/类
/**
 * connects a new camera preview session to the UI
 */
private void connectPreview() {
    try {
        setupPreviewSizeAndImageReader();
        cameraHelper.startCameraPreview(openCamera, binding.preview, previewSize, getDeviceOrientation(),
                getRelativeDisplayRotation(), imageReader, new Consumer<CameraCaptureSession>() {
                    @Override
                    public void accept(CameraCaptureSession cameraCaptureSession) {
                        openPreviewSession = cameraCaptureSession;
                    }
                });
    } catch (CameraException e) {
        cleanup();
        logErrorAndFinish("connectPreview failed: %s", e.getMessage());
    }
}
 
开发者ID:BioID-GmbH,项目名称:BWS-Android,代码行数:19,代码来源:FacialRecognitionFragment.java

示例6: updatePreview

import android.hardware.camera2.CameraCaptureSession; //导入依赖的package包/类
private void updatePreview(CameraCaptureSession cameraCaptureSession) {
    if (null == cameraDevice) {
        return;
    }
    captureSession = cameraCaptureSession;

    setFlashModeAndBuildPreviewRequest(configurationProvider.getFlashMode());
}
 
开发者ID:florent37,项目名称:CameraFragment,代码行数:9,代码来源:Camera2Manager.java

示例7: captureStillPicture

import android.hardware.camera2.CameraCaptureSession; //导入依赖的package包/类
private void captureStillPicture() {
    try {
        if (null == cameraDevice) {
            return;
        }
        final CaptureRequest.Builder captureBuilder =
                cameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);
        captureBuilder.addTarget(imageReader.getSurface());

        captureBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
        captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, getPhotoOrientation(configurationProvider.getSensorPosition()));

        CameraCaptureSession.CaptureCallback CaptureCallback = new CameraCaptureSession.CaptureCallback() {
            @Override
            public void onCaptureCompleted(@NonNull CameraCaptureSession session,
                                           @NonNull CaptureRequest request,
                                           @NonNull TotalCaptureResult result) {
                Log.d(TAG, "onCaptureCompleted: ");
            }
        };

        captureSession.stopRepeating();
        captureSession.capture(captureBuilder.build(), CaptureCallback, null);

    } catch (CameraAccessException e) {
        Log.e(TAG, "Error during capturing picture");
    }
}
 
开发者ID:florent37,项目名称:CameraFragment,代码行数:29,代码来源:Camera2Manager.java

示例8: onConfigured

import android.hardware.camera2.CameraCaptureSession; //导入依赖的package包/类
@Override
public void onConfigured(@NonNull CameraCaptureSession cameraCaptureSession) {
    // The camera is already closed
    if (mCameraDevice == null) {
        return;
    }
    // When the session is ready, we start capture.
    mCaptureSession = cameraCaptureSession;
    triggerImageCapture();
}
 
开发者ID:FoxLabMakerSpace,项目名称:SIGHT-For-the-Blind,代码行数:11,代码来源:CameraHandler.java

示例9: onCaptureCompleted

import android.hardware.camera2.CameraCaptureSession; //导入依赖的package包/类
@Override
public void onCaptureCompleted(@NonNull CameraCaptureSession session, @NonNull CaptureRequest request,
                               @NonNull TotalCaptureResult result) {
    super.onCaptureCompleted(session, request, result);
    if (picturesTaken.lastEntry() != null) {
        capturingListener.onCaptureDone(picturesTaken.lastEntry().getKey(), picturesTaken.lastEntry().getValue());
        Log.i(TAG, "done taking picture from camera " + cameraDevice.getId());
    }
    closeCamera();
}
 
开发者ID:botyourbusiness,项目名称:android-camera2-secret-picture-taker,代码行数:11,代码来源:PictureCapturingServiceImpl.java

示例10: onCaptureCompleted

import android.hardware.camera2.CameraCaptureSession; //导入依赖的package包/类
@Override
public void onCaptureCompleted(@NonNull CameraCaptureSession session,
                               @NonNull CaptureRequest request,
                               @NonNull TotalCaptureResult result) {
    session.close();
    mCaptureSession = null;
    Log.d(TAG, "CaptureSession closed");
}
 
开发者ID:FoxLabMakerSpace,项目名称:SIGHT-For-the-Blind,代码行数:9,代码来源:CameraHandler.java

示例11: captureStillPicture

import android.hardware.camera2.CameraCaptureSession; //导入依赖的package包/类
/**
 * Capture a still picture. This method should be called when we get a response in
 * {@link #mCaptureCallback} from both {@link #lockFocus()}.
 */
private void captureStillPicture() {
    try {
        final Activity activity = getActivity();
        if (null == activity || null == mCameraDevice) {
            return;
        }
        // This is the CaptureRequest.Builder that we use to take a picture.
        final CaptureRequest.Builder captureBuilder =
                mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);
        captureBuilder.addTarget(mImageReader.getSurface());

        // Use the same AE and AF modes as the preview.
        captureBuilder.set(CaptureRequest.CONTROL_AF_MODE,
                CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
        setAutoFlash(captureBuilder);

        // Orientation
        int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
        captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, getOrientation(rotation));

        CameraCaptureSession.CaptureCallback CaptureCallback
                = new CameraCaptureSession.CaptureCallback() {

            @Override
            public void onCaptureCompleted(@NonNull CameraCaptureSession session,
                                           @NonNull CaptureRequest request,
                                           @NonNull TotalCaptureResult result) {
                showToast("Saved: " + mFile);
                Log.d(TAG, mFile.toString());
                unlockFocus();
            }
        };

        mCaptureSession.stopRepeating();
        mCaptureSession.capture(captureBuilder.build(), CaptureCallback, null);
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}
 
开发者ID:InnoFang,项目名称:Android-Code-Demos,代码行数:44,代码来源:Camera2BasicFragment.java

示例12: onConfigured

import android.hardware.camera2.CameraCaptureSession; //导入依赖的package包/类
@Override
public void onConfigured(CameraCaptureSession session) {
    Log.d(TAG, "mSessionPreviewStateCallback onConfigured");
    mSession = session;
    try {
        mPreviewBuilder.set(CaptureRequest.CONTROL_AF_MODE,
                CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
        mPreviewBuilder.set(CaptureRequest.CONTROL_AE_MODE,
                CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH);
        session.setRepeatingRequest(mPreviewBuilder.build(), mSessionCaptureCallback, mHandler);
    } catch (CameraAccessException e) {
        e.printStackTrace();
        Log.e(TAG, "set preview builder failed." + e.getMessage());
    }
}
 
开发者ID:InnoFang,项目名称:Android-Code-Demos,代码行数:16,代码来源:MyCamera2Fragment.java

示例13: onCaptureProgressed

import android.hardware.camera2.CameraCaptureSession; //导入依赖的package包/类
@Override
public void onCaptureProgressed(CameraCaptureSession session, CaptureRequest request,
                                CaptureResult partialResult) {
    Log.d(TAG, "mSessionCaptureCallback,  onCaptureProgressed");
    mSession = session;
    checkState(partialResult);
}
 
开发者ID:InnoFang,项目名称:Android-Code-Demos,代码行数:8,代码来源:MyCamera2Fragment.java

示例14: captureStillPicture

import android.hardware.camera2.CameraCaptureSession; //导入依赖的package包/类
/**
     * Capture a still picture. This method should be called when we get a response in
     * {@link #mCaptureCallback} from both {@link #lockFocus()}.
     */
    private void captureStillPicture() {
        try {
            removeCaptureMessage();
            final Activity activity = getActivity();
            if (null == activity || null == mCameraDevice) {
                return;
            }
            // This is the CaptureRequest.Builder that we use to take a picture.
            final CaptureRequest.Builder captureBuilder =
                mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);
            captureBuilder.addTarget(mImageReader.getSurface());

            // Use the same AE and AF modes as the preview.
//            captureBuilder.set(CaptureRequest.CONTROL_AF_MODE,
//                CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
//            updateAutoFocus();
            updateFlash(captureBuilder);

            // Orientation
            int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
            captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, getOrientation(rotation));

            CameraCaptureSession.CaptureCallback CaptureCallback
                = new CameraCaptureSession.CaptureCallback() {

                @Override
                public void onCaptureCompleted(@NonNull CameraCaptureSession session,
                                               @NonNull CaptureRequest request,
                                               @NonNull TotalCaptureResult result) {
                    unlockFocus();
                }
            };

            mPreviewSession.stopRepeating();
            mPreviewSession.capture(captureBuilder.build(), CaptureCallback, mBackgroundHandler);
        } catch (CameraAccessException e) {
            e.printStackTrace();
        }
    }
 
开发者ID:lytcom,项目名称:CameraKitView,代码行数:44,代码来源:Camera2Fragment.java

示例15: onCaptureStarted

import android.hardware.camera2.CameraCaptureSession; //导入依赖的package包/类
@Override
public void onCaptureStarted(@NonNull CameraCaptureSession session,
                             @NonNull CaptureRequest request, long timestamp, long frameNumber) {
  super.onCaptureStarted(session, request, timestamp, frameNumber);
  Timber.d("Capture started.");
  this.session = session;
}
 
开发者ID:zugaldia,项目名称:android-robocar,代码行数:8,代码来源:CaptureCallback.java


注:本文中的android.hardware.camera2.CameraCaptureSession类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。