问题描述
我正在尝试构建一个 Cardboard android 应用程序,它并排显示 2 个摄像头视图.[就像相机视图适用于 VRCinema Android 应用一样.]
I am trying to build a Cardboard android application that shows 2 camera view side by side. [Just like the camera view works for VRCinema Android app.]
所以我研究了 GitHub 上的 Cardboard 代码,做了一些修改,到目前为止,我能够使用 imageView 并排复制相同的图像.
So I studies the Cardboard code from GitHub, made some modification and so far I am able to use the imageView to replicate the same image side by side.
到目前为止的代码看起来像这样.
and the Code so far looks like this.
AndroidManifest.XML
common_ui.xml
CardboardOverlayView.java
MainActivity.Java
我注意到的几点:
- 我不想要一个意图,我需要相机预览,以便稍后我可以用它做其他事情,比如拍照.
- 如果我尝试用 surfaceView 替换 imageView,我在 common_ui.xml 中遇到错误找不到渲染问题类:CardboardOverlayView.java".但是文件在那里,这是一个已知和报告的错误.
- 我能想到的另一种方法是每秒捕获并保存图像,并使用图像更新 2 个图像视图.不过我是不确定这是否是正确的做法或如何去做.
我还检查了自过去 3 天以来堆栈溢出中可用的所有链接.最接近我的问题的是 Android 多摄像头预览 - 但它是不能完全解决我的问题.我还浏览了 Android - Camera 文档并了解了他们如何使用 cameraPreview 和 surfaceView.
I have also checked all the links that are available in stack overflow since last 3 days. The closest to my question was Android multuple camera preview - but it's not quite exactly solves my question. I have also gone through the Android - Camera documentation and learned about how they are using cameraPreview and surfaceView.
所以我的问题是我现在需要做什么才能看到 CameraPreview [或包含 CameraPreview 的 surfaceView] 而不是 Imageview,以便我可以在横向模式下像分屏一样提供实时摄像头馈送?
So my question is what do I need to do now to be able to see the CameraPreview [or the surfaceView that holds the CameraPreview] instead of the Imageview so that I cam provide live camera feed like a split screen in landscape mode?
我希望问题足够详细.如果您需要任何进一步的信息,尽管问.
I hope the question is detailed enough.Still if you need any further info, just ask.
推荐答案
基本上你需要将相机绘制成一个OpenGL纹理并显示纹理.
Basically you need to draw the camera into an OpenGL texture and show the texture.
我在这里写了两个版本,随意修改代码并添加拉取请求:https://github.com/Sveder/CardboardPassthrough
I wrote two versions of this here, feel free to modify the code and add pull requests: https://github.com/Sveder/CardboardPassthrough
这篇关于如何并排显示 2 个摄像头预览?[对于纸板应用程序]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!