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


Java CameraCaptureSession.setRepeatingRequest方法代碼示例

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


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

示例1: 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

示例2: 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

示例3: onConfigured

import android.hardware.camera2.CameraCaptureSession; //導入方法依賴的package包/類
@Override
public void onConfigured(CameraCaptureSession session) {
    mCameraCaptureSession = session;
    try {
        // 自動對焦
        mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
        // 自動閃光燈
        mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH);
        CaptureRequest previewRequest = mPreviewRequestBuilder.build();
        session.setRepeatingRequest(previewRequest, null, mPreviewHandler);
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}
 
開發者ID:uestccokey,項目名稱:EZFilter,代碼行數:15,代碼來源:Camera2Input.java

示例4: onConfigured

import android.hardware.camera2.CameraCaptureSession; //導入方法依賴的package包/類
@Override
public void onConfigured(CameraCaptureSession session) {
    try {
        //session.capture(mPreviewBuilder.build(), mSessionCaptureCallback, mHandler);
        session.setRepeatingRequest(mPreviewBuilder.build(), mSessionCaptureCallback, mHandler);
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}
 
開發者ID:vipycm,項目名稱:mao-android,代碼行數:10,代碼來源:Camera2Fragment.java

示例5: onConfigured

import android.hardware.camera2.CameraCaptureSession; //導入方法依賴的package包/類
@Override
public void onConfigured(CameraCaptureSession cameraCaptureSession) {
    try {
        mCameraSession = cameraCaptureSession;
        cameraCaptureSession.setRepeatingRequest(mPreViewBuilder.build(), null, mHandler);
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}
 
開發者ID:lupwei,項目名稱:Croprotector,代碼行數:10,代碼來源:Shoot_fragment.java

示例6: onConfigured

import android.hardware.camera2.CameraCaptureSession; //導入方法依賴的package包/類
@Override
public void onConfigured(CameraCaptureSession session) {
  checkIsOnCameraThread();
  Logging.d(TAG, "Camera capture session configured.");
  captureSession = session;
  try {
    /*
     * The viable options for video capture requests are:
     * TEMPLATE_PREVIEW: High frame rate is given priority over the highest-quality
     *   post-processing.
     * TEMPLATE_RECORD: Stable frame rate is used, and post-processing is set for recording
     *   quality.
     */
    final CaptureRequest.Builder captureRequestBuilder =
        cameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_RECORD);
    // Set auto exposure fps range.
    captureRequestBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE,
        new Range<Integer>(captureFormat.framerate.min / fpsUnitFactor,
                                  captureFormat.framerate.max / fpsUnitFactor));
    captureRequestBuilder.set(
        CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON);
    captureRequestBuilder.set(CaptureRequest.CONTROL_AE_LOCK, false);
    chooseStabilizationMode(captureRequestBuilder);
    chooseFocusMode(captureRequestBuilder);

    captureRequestBuilder.addTarget(surface);
    session.setRepeatingRequest(
        captureRequestBuilder.build(), new CameraCaptureCallback(), cameraThreadHandler);
  } catch (CameraAccessException e) {
    reportError("Failed to start capture request. " + e);
    return;
  }

  surfaceTextureHelper.startListening(
      new SurfaceTextureHelper.OnTextureFrameAvailableListener() {
        @Override
        public void onTextureFrameAvailable(
            int oesTextureId, float[] transformMatrix, long timestampNs) {
          checkIsOnCameraThread();

          if (state != SessionState.RUNNING) {
            Logging.d(TAG, "Texture frame captured but camera is no longer running.");
            surfaceTextureHelper.returnTextureFrame();
            return;
          }

          if (!firstFrameReported) {
            firstFrameReported = true;
            final int startTimeMs =
                (int) TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - constructionTimeNs);
            camera2StartTimeMsHistogram.addSample(startTimeMs);
          }

          int rotation = getFrameOrientation();
          if (isCameraFrontFacing) {
            // Undo the mirror that the OS "helps" us with.
            // http://developer.android.com/reference/android/hardware/Camera.html#setDisplayOrientation(int)
            transformMatrix = RendererCommon.multiplyMatrices(
                transformMatrix, RendererCommon.horizontalFlipMatrix());
          }

          // Undo camera orientation - we report it as rotation instead.
          transformMatrix =
              RendererCommon.rotateTextureMatrix(transformMatrix, -cameraOrientation);

          events.onTextureFrameCaptured(Camera2Session.this, captureFormat.width,
              captureFormat.height, oesTextureId, transformMatrix, rotation, timestampNs);
        }
      });
  Logging.d(TAG, "Camera device successfully started.");
  callback.onDone(Camera2Session.this);
}
 
開發者ID:lgyjg,項目名稱:AndroidRTC,代碼行數:73,代碼來源:Camera2Session.java

示例7: onConfigured

import android.hardware.camera2.CameraCaptureSession; //導入方法依賴的package包/類
@Override
public void onConfigured(CameraCaptureSession session) {
  checkIsOnCameraThread();
  Logging.d(TAG, "Camera capture session configured.");
  captureSession = session;
  try {
    /*
     * The viable options for video capture requests are:
     * TEMPLATE_PREVIEW: High frame rate is given priority over the highest-quality
     *   post-processing.
     * TEMPLATE_RECORD: Stable frame rate is used, and post-processing is set for recording
     *   quality.
     */
    final CaptureRequest.Builder captureRequestBuilder =
        cameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_RECORD);
    // Set auto exposure fps range.
    captureRequestBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE,
        new Range<Integer>(captureFormat.framerate.min / fpsUnitFactor,
            captureFormat.framerate.max / fpsUnitFactor));
    captureRequestBuilder.set(
        CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON);
    captureRequestBuilder.set(CaptureRequest.CONTROL_AE_LOCK, false);
    chooseStabilizationMode(captureRequestBuilder);
    chooseFocusMode(captureRequestBuilder);

    captureRequestBuilder.addTarget(surface);
    if (mediaRecorderSurface != null) {
      Logging.d(TAG, "Add MediaRecorder surface to CaptureRequest.Builder");
      captureRequestBuilder.addTarget(mediaRecorderSurface);
    }
    session.setRepeatingRequest(
        captureRequestBuilder.build(), new CameraCaptureCallback(), cameraThreadHandler);
  } catch (CameraAccessException e) {
    reportError("Failed to start capture request. " + e);
    return;
  }

  surfaceTextureHelper.startListening(
      new SurfaceTextureHelper.OnTextureFrameAvailableListener() {
        @Override
        public void onTextureFrameAvailable(
            int oesTextureId, float[] transformMatrix, long timestampNs) {
          checkIsOnCameraThread();

          if (state != SessionState.RUNNING) {
            Logging.d(TAG, "Texture frame captured but camera is no longer running.");
            surfaceTextureHelper.returnTextureFrame();
            return;
          }

          if (!firstFrameReported) {
            firstFrameReported = true;
            final int startTimeMs =
                (int) TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - constructionTimeNs);
            //camera2StartTimeMsHistogram.addSample(startTimeMs);
          }

          int rotation = getFrameOrientation();

          // make sure it appears in right orientation and flip using GlRectDrawer

          //if (isCameraFrontFacing) {
          //  // Undo the mirror that the OS "helps" us with.
          //  // http://developer.android.com/reference/android/hardware/Camera.html#setDisplayOrientation(int)
          //  transformMatrix = RendererCommon.multiplyMatrices(
          //      transformMatrix, RendererCommon.horizontalFlipMatrix());
          //}
          //
          //// Undo camera orientation - we report it as rotation instead.
          //transformMatrix =
          //    RendererCommon.rotateTextureMatrix(transformMatrix, -cameraOrientation);

          events.onTextureFrameCaptured(Camera2Session.this, captureFormat.width,
              captureFormat.height, oesTextureId, transformMatrix, rotation, timestampNs);
        }
      });
  Logging.d(TAG, "Camera device successfully started.");
  callback.onDone(Camera2Session.this);
}
 
開發者ID:Piasy,項目名稱:VideoCRE,代碼行數:80,代碼來源:Camera2Session.java


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