Android OpenGL camera2 纹理分辨率
Android OpenGL camera2 texture resolution
简介
我正在使用 CaptureRequest.Builder and provide two surfaces as a target: a SurfaceTexture for drawing GL and an ImageReader (getSurface()) 处理帧。
我通过设置 surfaceTexture.setDefaultBufferSize and by creating ImageReader.newInstance.
设置了所需的分辨率 640x480
问题
似乎 SurfaceTexture OpenGL texture is getting image that is of different aspect ration than 640x480 (4:3), more like 2560x1440 (16:9)(SurfaceTexture 占满了屏幕,参见 IMG 3)。必须注意的是,两个 phone 具有相同的分辨率纵横比 16:9。 (有意留下与侧面的纹理偏移)。
下面你可以看到IMG 1显示在监视器屏幕上,IMG 2和IMG 3 是 phone 屏幕截图,其中当前 activity 视图显示相机预览。
问题
如何正确地强制 SurfaceTexture or GLSurfaceView.Renderer 从相机获取任意尺寸视图的特定(在本例中为 4:3)纵横比纹理图像?
相关
需要注意的是有an app that addresses issue, but for that they change the view size对应想要的宽高比
另见:
- GitHub repo.
- Relevant source code.
- Related post
IMG 1 - 显示的源图像:
IMG 2 - 良好的宽高比(Google Nexus 5 - Android 6.0.1):
IMG 3 - 纹理宽高比错误(LG-D855 - Android 5.0)
"Fixed" 通过将 LG phone 更新到 Android 6.0 来解决这个问题。
简介
我正在使用 CaptureRequest.Builder and provide two surfaces as a target: a SurfaceTexture for drawing GL and an ImageReader (getSurface()) 处理帧。
我通过设置 surfaceTexture.setDefaultBufferSize and by creating ImageReader.newInstance.
设置了所需的分辨率 640x480问题
似乎 SurfaceTexture OpenGL texture is getting image that is of different aspect ration than 640x480 (4:3), more like 2560x1440 (16:9)(SurfaceTexture 占满了屏幕,参见 IMG 3)。必须注意的是,两个 phone 具有相同的分辨率纵横比 16:9。 (有意留下与侧面的纹理偏移)。
下面你可以看到IMG 1显示在监视器屏幕上,IMG 2和IMG 3 是 phone 屏幕截图,其中当前 activity 视图显示相机预览。
问题
如何正确地强制 SurfaceTexture or GLSurfaceView.Renderer 从相机获取任意尺寸视图的特定(在本例中为 4:3)纵横比纹理图像?
相关
需要注意的是有an app that addresses issue, but for that they change the view size对应想要的宽高比
另见:
- GitHub repo.
- Relevant source code.
- Related post
IMG 1 - 显示的源图像:
IMG 2 - 良好的宽高比(Google Nexus 5 - Android 6.0.1):
IMG 3 - 纹理宽高比错误(LG-D855 - Android 5.0)
"Fixed" 通过将 LG phone 更新到 Android 6.0 来解决这个问题。