Java 类android.hardware.camera2.TotalCaptureResult 实例源码

项目:Camera2Vision    文件:Camera2Source.java   
@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);
    }
}
项目:android-camera    文件:Camera2.java   
void captureStillPicture() {
    deviceOrientationListener.rememberOrientation();
    try {
        CaptureRequest.Builder picCaptureRequestBuilder = cameraDevice.createCaptureRequest(CameraDevice
                .TEMPLATE_STILL_CAPTURE);
        picCaptureRequestBuilder.addTarget(imageReader.getSurface());
        picCaptureRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE,
                previewRequestBuilder.get(CaptureRequest.CONTROL_AF_MODE));
        // fix the orientation
        picCaptureRequestBuilder.set(CaptureRequest.JPEG_ORIENTATION, getJpegOrientation(cameraCharacteristics));
        captureSession.stopRepeating(); // Stop preview while capturing a still picture.
        captureSession.capture(picCaptureRequestBuilder.build(), new CameraCaptureSession.CaptureCallback() {
            @Override
            public void onCaptureCompleted(@NonNull CameraCaptureSession session, @NonNull CaptureRequest request,
                                           @NonNull TotalCaptureResult result) {
                restartPreview(); // restart the preview etc.
            }
        }, null);

    } catch (CameraAccessException e) {
        Log.e(TAG, "Cannot capture a still picture.", e);
    }
}
项目:AudioVideo    文件:Camera2CapturePic.java   
@Override
public void onCaptureCompleted(CameraCaptureSession session,
                               CaptureRequest request, TotalCaptureResult result) {

    super.onCaptureCompleted(session, request, result);
    //new tell the system that the file exists , so it will show up in gallery/photos/whatever
    ContentValues values = new ContentValues();
    values.put(MediaStore.Images.Media.DATE_TAKEN, System.currentTimeMillis());
    values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
    values.put(MediaStore.MediaColumns.DATA, file.toString());
    context.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);

    Toast.makeText(context, "Saved:" + file, Toast.LENGTH_SHORT).show();
    Log.v(TAG, "Saved:" + file);
    camera2Preview.startPreview();
}
项目:AudioVideo    文件:Camera2Preview.java   
@Override
public void onCaptureCompleted(CameraCaptureSession session,
                               CaptureRequest request, TotalCaptureResult result) {

    super.onCaptureCompleted(session, request, result);
    //new tell the system that the file exists , so it will show up in gallery/photos/whatever
    ContentValues values = new ContentValues();
    values.put(MediaStore.Images.Media.DATE_TAKEN, System.currentTimeMillis());
    values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
    values.put(MediaStore.MediaColumns.DATA, file.toString());
    context.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);

    Toast.makeText(context, "Saved:" + file, Toast.LENGTH_SHORT).show();
    Log.v(TAG, "Saved:" + file);
    startPreview();
}
项目:Camera2    文件:OneCameraZslImpl.java   
@Override
public void onImageCaptured(Image image, TotalCaptureResult
        captureResult) {
    long timestamp = captureResult.get(CaptureResult.SENSOR_TIMESTAMP);

    // We should only capture the image if it's more recent than the
    // latest one. Synchronization is necessary since this method is
    // called on {@link #mImageSaverThreadPool}.
    synchronized (mLastCapturedImageTimestamp) {
        if (timestamp > mLastCapturedImageTimestamp.get()) {
            mLastCapturedImageTimestamp.set(timestamp);
        } else {
            // There was a more recent (or identical) image which has
            // begun being saved, so abort.
            return;
        }
    }

    mReadyStateManager.setInput(
            ReadyStateRequirement.CAPTURE_NOT_IN_PROGRESS, true);

    mSession.startEmpty();
    savePicture(image, mParams, mSession);
    mParams.callback.onPictureTaken(mSession);
    Log.v(TAG, "Image saved.  Frame number = " + captureResult.getFrameNumber());
}
项目:CameraFragment    文件:Camera2Manager.java   
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");
    }
}
项目:SIGHT-For-the-Blind    文件:CameraHandler.java   
@Override
public void onCaptureCompleted(@NonNull CameraCaptureSession session,
                               @NonNull CaptureRequest request,
                               @NonNull TotalCaptureResult result) {
    session.close();
    mCaptureSession = null;
    Log.d(TAG, "CaptureSession closed");
}
项目:Android-Code-Demos    文件:Camera2BasicFragment.java   
/**
 * 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();
    }
}
项目:Android-Code-Demos    文件:MyCamera2Fragment.java   
@Override
public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request,
                               TotalCaptureResult result) {
    //            Log.d(TAG,"mSessionCaptureCallback, onCaptureCompleted");
    mSession = session;
    checkState(result);
}
项目:android-robocar    文件:CaptureCallback.java   
@Override
public void onCaptureCompleted(@NonNull CameraCaptureSession session,
                               @NonNull CaptureRequest request,
                               @NonNull TotalCaptureResult result) {
  super.onCaptureCompleted(session, request, result);
  Timber.d("Capture completed.");
  this.session = null;
}
项目:androidthings-imageclassifier    文件:CameraHandler.java   
@Override
public void onCaptureCompleted(@NonNull CameraCaptureSession session,
                               @NonNull CaptureRequest request,
                               @NonNull TotalCaptureResult result) {
    session.close();
    mCaptureSession = null;
    Log.d(TAG, "CaptureSession closed");
}
项目:androidthings-imageclassifier    文件:CameraHandler.java   
@Override
public void onCaptureCompleted(@NonNull CameraCaptureSession session,
                               @NonNull CaptureRequest request,
                               @NonNull TotalCaptureResult result) {
    session.close();
    mCaptureSession = null;
    Log.d(TAG, "CaptureSession closed");
}
项目:androidthings-imageclassifier    文件:CameraHandler.java   
@Override
public void onCaptureCompleted(@NonNull CameraCaptureSession session,
                               @NonNull CaptureRequest request,
                               @NonNull TotalCaptureResult result) {
    session.close();
    mCaptureSession = null;
    Log.d(TAG, "CaptureSession closed");
}
项目:android-Camera2Basic-master    文件:Camera2BasicFragment.java   
/**
 * 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();
    }
}
项目:Camera2Vision    文件:Camera2Source.java   
/**
 * 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 {
        if (null == mCameraDevice) {
            return;
        }
        if(mShutterCallback != null) {
            mShutterCallback.onShutter();
        }
        // This is the CaptureRequest.Builder that we use to take a picture.
        final CaptureRequest.Builder captureBuilder = mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);
        captureBuilder.addTarget(mImageReaderStill.getSurface());

        // Use the same AE and AF modes as the preview.
        captureBuilder.set(CaptureRequest.CONTROL_AF_MODE, mFocusMode);
        if(mFlashSupported) {
            captureBuilder.set(CaptureRequest.CONTROL_AE_MODE, mFlashMode);
        }

        // Orientation
        captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, getOrientation(mDisplayOrientation));

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

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

        mCaptureSession.stopRepeating();
        mCaptureSession.capture(captureBuilder.build(), CaptureCallback, null);
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}
项目:sample-tensorflow-imageclassifier    文件:CameraHandler.java   
@Override
public void onCaptureCompleted(@NonNull CameraCaptureSession session,
                               @NonNull CaptureRequest request,
                               @NonNull TotalCaptureResult result) {
    session.close();
    mCaptureSession = null;
    Log.d(TAG, "CaptureSession closed");
}
项目:OkayCamera-Android    文件:Camera2RawFragment.java   
@Override
public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request,
                               TotalCaptureResult result) {
    int requestId = (int) request.getTag();
    ImageSaver.ImageSaverBuilder jpegBuilder;
    ImageSaver.ImageSaverBuilder rawBuilder;
    StringBuilder sb = new StringBuilder();

    // Look up the ImageSaverBuilder for this request and update it with the CaptureResult
    synchronized (mCameraStateLock) {
        jpegBuilder = mJpegResultQueue.get(requestId);
        rawBuilder = mRawResultQueue.get(requestId);

        if (jpegBuilder != null) {
            jpegBuilder.setResult(result);
            sb.append("Saving JPEG as: ");
            sb.append(jpegBuilder.getSaveLocation());
        }
        if (rawBuilder != null) {
            rawBuilder.setResult(result);
            if (jpegBuilder != null) sb.append(", ");
            sb.append("Saving RAW as: ");
            sb.append(rawBuilder.getSaveLocation());
        }

        // If we have all the results necessary, save the image to a file in the background.
        handleCompletionLocked(requestId, jpegBuilder, mJpegResultQueue);
        handleCompletionLocked(requestId, rawBuilder, mRawResultQueue);

        finishedCaptureLocked();
    }

    showToast(sb.toString());
}
项目:androidthings-kuman-sm9    文件:Camera.java   
@Override
public void onCaptureCompleted(@NonNull CameraCaptureSession session,
                               @NonNull CaptureRequest request,
                               @NonNull TotalCaptureResult result) {
    session.close();
    mCaptureSession = null;
    Timber.d("CaptureSession closed");
}
项目:android-things-drawbot    文件:CameraHandler.java   
@Override
public void onCaptureCompleted(@NonNull CameraCaptureSession session,
                               @NonNull CaptureRequest request,
                               @NonNull TotalCaptureResult result) {
    session.close();
    mCaptureSession = null;
    Log.d(TAG, "CaptureSession closed");
}
项目:robo-car    文件:PiCameraDriver.java   
@Override
public void onCaptureCompleted(@NonNull CameraCaptureSession session,
                               @NonNull CaptureRequest request,
                               @NonNull TotalCaptureResult result) {
    //noinspection ConstantConditions
    if (session != null) {
        session.close();
        mCaptureSession = null;
    }
}
项目:JinsMemeBRIDGE-Android    文件:Camera2BasicFragment.java   
/**
 * 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) {
                unlockFocus();
            }
        };

        mCaptureSession.stopRepeating();
        mCaptureSession.capture(captureBuilder.build(), CaptureCallback, null);
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}
项目:CameraKitView    文件:Camera2Fragment.java   
/**
     * 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();
        }
    }
项目:CameraKitView    文件:Camera2.java   
/**
     * 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();
            // 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 = mWindowManager.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();
        }
    }
项目:phonk    文件:CameraNew2.java   
private void captureStillPicture() {
    MLog.d(TAG, "captureStillPicture");

    try {
        if (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
        captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, 0);

        CameraCaptureSession.CaptureCallback CaptureCallback = new CameraCaptureSession.CaptureCallback() {
            @Override
            public void onCaptureCompleted(@NonNull CameraCaptureSession session, @NonNull CaptureRequest request, @NonNull TotalCaptureResult result) {
                Log.d(TAG, "saved to: " ); // + mFile.toString());
                unlockFocus();
            }
        };

        mCaptureSession.stopRepeating();
        mCaptureSession.capture(captureBuilder.build(), CaptureCallback, null);
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}
项目:android-camera2-secret-picture-taker    文件:PictureCapturingServiceImpl.java   
@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();
}
项目:Ocr-android    文件:CameraPreview.java   
/**
 * 拍摄静态图片
 */
private void captureStillPicture() {
    if (null == mCameraDevice) {
        return;
    }
    try {
        final CaptureRequest.Builder captureBuilder =
                mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);
        captureBuilder.addTarget(mImageReader.getSurface());
        captureBuilder.set(CaptureRequest.CONTROL_AF_MODE,
                CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
        setAutoFlash(captureBuilder);
        // 方向
        int rotation = getDisplayRotation();
        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();
                if (mCapturePictureListener != null) {
                    mCapturePictureListener.onCapture(mFile);
                }
            }
        };
        mCaptureSession.stopRepeating();
        mCaptureSession.abortCaptures();
        mCaptureSession.capture(captureBuilder.build(), captureCallback, null);
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}
项目:sandriosCamera    文件:Camera2Manager.java   
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");
    }
}
项目:doorbell    文件:DoorbellCamera.java   
@Override
public void onCaptureCompleted(CameraCaptureSession session,
                               CaptureRequest request,
                               TotalCaptureResult result) {
    if (session != null) {
        session.close();
        mCaptureSession = null;
        Log.d(TAG, "CaptureSession closed");
    }
}
项目:Annca    文件:Camera2Manager.java   
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");
    }
}
项目:MultiMediaSample    文件:Camera2Fragment.java   
/**
 * 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("拍照成功,图片保存为: " + mFile);
                Log.d(TAG, mFile.toString());
                unlockFocus();
            }
        };

        mCaptureSession.stopRepeating();
        mCaptureSession.capture(captureBuilder.build(), CaptureCallback, null);
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}
项目:androidprojectbase    文件:Camera2BasicFragment.java   
/**
 * 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();
    }
}
项目:aurora-imui    文件:CameraNew.java   
/**
 * 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 = (Activity) mContext;
        if (null == activity || null == mCamera) {
            return;
        }
        // This is the CaptureRequest.Builder that we use to take a picture.
        final CaptureRequest.Builder captureBuilder =
                mCamera.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) {
                unlockFocus();
            }
        };

        mCaptureSession.stopRepeating();
        mCaptureSession.capture(captureBuilder.build(), CaptureCallback, null);
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}
项目:Camera2App    文件:BasicCamera.java   
@Override
public void onCaptureCompleted(CameraCaptureSession session,
                               CaptureRequest request,
                               TotalCaptureResult result) {
    // キャプチャの完了(プレビューの場合、プレビュー状態が継続)
    process(result);
}
项目:pocketDSLR    文件:DngSaver.java   
public DngSaver(UserContext userContext, ImageReader imageReader, CameraCharacteristics cameraCharacteristics, TotalCaptureResult totalCaptureResult){

        this.userContext = userContext;
        this.imageReader = imageReader;
        this.cameraCharacteristics = cameraCharacteristics;
        this.totalCaptureResult = totalCaptureResult;
    }
项目:AudioVideo    文件:Cam2Fragment.java   
@Override
public void onCaptureCompleted(CameraCaptureSession session,
                               CaptureRequest request, TotalCaptureResult result) {

    super.onCaptureCompleted(session, request, result);
    String[] filePathColumn = { MediaStore.Images.Media.DATA };
    Cursor cursor = getActivity().getContentResolver().query(imageFileUri, filePathColumn, null, null, null);
    cursor.moveToFirst();
    int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
    String file = cursor.getString(columnIndex);
    cursor.close();
    Toast.makeText(getActivity(), "Saved:" + file, Toast.LENGTH_SHORT).show();
    Log.v(TAG, "Saved:" + file);
    startPreview();
}
项目:Camera2    文件:ImageCaptureManager.java   
/**
 * Adds the metadata. Note that this can only be called once before a
 * {@link #reset()} is necessary.
 *
 * @param metadata the {@Link TotalCaptureResult} to add.
 */
public void addMetadata(TotalCaptureResult metadata) {
    if (mMetadata != null) {
        throw new IllegalArgumentException(
                "Unable to add a TotalCaptureResult when one already exists.");
    }
    mMetadata = metadata;
}
项目:Camera2    文件:ImageCaptureManager.java   
/**
 * Tries to resolve any pending image capture requests.
 *
 * @param newImageTimestamp the timestamp of a newly-acquired image which
 *            should be captured if appropriate and possible.
 */
private void tryExecutePendingCaptureRequest(long newImageTimestamp) {
    if (mPendingImageCaptureCallback != null) {
        final Pair<Long, CapturedImage> pinnedImage = mCapturedImageBuffer.tryPin(
                newImageTimestamp);
        if (pinnedImage != null) {
            CapturedImage image = pinnedImage.second;

            if (!image.isComplete()) {
                mCapturedImageBuffer.release(pinnedImage.first);
                return;
            }

            // Check to see if the image satisfies all constraints.
            TotalCaptureResult captureResult = image.tryGetMetadata();

            if (mPendingImageCaptureConstraints != null) {
                for (CapturedImageConstraint constraint : mPendingImageCaptureConstraints) {
                    if (!constraint.satisfiesConstraint(captureResult)) {
                        mCapturedImageBuffer.release(pinnedImage.first);
                        return;
                    }
                }
            }

            // If we get here, the image satisfies all the necessary
            // constraints.

            if (tryExecuteCaptureOrRelease(pinnedImage, mPendingImageCaptureCallback)) {
                // If we successfully handed the image off to the callback,
                // remove the pending
                // capture request.
                mPendingImageCaptureCallback = null;
                mPendingImageCaptureConstraints = null;
            }
        }
    }
}
项目:365browser    文件:VideoCaptureCamera2.java   
@Override
public void onConfigured(CameraCaptureSession cameraCaptureSession) {
    Log.d(TAG, "CrPreviewSessionListener.onConfigured");
    mPreviewSession = cameraCaptureSession;
    try {
        // This line triggers the preview. A |listener| is registered to receive the actual
        // capture result details. A CrImageReaderListener will be triggered every time a
        // downloaded image is ready. Since |handler| is null, we'll work on the current
        // Thread Looper.
        mPreviewSession.setRepeatingRequest(
                mPreviewRequest, new CameraCaptureSession.CaptureCallback() {
                    @Override
                    public void onCaptureCompleted(CameraCaptureSession session,
                            CaptureRequest request, TotalCaptureResult result) {
                        mLastExposureTimeNs =
                                result.get(CaptureResult.SENSOR_EXPOSURE_TIME);
                    }
                }, null);

    } catch (CameraAccessException | SecurityException | IllegalStateException
            | IllegalArgumentException ex) {
        Log.e(TAG, "setRepeatingRequest: ", ex);
        return;
    }
    // Now wait for trigger on CrPreviewReaderListener.onImageAvailable();
    nativeOnStarted(mNativeVideoCaptureDeviceAndroid);
    changeCameraStateAndNotify(CameraState.STARTED);
}
项目:cwac-cam2    文件:CameraTwoEngine.java   
@Override
public void onCaptureCompleted(CameraCaptureSession session,
                               CaptureRequest request,
                               TotalCaptureResult result) {
  // TODO: something useful with the picture
  unlockFocus();
}
项目:material-camera    文件:Camera2Fragment.java   
@Override
public void onCaptureCompleted(
    @NonNull CameraCaptureSession session,
    @NonNull CaptureRequest request,
    @NonNull TotalCaptureResult result) {
  process(result);
}