如何在Android camera2 API中同时配置前后两个摄像头? [英] How to configure front and back both cameras simultaneously in Android camera2 API?

查看:150
本文介绍了如何在Android camera2 API中同时配置前后两个摄像头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将前置和后置两个摄像头配置为Android camera2 API,以同时从两个摄像头拍摄照片和视频,我创建了2个纹理视图,每次打开一个摄像头(前后)时,我的代码都可以正常工作很好,但是每当我尝试同时打开两个摄像机时,代码在创建会话时就中断了,我得到了暗中的cameraAccessException:configure stream:方法.我想将前后摄像头捕获的图像都保存为一个图像,将视频都保存为一个视频.伙计们,如果您可以放置​​一些示例代码或示例链接,将会非常有帮助.

I want to configure front and back both cameras into Android camera2 API, to take pictures and videos from both cameras simultaneously, I have created 2 texture views , when ever I am opening one camera (front or back) my code is working fine but whenever I am trying to open both cameras simultaneously , code is breaking upon creating session, I am getting cameraAccessException :configure stream : method not implimented. I want to save both front and back camera captured images as one image and both video as one video. Guys it will be very much helpful if you can put some sample code or some sample link.

我使用的是plus 6,我最近下载了一个应用程序双摄像头从后置摄像头",通过使用该程序,我可以同时从两个摄像头的前部和后部捕获图像,因此如果有人想提出建议没有硬件支持,我认为它可能对其他手机有效,但就我而言,我认为我在编码中缺少一些东西,直到现在从Google搜索中看来,第二个摄像头的会话创建存在一些问题,我调试了我的代码,在创建第二个摄影机会话期间,它会失败,因此,如果您对此有任何想法,请分享.

i am using one plus 6, i recently downloaded an app "Dual camera fron back Camera", by using this i am able to capture image from front and back both camera on the same time, so if somebody want to suggest for no hardware support, i think it may be valid for other phones but for my case i think i am missing something in coding, till now from google search it looks like there is some problem with session creation for second camera, i debugged my code, during creation of second camera session it fails so if you have any idea about that, please share.

谢谢拉克什

推荐答案

相机API很好用,但是大多数Android设备没有足够的硬件资源来一次运行两个相机,因此尝试时通常会出现错误打开第二台相机.

The camera API is fine with it, but most Android devices do not have sufficient hardware resources to run both cameras at once, so you will generally get an error trying to open the second camera.

两个图像传感器通常都连接到同一图像信号处理器(ISP),并且该ISP一次只能操作一台摄像机.某些高端设备的ISP具有多个处理管道,理论上一次可以运行多个摄像机,但是它们通常需要使用多个管道来处理高级功能或主(后置)照相机的高分辨率.因此,在这些设备上,一次可以使用多个摄像头,但不能以最大分辨率或其他类似限制使用.

Both image sensors are typically connected to the same image signal processor (ISP), and that ISP can only operate one camera at a time. Some high-end devices have ISPs with multiple processing pipelines which can in theory run more than one camera at a time, but they often require using multiple pipelines to handle advanced functionality or very high resolutions for the main (back) camera. So on those devices, multiple cameras may be usable at once, but not at maximum resolution or other similar restrictions.

一些制造商在自己的相机应用程序中包含多相机功能,因为他们确切地知道了限制,并可以编写应用程序代码以在其中使用.由于担心性能,散热限制,或者只是缺乏时间来验证比其在自己的应用中实现的确切用例还要多的时间,因此他们可能无法将多台摄像机提供给普通应用.

Some manufacturers include multi-camera features in their own camera app, since they know exactly what the limitations are and can write application code to work within them. They may not make multi-camera available to normal apps, due to concerns about performance, thermal limits, or just lack of time to verify more than the exact use case they implement in their own app.

Android相机API当前尚无法查询是否可以一次使用多个相机,或者可以使用多个限制.因此,您唯一可以做的就是尝试,并在不可行的情况下处理错误.

The Android camera API does not currently have a way to query if multiple cameras can be used at once, or if they can be, what the restrictions are. So the only thing you can do is try, and handle the errors in case that isn't feasible.

这篇关于如何在Android camera2 API中同时配置前后两个摄像头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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