Roy Shilkrot
Roy Shilkrot

Reputation: 3578

ImageReader acquireLastestImage of different resolution than ImageReader itself on Galaxy S6

I'm trying to read an image from an ImageReader set to a particular resolution (obtained from CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP of course), but the ImageReader.acquireLastestImage returns an image of a different resolution!

Note: This only happens (so far as I've seen) on Samsung Galaxy S6 with the preview resolution set to 800x450, and the output resolution on the Image is apparently 640x480. Other resolutions seem fine, as well as other phones.

Relevant code:

Image im = mReader.acquireLatestImage();
Log.v(TAG, String.format("Image       size %d x %d", im.getWidth(), im.getHeight()));
Log.v(TAG, String.format("ImageReader size %d x %d", mReader.getWidth(), mReader.getHeight()));

The output log:

01-30 15:43:46.350 31422-31954/com.myapp V/ImageProcessor: Image       size 640 x 480
01-30 15:43:46.350 31422-31954/com.myapp V/ImageProcessor: ImageReader size 800 x 450

What could be wrong? A bug in Android? A bug in the Galaxy S6 implementation?

Is it not guaranteed that the camera will abide by the request of the ImageReader surface?

Upvotes: 1

Views: 1429

Answers (2)

Domagoj Korman
Domagoj Korman

Reputation: 1

The problem could be that you are reading "wrong" output sizes. Try getting output sizes with the same ImageFormat that is used when initializing your ImageReader.

So for example if you initialize your ImageReader with

ImageReader.newInstance(width, height, ImageFormat.JPEG, 1)

Fetch your available output sizes with

cameraCharacteristics
  .get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP)
  .getOutputSizes(ImageFormat.JPEG)

In my case I was using ImageReader.class instead of ImageFormat.JPEG when fetching available output sizes thus I received some output sizes that were not supported by JPEG format.

Upvotes: 0

Alex Cohn
Alex Cohn

Reputation: 57203

I don't have S6 at hand, (and if I had, this might not be same as yours). Still I can confirm that 800x450 is a very strange resolution for a phone camera. This could be a bug on some S6 devices that makes a false claim to support this preview size.

If that's so, I would not be surprised: I have seen some models from different brands that had similar bugs, including Samsung Galaxy Nexus which falsely reported support for 320x240. That device also (like your S6) produced images of different size when our app asked for QVGA.

Having said this, I can also contemplate a bug in your code, e.g. if you list supported resolutions for the front camera, and apply one of them to the rear camera.

At any rate, the preinstalled camera app does not use 800x450:

Rear

S6 Front

Upvotes: 0

Related Questions