同时使用前后摄像头android
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11419940/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using both front and back cameras simultaneously android
提问by axs
I know this question has been asked many times before. I had looked for it over a year ago but didn't find anything so posting this question again to gather if there are any new thoughts/ approaches or hacks.
我知道这个问题之前已经被问过很多次了。一年多前我曾寻找过它,但没有找到任何东西,所以再次发布这个问题以收集是否有任何新的想法/方法或黑客。
I want to be able to capture video from both cameras (front and back) in an android device.
我希望能够从 Android 设备中的两个摄像头(正面和背面)捕获视频。
My only thought as of now is to some how switch between front and back every 0.1 sec, however I have never been able to code this. Any help from anyone on this, please.
我现在唯一的想法是每 0.1 秒在正面和背面之间切换一次,但是我从未能够对此进行编码。请任何人对此提供帮助。
Also another thought is - videos are generally captured at 15 or 30 frames per second. Assume it is at 30 frames per second. What if there is a way to alternate these frames to front and back, then we could have 15 frames per second of front and 15 frames per second of back video. Is this possible? If yes then how? Please suggest. What happens to the audio? Maybe we could restrict audio to only one of the video recordings (front or back).
另一个想法是 - 视频通常以每秒 15 或 30 帧的速度捕获。假设它是每秒 30 帧。如果有一种方法可以将这些帧前后交替,那么我们可以拥有每秒 15 帧的正面视频和每秒 15 帧的背面视频。这可能吗?如果是,那么如何?请建议。音频会发生什么?也许我们可以将音频限制为仅录制其中一个视频(正面或背面)。
回答by MacD
It's possible on the HTC m8, the OnePlusOne and the Motorola Nexus 6, as far as I have tested. Many more phones might support it, but you just have to test on the phones and see if the app crashes or not.
据我测试,它可以在 HTC m8、OnePlusOne 和摩托罗拉 Nexus 6 上运行。更多的手机可能支持它,但您只需要在手机上进行测试,看看应用程序是否崩溃。
You create a camera object for each available camera and have each attach to the preview callback.
您为每个可用的相机创建一个相机对象,并将每个对象附加到预览回调。
-edit- So far I've found that this works on Snapdragon 801 based phones. Dunno if all of them do it or what other SOCs support it, but that's what I've found so far.
-edit- 到目前为止,我发现这适用于基于 Snapdragon 801 的手机。不知道他们是否都这样做或其他 SOC 支持它,但这是我迄今为止发现的。
回答by Alastair
It ispossible but so far, only with the upcoming Samsung Galaxy S4.
这是可能的,但到目前为止,只有即将推出的三星 Galaxy S4。
It has a dual-camera featurebut who knows whether it's hardware-dependant or a software-modification by Samsung, at this stage.
它具有双摄像头功能,但在现阶段,谁知道它是依赖于硬件还是由三星进行软件修改。
Hopefully it can be ported to other phones, if it's just software.
希望它可以移植到其他手机,如果它只是软件。
回答by LuxuryMode
You can't use both simultaneously and switching between each camera every 0.1 seconds is not going to work well. Acquiring and releasing the camera object is pretty expensive and this just isn't going to pan out well.
您不能同时使用两者,并且每 0.1 秒在每个摄像头之间切换是不会工作的。获取和释放相机对象非常昂贵,而且这不会很好。