本文整理匯總了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);
}
}
示例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());
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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);
}
示例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);
}