Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure front and back both cameras simultaneously in Android camera2 API?

Tags:

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.

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.

Thanks Rakesh

 i am using one plus 6,

like image 855
rakesh kejriwal Avatar asked Feb 04 '19 02:02

rakesh kejriwal


People also ask

Can two apps use camera at the same time Android?

No. Access to a camera is exclusive. See the Camera documentation, which says: If your application does not properly release the camera, all subsequent attempts to access the camera, including those by your own application, will fail and may cause your or other applications to be shut down.


1 Answers

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.

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.

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.

like image 92
Eddy Talvala Avatar answered Oct 13 '22 19:10

Eddy Talvala