当前位置: 首页>>代码示例>>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;未经允许,请勿转载。