gpt4 book ai didi

android - 高速捕获请求 Android Marshmallow

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:15:56 25 4
gpt4 key购买 nike

我在设置高速视频的捕获请求时遇到了一些问题。我打算在 Nexus 6P 上以 120 FPS 的速度进行捕捉。我将最小 API 设置为 23,因为我不打算将此应用程序部署到任何其他手机。

我不太明白如何让我的捕获请求起作用。现在,我正在尽最大努力更改谷歌示例中 Camera2Video 示例中的代码。 Link to sample from Google

这里是所有相关代码:

private void startPreview() {
if (null == mCameraDevice || !mTextureView.isAvailable() || null == mPreviewSize) {
return;
}
try {
setUpMediaRecorder();
SurfaceTexture texture = mTextureView.getSurfaceTexture();
assert texture != null;
texture.setDefaultBufferSize(mPreviewSize.getWidth(), mPreviewSize.getHeight());
mPreviewBuilder = mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_RECORD);
List<Surface> surfaces = new ArrayList<Surface>();

Surface previewSurface = new Surface(texture);
surfaces.add(previewSurface);
mPreviewBuilder.addTarget(previewSurface);

Surface recorderSurface = mMediaRecorder.getSurface();
surfaces.add(recorderSurface);
mPreviewBuilder.addTarget(recorderSurface);

mCameraDevice.createConstrainedHighSpeedCaptureSession(surfaces, new CameraCaptureSession.StateCallback() {
//mCameraDevice.createCaptureSession(surfaces, new CameraCaptureSession.StateCallback() {

@Override
public void onConfigured(CameraCaptureSession cameraCaptureSession) {
//mPreviewSession = cameraCaptureSession;
mPreviewSession2 = cameraCaptureSession;
updatePreview();
}

@Override
public void onConfigureFailed(CameraCaptureSession cameraCaptureSession) {
Activity activity = getActivity();
if (null != activity) {
Toast.makeText(activity, "Failed", Toast.LENGTH_SHORT).show();
}
}
}, mBackgroundHandler);
} catch (CameraAccessException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}


/**
* Update the camera preview. {@link #startPreview()} needs to be called in advance.
*/
private void updatePreview() {
if (null == mCameraDevice) {
return;
}
try {
setUpCaptureRequestBuilder(mPreviewBuilder);
HandlerThread thread = new HandlerThread("CameraPreview");
thread.start();
mPreviewBuilder2 = mPreviewSession2.createHighSpeedRequestList(mPreviewBuilder.build());
//mPreviewBuilder2 =


//mPreviewSession.setRepeatingRequest(mPreviewBuilder.build(), null, mBackgroundHandler);
mPreviewSession.setRepeatingBurst(mPreviewBuilder2, null, mBackgroundHandler);
} catch (CameraAccessException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch(Exception e){
e.printStackTrace();
}
}

private void setUpCaptureRequestBuilder(CaptureRequest.Builder builder) {
builder.set(CaptureRequest.CONTROL_MODE, CameraMetadata.CONTROL_MODE_AUTO);
Range<Integer> fpsRange = Range.create(120, 120);
builder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, fpsRange);

}

获取更新预览的代码没有问题。不幸的是,从那里我遇到了如何向 setRepeatingBurst 提供我的捕获请求的障碍。我知道构造函数与示例的 setRepeatingRequest 不同。因此,我需要找到一种方法来为我的表面、我的 CONTROL_MODE 请求和我的 TARGET_FPS_RANGE 请求提供 setRepeatingBurst。

/**
* Camera preview.
*/
private CaptureRequest.Builder mPreviewBuilder;
List<CaptureRequest> mPreviewBuilder2;

/**
* A reference to the current {@link android.hardware.camera2.CameraCaptureSession} for
* preview.
*/
private CameraCaptureSession mPreviewSession;
private CameraConstrainedHighSpeedCaptureSession mPreviewSession2;

任何帮助弄清楚如何使这项工作正常工作的人都会非常有帮助。我在网上没有找到太多帮助,StackOverflow 中也没有任何文章提到任何高速捕获功能。我最大的问题是试图了解 createConstrainedHighSpeedCaptureSession 如何提供 CameraConstrainedHighSpeedCaptureSession session 。这样我就可以使用 createHighSpeedRequestList。

最佳答案

我遇到了类似的问题,但是用你的问题解决了。

在你的情况下,我认为如果你调用它应该可以工作

mPreviewSession2.setRepeatingBurst(mPreviewBuilder2, null, mBackgroundHandler);

代替

mPreviewSession.setRepeatingBurst(mPreviewBuilder2, null, mBackgroundHandler);

因为您随后要在 CameraConstrainedHighSpeedCaptureSession 上设置 RepeatingBurst


我制作了一个 github 存储库,展示了如何使用 camera2 api 创建高速录制 session 。

https://github.com/thesleort/Android-Slow-Motion-Camera2.git

关于android - 高速捕获请求 Android Marshmallow,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35048208/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com