Camera2 API:能否将两个摄像机输出到同一平面上? [英] Camera2 API: can it output two cameras into same surface?

查看:235
本文介绍了Camera2 API:能否将两个摄像机输出到同一平面上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对将两台摄像机的信号连接到一个表面有特殊要求.每个摄像机将充满整个表面的一半. 该表面将被显示或驻留在OpenGL纹理中.

I have specific requirement to connect signal from two Cameras into one surface. Each camera would fill half of the surface. The surface would be either displayed or reside in OpenGL texture.

使用Camera2 API完全可以吗?第一件事是指定要在表面上投影的目标矩形,第二件事是两个摄像机是否可以将单个表面用作输出.

Is this at all possible using Camera2 API? First thing is specifying target rectangle for projection on surface, second thing is if two cameras can use single surface as output.

这样做的原因是我们的硬件将一个图像信号分成两个Android相机,并且需要将图像重新连接到软件中,以便可以使用MediaRecorder将包含两个相机的图像的表面保存为视频.

Reason for this is that our hardware delivers one picture signal split into two Android cameras, and there is need to connect the the picture back in software, so that surface containing picture of both cameras can be possibly saved as video using MediaRecorder.

谢谢

推荐答案

不直接. Surface一次只能由一个生产源拥有,因此,如果在相机设备0的会话配置中包含特定的Surface,则尝试同时将其与相机设备1一起使用将使您在会话中出错相机设备1的创建.

Not directly. A Surface can only be owned by a single producing source at a time, so if you include a particular Surface in a session configuration for camera device 0, trying to use it with camera device 1 at the same time will get you an error in session creation for camera device 1.

如果要执行此操作,则需要实现自己的合并,该合并将从每个摄像机中获取缓冲区,然后将它们合成为一个输出.

If you want to do this, you'll need to implement your own merger, which takes in buffers from each camera, and composites them into one output.

最有效的途径可能是通过GPU和OpenGL.简而言之,您需要创建一个OpenGL上下文和两个SurfaceTexture,每个相机输出一个.然后,您可以使用

The most efficient route for this is likely via the GPU and OpenGL. In short, you'll need to create an OpenGL context and two SurfaceTextures, one for each camera output. Then you can use EGLCreateWindowSurface with the MediaRecorder Surface to create an output EGL window to draw into.

此时,您可以将两种输入纹理以任何所需的方式渲染到输出表面中-听起来您想要的是两个并排的矩形,每个矩形都有一个摄像机的输出.

At that point, you can render with the two input textures into your output surface in any way you want - it sounds like what you want is two side-by-side rectangles, each with one camera's output.

设置Android EGL环境的详细信息太长,无法在此处介绍,但是应该有很多可用的示例.

The details of setting up an Android EGL environment are too long to put here, but there should be plenty of samples of that available.

这篇关于Camera2 API:能否将两个摄像机输出到同一平面上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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