Skip to content Skip to sidebar Skip to footer

Android Camera2 Capture Image Skewed

Update: This looks like it's related to this: Image data from Android camera2 API flipped & squished on Galaxy S5 - I consider this as a bug since Nexus 5/6 works correctly and

Solution 1:

I encounter similar issue, model SM-A7009 with api level 21, legacy camera2 device.

The preview is stretched, surfaceTexture.setDefaultBufferSize not working, the framework will override these value when preview started.

The preview sizes reported from StreamConfigurationMap.getOutputSizes(SurfaceTexture.class) are not all supported.

Only three of them are supported.

$ adb shell dumpsys media.camera |grep preview-size
preferred-preview-size-for-video: 1920x1080preview-size: 1440x1080preview-size-values: 1920x1080,1440x1080,1280x720,1056x864,960x720,880x720,800x480,720x480,640x480,528x432,352x288,320x240,176x144

The system dump info list many of the preview sizes, after check all of them, I found only 1440x1080, 640x480, 320x240 are supported.

The supported preview sizes all have 1.33333 ratio. They have the same ratio reported from CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE.

So I thought it's a bug in some samsung devices with legacy camera2 api in API 21.

The solution is making these devices using deprecated camera API.

Hope it would be helpful for anyone reach here.

Solution 2:

So yes, this is a bug on those Samsung devices.

Generally this happens when you ask for multiple different aspect ratios on output, and the device-specific camera code trips over itself on cropping and scaling all of them correctly. You may be able to avoid it by ensuring all requested sizes have the same aspect ratio.

The resolution is probably actually what you asked for - but it's been incorrectly scaled (you could test this with an ImageReader at the problematic size, where you get an explicit buffer you can poke at.)

We are adding additional testing to the Android compliance tests to try to ensure these kinds of stretched outputs don't continue to happen.

Post a Comment for "Android Camera2 Capture Image Skewed"