5

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,

Rakesh
  • 199
  • 1
  • 12
  • See *[Using both front and back cameras simultaneously android](https://stackoverflow.com/questions/11419940/using-both-front-and-back-cameras-simultaneously-android)* and *[Using both cameras on android: “Fail to connect to camera service”](https://stackoverflow.com/questions/7215230/using-both-cameras-on-android-fail-to-connect-to-camera-service)*. The bottom line is, this works on some devices that have dual ISP (hardware restriction) and permit such usage in software (e.g. Samsung phones block this for 3rd party apps). – Alex Cohn Feb 04 '19 at 20:13
  • Hi @alex, Thanks for reply, 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 i think it may be valid for other phones but for my case i think i am missing something, till now from google search it looks like there is some problem with session creation for second camera, i debuged my code, during creation of second camera session it fails so if you have any idea about that, please share. Thanks – Rakesh Feb 16 '19 at 05:59
  • Hi Rakesh, from your update its clear that the device is capable of capturing both pictures. This means that somewhere your code must be fixed. Dealing correctly with the two simultaneous pipelines requires careful coding, and as Eddy mentioned in his answer, not all camera resolutions and modes may be used this way. Note that the system will not record the two streams in one video for you, you must programmatically stitch the two frames together. And these frames will not be available at the same moment. – Alex Cohn Feb 16 '19 at 10:04
  • Did you get any solution for this? – Huzaifa Asif Nov 21 '19 at 06:38

1 Answers1

6

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.

Eddy Talvala
  • 17,243
  • 2
  • 42
  • 47
  • Hi Eddy, Thanks for reply, 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 i think it may be valid for other phones but for my case i think i am missing something, till now from google search it looks like there is some problem with session creation for second camera, i debuged my code, during creation of second camera session it fails so if you have any idea about that, please share. Thanks – Rakesh Feb 16 '19 at 05:56
  • Hi Eddy, i saw your reply upon this post "https://stackoverflow.com/questions/46347452/camera2-api-can-it-output-two-cameras-into-same-surface" you mentioned about failure upon session creation of second device if i am using same texture view, but i am using different texture views even then i am getting session creation failure for second camera, so please provide some hint or code link which can help. – Rakesh Feb 16 '19 at 17:42