2

Intro

I'm using CaptureRequest.Builder and provide two surfaces as a target: a SurfaceTexture for drawing GL and an ImageReader (getSurface()) for processing frame.

I set desired resolution 640x480 by setting surfaceTexture.setDefaultBufferSize and by creating ImageReader.newInstance.

The problem

It appears that SurfaceTexture OpenGL texture is getting image that is of different aspect ration than 640x480 (4:3), more like 2560x1440 (16:9)(SurfaceTexture occupying full screen, see IMG 3). It has to be noted that both phones have same resolution aspect ratio 16:9. (Texture offset from the sides is left intentionally).

Below you can see IMG 1 displayed on a monitor screen, and IMG 2 and IMG 3 are phone screen captures where current activity view is showing camera preview.

The question

How to correctly force SurfaceTexture or GLSurfaceView.Renderer to get specific (4:3 in this case) aspect ratio texture image from camera for arbitrary size View?

Relevant

It has to be noted that there is an app that addresses issue, but for that they change the view size to correspond to desired aspect ratio.

See also:

IMG 1 - Displayed source image: enter image description here

IMG 2 - Good aspect ratio (Google Nexus 5 - Android 6.0.1): enter image description here

IMG 3 - Bad texture aspect ratio (LG-D855 - Android 5.0) enter image description here

alex
  • 425
  • 4
  • 21

1 Answers1

0

"Fixed" the issue by updating LG phone to Android 6.0.

alex
  • 425
  • 4
  • 21
  • It's not a solution if you release your app to the world. So don't use Camera2 API if you support Android 5-7: https://github.com/googlesamples/android-Camera2Basic/issues/123 – user25 Jan 06 '19 at 16:13