當前位置: 首頁>>代碼示例>>Java>>正文


Java CaptureRequest.Builder方法代碼示例

本文整理匯總了Java中android.hardware.camera2.CaptureRequest.Builder方法的典型用法代碼示例。如果您正苦於以下問題:Java CaptureRequest.Builder方法的具體用法?Java CaptureRequest.Builder怎麽用?Java CaptureRequest.Builder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.hardware.camera2.CaptureRequest的用法示例。


在下文中一共展示了CaptureRequest.Builder方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: takePicture

import android.hardware.camera2.CaptureRequest; //導入方法依賴的package包/類
private void takePicture() {
    if (mCameraDevice == null) {
        return;
    }

    //創建Request.Builder()
    final CaptureRequest.Builder requestBuilder ;
    try{
        requestBuilder = mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);

        //將ImageReader的surface作為CaptureRequest.Builder的目標
        requestBuilder.addTarget(mImageReader.getSurface());
        // 自動對焦
        requestBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
        // 自動曝光
        requestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH);

        requestBuilder.set(CaptureRequest.JPEG_ORIENTATION, 270);

        //拍照
        CaptureRequest mCaptureRequest = requestBuilder.build();
        mCameraCaptureSession.capture(mCaptureRequest, null, null);

    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}
 
開發者ID:lazyparser,項目名稱:xbot_head,代碼行數:28,代碼來源:CameraActivity.java

示例2: captureStillPicture

import android.hardware.camera2.CaptureRequest; //導入方法依賴的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

示例3: init

import android.hardware.camera2.CaptureRequest; //導入方法依賴的package包/類
public OkCaptureRequestBuilder init(@NonNull CaptureRequest.Builder mBuilder, Object tag) {
    this.mBuilder = mBuilder;
    try {
        this.setTag(tag);
    } catch (ObjectNotInitializedException ignored) {
    }
    return this;
}
 
開發者ID:OkayCamera,項目名稱:OkayCamera-Android,代碼行數:9,代碼來源:OkCaptureRequestBuilder.java

示例4: captureStillPicture

import android.hardware.camera2.CaptureRequest; //導入方法依賴的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

示例5: triggerImageCapture

import android.hardware.camera2.CaptureRequest; //導入方法依賴的package包/類
/**
 * Execute a new capture request within the active session
 */
private void triggerImageCapture() {
    try {
        final CaptureRequest.Builder captureBuilder =
                mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);
        captureBuilder.addTarget(mImageReader.getSurface());
        captureBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON);
        Log.d(TAG, "Capture request created.");
        mCaptureSession.capture(captureBuilder.build(), mCaptureCallback, null);
    } catch (CameraAccessException cae) {
        Log.d(TAG, "camera capture exception");
    } catch (IllegalStateException e) {
        Log.d(TAG, "camera freaked out");
    }
}
 
開發者ID:Deeplocal,項目名稱:android-things-drawbot,代碼行數:18,代碼來源:CameraHandler.java

示例6: onCameraReady

import android.hardware.camera2.CaptureRequest; //導入方法依賴的package包/類
/**
 * Callbacks for CameraOps {@link CameraOps.CameraReadyListener}.
 */
@Override
public void onCameraReady() {
    // Ready to send requests in, so set them up
    try {
        CaptureRequest.Builder previewBuilder =
                mCameraOps.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
        previewBuilder.addTarget(mProcessingNormalSurface);
        mCameraOps.setRepeatingRequest(previewBuilder.build(), null, mUiHandler);

    } catch (CameraAccessException e) {
        String errorMessage = getErrorString(e);
        showErrorDialog(errorMessage);
    }
}
 
開發者ID:lydia-schiff,項目名稱:hella-renderscript,代碼行數:18,代碼來源:BaseViewfinderActivity.java

示例7: triggerImageCapture

import android.hardware.camera2.CaptureRequest; //導入方法依賴的package包/類
/**
     * Execute a new capture request within the active session
     */
    private void triggerImageCapture() {
        try {
            final CaptureRequest.Builder captureBuilder =
                    mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);
            captureBuilder.addTarget(mImageReader.getSurface());
            captureBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON);
//            captureBuilder.set(CaptureRequest.CONTROL_AWB_MODE, CaptureRequest.CONTROL_AWB_MODE_AUTO);
            Log.d(TAG, "Capture request created.");
            mCaptureSession.capture(captureBuilder.build(), mCaptureCallback, null);
        } catch (CameraAccessException cae) {
            Log.d(TAG, "camera capture exception");
        }
    }
 
開發者ID:googlecodelabs,項目名稱:androidthings-imageclassifier,代碼行數:17,代碼來源:CameraHandler.java

示例8: captureStillPicture

import android.hardware.camera2.CaptureRequest; //導入方法依賴的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) {
                unlockFocus();
            }
        };

        mCaptureSession.stopRepeating();
        mCaptureSession.capture(captureBuilder.build(), CaptureCallback, null);
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}
 
開發者ID:tkrworks,項目名稱:JinsMemeBRIDGE-Android,代碼行數:42,代碼來源:Camera2BasicFragment.java

示例9: updateFlash

import android.hardware.camera2.CaptureRequest; //導入方法依賴的package包/類
/**
 * Updates the internal state of flash to {@link #mFlash}.
 */
void updateFlash(CaptureRequest.Builder requestBuilder) {
    if (!mFlashSupported) {
        return;
    }
    switch (mFlash) {
        case CameraConstants.FLASH_OFF:
            requestBuilder.set(CaptureRequest.CONTROL_AE_MODE,
                CaptureRequest.CONTROL_AE_MODE_ON);
            requestBuilder.set(CaptureRequest.FLASH_MODE,
                CaptureRequest.FLASH_MODE_OFF);
            break;
        case CameraConstants.FLASH_ON:
            requestBuilder.set(CaptureRequest.CONTROL_AE_MODE,
                CaptureRequest.CONTROL_AE_MODE_ON_ALWAYS_FLASH);
            requestBuilder.set(CaptureRequest.FLASH_MODE,
                CaptureRequest.FLASH_MODE_OFF);
            break;
        case CameraConstants.FLASH_TORCH:
            requestBuilder.set(CaptureRequest.CONTROL_AE_MODE,
                CaptureRequest.CONTROL_AE_MODE_ON);
            requestBuilder.set(CaptureRequest.FLASH_MODE,
                CaptureRequest.FLASH_MODE_TORCH);
            break;
        case CameraConstants.FLASH_AUTO:
            requestBuilder.set(CaptureRequest.CONTROL_AE_MODE,
                CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH);
            requestBuilder.set(CaptureRequest.FLASH_MODE,
                CaptureRequest.FLASH_MODE_OFF);
            break;
        case CameraConstants.FLASH_RED_EYE:
            requestBuilder.set(CaptureRequest.CONTROL_AE_MODE,
                CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH_REDEYE);
            requestBuilder.set(CaptureRequest.FLASH_MODE,
                CaptureRequest.FLASH_MODE_OFF);
            break;
    }
}
 
開發者ID:lytcom,項目名稱:CameraKitView,代碼行數:41,代碼來源:Camera2.java

示例10: triggerImageCapture

import android.hardware.camera2.CaptureRequest; //導入方法依賴的package包/類
/**
 * Execute a new capture request within the active session
 */
private void triggerImageCapture() {
    try {
        final CaptureRequest.Builder captureBuilder =
                mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);
        captureBuilder.addTarget(mImageReader.getSurface());
        captureBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON);
        mCaptureSession.capture(captureBuilder.build(), mCaptureCallback, mBackgroundHandler);
    } catch (CameraAccessException cae) {
        Log.d(TAG, "camera capture exception");
    }
}
 
開發者ID:kevalpatel2106,項目名稱:robo-car,代碼行數:15,代碼來源:PiCameraDriver.java

示例11: captureStillPicture

import android.hardware.camera2.CaptureRequest; //導入方法依賴的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;
            }
            Log.d(TAG, "captureStillPicture: ");
            // 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());
            captureBuilder.set(CaptureRequest.EDGE_MODE, CaptureRequest.EDGE_MODE_HIGH_QUALITY);
            captureBuilder.set(CaptureRequest.COLOR_CORRECTION_MODE, CaptureRequest.COLOR_CORRECTION_MODE_HIGH_QUALITY);

            // 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));
            //Set the JPEG quality here like so
            captureBuilder.set(CaptureRequest.JPEG_QUALITY, (byte) 100);

            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());
                    refreshAndroidGallery(Uri.fromFile(mFile));
                    scanner.onBitmapSelect(Uri.fromFile(mFile));
//                    mFile = new File(Environment.getExternalStoragePublicDirectory(DIRECTORY_DCIM).getAbsolutePath() +
//                            File.separator + "insta_download" + File.separator + System.currentTimeMillis() + ".jpg");
                }
            };

            mCaptureSession.stopRepeating();
            mCaptureSession.capture(captureBuilder.build(), CaptureCallback, null);
        } catch (CameraAccessException e) {
            e.printStackTrace();
        }
    }
 
開發者ID:vulovicv23,項目名稱:opencv-documentscanner-android,代碼行數:52,代碼來源:Camera2BasicFragment.java

示例12: setup3AControlsLocked

import android.hardware.camera2.CaptureRequest; //導入方法依賴的package包/類
/**
 * Configure the given {@link CaptureRequest.Builder} to use auto-focus, auto-exposure, and
 * auto-white-balance controls if available.
 * <p/>
 * Call this only with {@link #mCameraStateLock} held.
 *
 * @param builder the builder to configure.
 */
private void setup3AControlsLocked(CaptureRequest.Builder builder) {
    // Enable auto-magical 3A run by camera device
    builder.set(CaptureRequest.CONTROL_MODE,
            CaptureRequest.CONTROL_MODE_AUTO);

    Float minFocusDist =
            mCharacteristics.get(CameraCharacteristics.LENS_INFO_MINIMUM_FOCUS_DISTANCE);

    // If MINIMUM_FOCUS_DISTANCE is 0, lens is fixed-focus and we need to skip the AF run.
    mNoAFRun = (minFocusDist == null || minFocusDist == 0);

    if (!mNoAFRun) {
        // If there is a "continuous picture" mode available, use it, otherwise default to AUTO.
        if (contains(mCharacteristics.get(
                CameraCharacteristics.CONTROL_AF_AVAILABLE_MODES),
                CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE)) {
            builder.set(CaptureRequest.CONTROL_AF_MODE,
                    CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
        } else {
            builder.set(CaptureRequest.CONTROL_AF_MODE,
                    CaptureRequest.CONTROL_AF_MODE_AUTO);
        }
    }

    // If there is an auto-magical flash control mode available, use it, otherwise default to
    // the "on" mode, which is guaranteed to always be available.
    if (contains(mCharacteristics.get(
            CameraCharacteristics.CONTROL_AE_AVAILABLE_MODES),
            CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH)) {
        builder.set(CaptureRequest.CONTROL_AE_MODE,
                CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH);
    } else {
        builder.set(CaptureRequest.CONTROL_AE_MODE,
                CaptureRequest.CONTROL_AE_MODE_ON);
    }

    // If there is an auto-magical white balance control mode available, use it.
    if (contains(mCharacteristics.get(
            CameraCharacteristics.CONTROL_AWB_AVAILABLE_MODES),
            CaptureRequest.CONTROL_AWB_MODE_AUTO)) {
        // Allow AWB to run auto-magically if this device supports this
        builder.set(CaptureRequest.CONTROL_AWB_MODE,
                CaptureRequest.CONTROL_AWB_MODE_AUTO);
    }
}
 
開發者ID:OkayCamera,項目名稱:OkayCamera-Android,代碼行數:54,代碼來源:Camera2RawFragment.java

示例13: setAutoFlash

import android.hardware.camera2.CaptureRequest; //導入方法依賴的package包/類
private void setAutoFlash(CaptureRequest.Builder requestBuilder) {
    if (mFlashSupported) {
        requestBuilder.set(CaptureRequest.CONTROL_AE_MODE,
                CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH);
    }
}
 
開發者ID:InnoFang,項目名稱:Android-Code-Demos,代碼行數:7,代碼來源:Camera2BasicFragment.java

示例14: setUpCaptureRequestBuilder

import android.hardware.camera2.CaptureRequest; //導入方法依賴的package包/類
private void setUpCaptureRequestBuilder(CaptureRequest.Builder builder) {
    builder.set(CaptureRequest.CONTROL_MODE, CameraMetadata.CONTROL_MODE_AUTO);
}
 
開發者ID:team-supercharge,項目名稱:SCCameraView,代碼行數:4,代碼來源:Camera2View.java

示例15: captureStillPicture

import android.hardware.camera2.CaptureRequest; //導入方法依賴的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() {
    System.out.println("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) {
                Log.d(TAG, mFile.toString());
                System.out.println("onCaptureCompleted");
                unlockFocus();
            }
        };

        mCaptureSession.stopRepeating();
        mCaptureSession.capture(captureBuilder.build(), CaptureCallback, null);
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}
 
開發者ID:TongLi1992,項目名稱:Camera_Calibration_Android,代碼行數:45,代碼來源:Camera2BasicFragment.java


注:本文中的android.hardware.camera2.CaptureRequest.Builder方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。