gpt4 book ai didi

java - 错误: Failed to create capture session

转载 作者:太空宇宙 更新时间:2023-11-04 12:38:38 25 4
gpt4 key购买 nike

我使用下面的代码来捕获图像:

mCameraDevice.createCaptureSession(Arrays.asList(previewSurface, mImageReader.getSurface()), new CameraCaptureSession.StateCallback(){
@Override
public void onConfigured(CameraCaptureSession session) {
if(mCameraDevice == null){
return;
}
try{
mPreviewCaptureRequest = mPreviewCaptureRequestBuider.build();
mCameraCaptureSession = session;
mCameraCaptureSession.setRepeatingRequest(
mPreviewCaptureRequest,
mSessionCaptureCallback,
mBackgroundHandler
);
}catch(CameraAccessException e){
e.printStackTrace();
}
}

@Override
public void onConfigureFailed(CameraCaptureSession session) {
Toast.makeText(getApplicationContext(), "create camera session failed!", Toast.LENGTH_SHORT).show();
}
}, null);

Error: Failed to create capture session

在设置相机中。我有:

Size largestImageSize = Collections.max(
Arrays.asList(map.getOutputSizes(ImageFormat.JPEG)),
new Comparator<Size>() {
@Override
public int compare(Size lhs, Size rhs) {
return Long.signum(lhs.getWidth() * lhs.getHeight() - rhs.getWidth() * rhs.getHeight());
}
}
);
mImageReader = ImageReader.newInstance(largestImageSize.getWidth(), largestImageSize.getHeight(), ImageFormat.JPEG, 1);
mImageReader.setOnImageAvailableListener(mOnImageAvailableListener, mBackgroundHandler);

权限:

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-feature android:name="android.hardware.camera2.full" />

我认为问题在于从mImageReader获取表面。但是,我不知道在这里做什么!

最佳答案

您是否在 list 文件中设置了以下内容?

<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

关于java - 错误: Failed to create capture session,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37060114/

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