3

Hello I have a problem with camera 2 api. I am using the front camera and a surface view for display the preview.

When I get the list of sizes from StreamConfigurationMap, i have this list of sizes.

> 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"

The choose a preferred size to use as a Preview Size. Like this:

mTexturePreviewSize = getPreferredSize(sizeList, width, height);

The preferred size chosen was the 1600*1200.

When calling to 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();
                }
            }

I have onConfigureFailed. I thought any of the size in the list would allow me to configure the camera correctly.

LittleFunny
  • 8,155
  • 15
  • 87
  • 198
  • Are you sure, that problem caused by selected size? Can you provide full log of error? Did you try to set another sizes and it was OK? – Maxim Metelskiy Dec 30 '15 at 08:40
  • Probably you should set preview size to TextureView.... i.e. textureView.getSurfaceTexture().setDefaultBufferSize(1600, 1200); – user1991679 Jul 28 '16 at 13:51
  • Add the log and we could help you better, normally when this error happens it show the wrong setted sized and the list of valid ones, show this error log please – Sulfkain Feb 14 '18 at 10:39
  • Most likely, `1600x1200` is a valid size for Jpeg (a.k.a. still capture), not for preview. – Alex Cohn Oct 08 '20 at 17:40

0 Answers0