CameraPreview camera2 stretched on some devices

I am developing a camera application using camera2 api. I use the project in this link: https://github.com/googlesamples/android-Camera2Basic

Here is my problem:

  • If I set the relation as the display relation, everything is fine.
  • If I need a 4: 3 camera preview, I have problems with Samsung Note 4 (both rear and front camera), on Nexus 6 (front camera). The camera preview is stretched horizontally. Here are the images (left: what I expected is correct: what I got).

I expected And what I got

Please help me solve this problem.

+5
source share
1 answer

Some cameras do not support preview sizes that match your 4: 3 view. You can crop the image by resizing the SurfaceView or use the same compensation with texture coordinates if you use OpenGL.

0
source

Source: https://habr.com/ru/post/1232522/


All Articles