2

I want to use both front and back cameras at the same time. I have used two surface views. I have tried to implement the code in following answer.

https://stackoverflow.com/a/24238301/6874315

The problem is that the camera API is now deprecated and the code was too old. I tried using the Camera 2 API in the same way but the camera instance won't open and i get a blank white screen. I get the following two errors:

Camera 0 not available! java.lang.RuntimeException: Fail to connect to camera service

Camera 1 not available! java.lang.RuntimeException: Fail to connect to camera service

What i wanna do is capture picture from front and back camera simultaneously on a button click. But i'm not able to open both front and back cameras at the same time. Is there anything that I do to use both cameras at same time?

Huzaifa Asif
  • 658
  • 1
  • 8
  • 24
  • I've been looking for years, and I've yet to get my hands on a device that supports this. The Samsung Galaxy S4 can do it, but apparently only with an OEM app. – greeble31 Nov 21 '19 at 15:14
  • There must be someother way. I was thinking that if i could not get the camera preview from both front and back may be i could click a picture in a fraction of second for switching the camera. – Huzaifa Asif Nov 21 '19 at 15:42

2 Answers2

1

Take a look at these answers:

https://stackoverflow.com/a/30444841/11338123

https://stackoverflow.com/a/52075569/11338123

I think it is possible in some devices and it is impossible in others

Hadi Haidar
  • 337
  • 2
  • 13
0

I don't sure that it is possible to use both cameras simultaneously. But, you could switching between two cameras like in this sample for short time interval.

Also you can modify you program to process camera images in the background thread in such way to avoid GUI freezing.

So, you may try to make a little changes in the sample to get front and back camera instances for testing your idea. Good luck!

Egor Richman
  • 559
  • 3
  • 13
  • 1
    Well, there are some mobile phones capable of using both cameras. Maybe that is because they have separate hardware. But it is possible as I have seen it in Samsung Galaxy S4 – Huzaifa Asif Mar 31 '20 at 09:18