cameraX preview Skews when I tilt my device sideways(Left or right) using GlSurfaceView

91 views Asked by At

I am making a camera filter app, for that I am using opengles and CameraX, when I use PreviewView everything works fine but when I use GlSurfaceView the preview starts to skew as I move my device sideways.

image example for skewing of camera output

  1. I am creating a texture in the renderer
  2. creating a surface texture out of the texture
  3. creating a surface provider from that surface texture
  4. finally providing this surface provider to the CameraX.

This way I am allowing cameraX to provide preview on the texture which I am manipulating through opengles to create colour filters.

Everything works just when I tilt the phone the image starts skewing and the skew increases as the angle of tilt increases.

1

There are 1 answers

0
Xi 张熹 On

Please take a look at the SurfaceProcessor API. It's designed for injecting things like OpenGL renderer into CameraX pipeline. It's compatible with PreviewView. You can find a sample code here: https://github.com/androidx/androidx/blob/androidx-main/camera/camera-core/src/main/java/androidx/camera/core/processing/DefaultSurfaceProcessor.java