问题描述
我正在尝试使用2个绑定到2个单独SurfaceView的Surface Holder对象.我是一组用于后置摄像头的Camera.Open(0)和前部摄像头的Camera.Open(1).无论我先打开哪一个相机,我都能得到完美的预览,但是即使我为每个相机使用单独的SurfaceViews和SurfaceHolders,也无法同时打开两个相机.
I am attempting to use 2 Surface Holder objects tied to 2 separate SurfaceViews.I am for the one set doing a Camera.Open(0) for the back camera and Camera.Open(1) for the front.I am able to get a perfect preview for whichever I call to open first, but am unable to open both Cameras at the same time, even though I am using separate SurfaceViews and SurfaceHolders for each Camera.
在Android下是否不可能做到这一点?我看过几篇文章,暗示这是不可能的,或者它取决于电话硬件,但是没有具体的原因解释.
Is it just impossible to do this under Android ? I have seen a couple of post suggesting that it is either not possible, or that it is phone hardware dependent, but no concrete explanations as to why.
有人可以解释为什么Android似乎不支持此功能吗?如果支持,有人可以建议同时打开两个摄像头的正确方法吗?
Could somebody explain why Android does not appear to support this ?If it is supported, could someone suggest the correct way of opening both Cameras at the same time ?
我还看到了一些建议,建议可以使用OpenCV进行.如果是这样,有人可以提供示例或类似内容的链接吗?
I have also seen some suggestions that it should be possible to do using OpenCV. If so, could someone please provide a link to an example or similar ?
感谢和问候,
站起来.
推荐答案
这是可能的,因为我已经在Nexus 6上完成了此操作,甚至在使用Camera1 API时同时从两个摄像机录制视频.但是,它非常限于少数设备.
It is possible because I've done it on my Nexus 6, even recording video from both cameras simultaneously when using Camera1 APIs. However, it is very much limited to a few devices.
在第二次Camera.open()调用期间,任何不受支持的设备都应该给出错误.似乎每个硬件制造商都提供了不同的Camera API实现.如果相机不允许,您可以很容易地尝试/捕获异常.
Any unsupported device should give an error during the 2nd Camera.open() call. It seems each hardware manufacturer provides a different implementation of the Camera APIs. You could pretty easily try/catch the exception if a camera does not allow it.
这篇关于Android,同时打开前后摄像头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!