- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我从 Grafika 示例开始,我想用 GlRenderView 渲染相机预览。我的问题是如何修改从 surfacetexture 获得的变换矩阵,以便像使用设备前置摄像头一样获得镜像视频预览:
mDisplaySurface.makeCurrent();
mCameraTexture.updateTexImage();
mCameraTexture.getTransformMatrix(mTmpMatrix);
mFullFrameBlit.drawFrame(mTextureId, mTmpMatrix);
我尝试使用以下行,但我的视频出现了奇怪的效果://应用水平翻转。
// Apply horizontal flip.
android.opengl.Matrix.scaleM(mTmpMatrix, 0, -1, 1, 1);
谢谢大家
最佳答案
我也遇到过这个问题,奇怪的是每次调用drawFrame函数两次都是第一次正确第二次倒过来,像这样:
mSurfaceTexture.updateTexImage();
mSurfaceTexture.getTransformMatrix(mTmpMatrix);
mDisplaySurface.makeCurrent();
GLES20.glViewport(0, 0, mSurfaceView.getWidth(), mSurfaceView.getHeight());
mFullFrameBlit.drawFrame(mTextureId, mTmpMatrix);//draws in correct direction
mDisplaySurface.swapBuffers();
mOffscreenSurface.makeCurrent();
GLES20.glViewport(0, 0, desiredSize.getWidth(), desiredSize.getHeight());
mFullFrameBlit.drawFrame(mTextureId, mTmpMatrix);//draws upside down
mOffscreenSurface.getPixels();
很好奇为什么会这样......
无论如何,解决方法很简单,只需在 FullFrameRect 类中添加一个 drawFrameFilpped 函数并调用它来绘制翻转图像即可:
public void drawFrameFlipped(int textureId, float[] texMatrix) {
float[] mMatrix=GlUtil.IDENTITY_MATRIX.clone();//must clone a new one...
Matrix m=new Matrix();
m.setValues(mMatrix);
m.postScale(1,-1);
m.getValues(mMatrix);
//note: the mMatrix is how gl will transform the scene, and
//texMatrix is how the texture to be drawn onto transforms, as @fadden has mentioned
mProgram.draw(mMatrix, mRectDrawable.getVertexArray(), 0,
mRectDrawable.getVertexCount(), mRectDrawable.getCoordsPerVertex(),
mRectDrawable.getVertexStride(),
texMatrix, mRectDrawable.getTexCoordArray(), textureId,
mRectDrawable.getTexCoordStride());
}
然后打电话
mFullFrameBlit.drawFrameFlipped(mTextureId, mTmpMatrix);
关于Android 使用 SurfaceTexture TransformMatrix 镜像相机预览,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41748038/
在 onPause 中,我使用 mTextureView.getSurfaceTexture() 将 surfaceTexture 存储到类变量 mTextureViewSurface 在 onRes
我可以渲染 YUVI420框架上 GLSurfaceView使用 openGL,但我的要求是在 SurfaceTexture 上渲染帧. 基本上我想为 SurfaceTexture 制作框架不像渲染到
只是一个简单的问题:我使用的着色器允许视频作为来自 SurfaceTexture 的 GL_TEXTURE_EXTERNAL_OES,但现在我想修改它以接受来自两个不同 SurfaceTexture
我是这里和 android 的新手 :)我有一个 android 应用程序,它正在从相机接收帧并尝试处理它们(也使用 OpenCv 查找特定颜色)。我使用 SurfaceTexture setPrev
我正在使用 Exoplayer 和 GL SurfaceTexture(来自 TextureView)来显示视频。我在视频播放中重复使用相同的表面。 我释放播放器并实例化一个新播放器。第二次显示 Su
是否可以在两个进程之间共享 SurfaceTexture,例如 Activity 和 Service? 我想创建一个带有 TextureView 的 Activity,并从一个单独的服务更新它的 Su
我想在通过 setPreviewTexture 连接到 Camera 的 SurfaceTexture 上绘图。我可以通过 SurfaceTextureListener 获取 SurfaceTextu
我正在使用 SurfaceTexture 绘制相机预览,需要知道纹理的大小 + 过程中发生的情况。 假设设备支持的相机预览尺寸为: 1280 720、1024 576、960 720、800 600、
我正在我的应用程序中实现 SurfaceTexture.OnFrameAvailableListener 接口(interface),因此我可以将视频帧用作 OpenGL 纹理。一切都按应有的方式设置
当我将视频解码到表面时,我想将我想要的帧保存为位图/jpeg 文件。我不想在屏幕上绘图,只想将 SurfaceTexture 的内容保存为图像文件。 最佳答案 你必须渲染纹理。 如果它是普通纹理,并且
是否可以使用 MediaCodec API 解密和解码数据? 我想解密和解码由 Widevine 或其他 DRM 机制加密的数据。 我想尝试的基本事情是 我使用从 SurfaceTexure 创建的
实际上我正在尝试在不显示预览的情况下拍照。为此,我想出了 SurfaceTexture,但我想知道表面纹理中的 texName 是什么以及它的用途是什么? //c is camera instance
我正在执行需要双 channel 渲染的视频效果(纹理需要通过多个着色器程序)。将 SurfaceTexture 附加到构造函数中传递的 GL_TEXTURE_EXTERNAL_OES 似乎不是解决方
更新:问题是关于 Camera2 当在 SurfaceTexture 上绘制相机预览时,我试图找出谁应用了旋转变换。 当从相机请求预览尺寸时,您总是会得到宽度大于高度的对(因为横向是拍照时的通常方向)
SurfaceTexture 是否在手动创建时默认附加到 GLContext?如果是,怎么办? 这是一个示例,我正在尝试创建自己的 SurfaceTexture 并将其设置为 TextureView:
我从 Grafika 示例开始,我想用 GlRenderView 渲染相机预览。我的问题是如何修改从 surfacetexture 获得的变换矩阵,以便像使用设备前置摄像头一样获得镜像视频预览: mD
我想在类似于 this answer 的设置中创建一个带有我可以管理的 OpenGL 纹理的 SurfaceTexture . (此处引用:) Create a texture through Ope
我想将相机预览 SurfaceTexture 与一些覆盖纹理混合。我正在使用这些着色器进行处理: private final String vss = "attribute vec2 vPositio
我正在使用带有 TextureView 子级的 ListView。 TextureView 使用 MediaPlayer 播放视频。当 TextureView 被回收时,最后一帧保留在表面上,直到下一
我想使用 Android 3.0 在 XOOM 上将视频播放到 OpenGL 纹理中。我在 API 11 中添加的 goole 开发人员文档中遇到了 SurfaceTexture http://dev
我是一名优秀的程序员,十分优秀!