如何旋转textureView显示相机preVIEW [英] how to rotate textureView to show a cameraPreview

查看:2263
本文介绍了如何旋转textureView显示相机preVIEW的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用摄像机2 API来显示相机preVIEW,我锁定lanscape屏幕的方向,我的问题是,我想旋转textureview以显示正确的相机preVIEW,当我旋转使用该方法setRotation,它变得更小。我搜索堆栈,但所有的解决方案都相对于摄像头(第一个API),所以有旋转textureView的解决方案。

I use the camera2 api to show a camerapreview, and i lock the screen orientation on lanscape, my problem is that i want to rotate the textureview to display the correct camerapreview, when i rotate it using the method setRotation, it becomes smaller. I search on stack but all solutions are relative to camera(first api) so is there a solution to rotate the textureView.

推荐答案

您可以添加一个旋转到TextureView的矩阵。举一个例子,请参见 Grafika的玩电影活动,它发送一个视频去$ C $的输出CR到TextureView(相同的基本原则,相机preVIEW)。

You can add a rotation to the TextureView's matrix. For an example, see Grafika's "play movie activity", which sends the output of a video decoder to a TextureView (same basic principles as Camera preview).

如果你看一下<一个href=\"https://github.com/google/grafika/blob/master/src/com/android/grafika/PlayMovieActivity.java#L211\"相对=nofollow> adjustAspectRatio() 你可以看到它调节输出的位置(翻译)和规模相匹配的视频的显示比例。还有一个注释掉 postRotate()通话将旋转输出10度。

If you look at adjustAspectRatio() you can see it adjusting the position (translation) and scale of the output to match the video's aspect ratio. There's also a commented out postRotate() call that would rotate the output 10 degrees.

请注意这是旋转视图中的视频帧,而不是视图本身。

Note this is rotating the video frame within the View, not the View itself.

这篇关于如何旋转textureView显示相机preVIEW的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆