Android:相机2 Api尺寸不在有效设置中

时间:2015-12-28 03:41:09

标签: android camera camera2

您好我的相机2 api有问题。我正在使用前置摄像头和表面视图来显示预览。

当我从StreamConfigurationMap获取大小列表时,我有这个大小列表。

> 0 = {Size@5139} "1600x1200"
1 = {Size@5152} "1280x720"
2 = {Size@5153} "960x720"
3 = {Size@5154} "720x480"
4 = {Size@5155} "640x480"
5 = {Size@5156} "480x320"
6 = {Size@5157} "320x240"
7 = {Size@5158} "176x144"

选择要用作预览尺寸的首选尺寸。像这样:

mTexturePreviewSize = getPreferredSize(sizeList, width, height);

选择的首选尺寸为1600 * 1200。

调用CreateCaptureSession时,

mCaptureRequestBuilder = mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
        mCaptureRequestBuilder.addTarget(surface);
        mCameraDevice.createCaptureSession(Arrays.asList(surface, mReader.getSurface()), new CameraCaptureSession.StateCallback() {
            @Override
            public void onConfigured(CameraCaptureSession session) {
                if (mCameraDevice == null) return;

                try {
                    mCaptureRequest = mCaptureRequestBuilder.build();
                    mCameraSession = session;
                    mCameraSession.setRepeatingRequest(mCaptureRequest, mCameraSessionCallback, mBackgroundHandler);

                } catch (CameraAccessException ex) {
                    ex.printStackTrace();
                }
            }

我有onConfigureFailed。我认为列表中的任何大小都允许我正确配置相机。

0 个答案:

没有答案