Simultaneous access to rear and front cameras

What I'm trying to achieve: simultaneously access front and rear cameras.

What I researched: I know that the Android camera API does not support using multiple instances of the camera, and you need to free the camera before using another. I read dozens of questions about this, I know on some devices it is possible (for example, Samsung S4 or other new devices from them). I also found out that they have access to both of them in Android KitKat on some devices. I also know that on api> = 21, using the camera2 API, you can access both of them at the same time, since it is thread safe.

What I have so far: implementation for accessing cameras one at a time to provide image in picture.

I know that it is impossible to implement a dual camera simultaneously on each device, I just want to make it available for some devices.

How can I check if a device can access both of them?

I was also looking for a library that could allow me such a thing, but I did not find anything. Is there such a library?

I would like to make this function available for as many devices as possible, and for the rest I will leave the current state (one by one) of this function.

Can someone help me with at least some tips?

thanks

+8
android camera
source share
3 answers

The APIs for Android cameras usually allow you to use multiple cameras at the same time, but most devices do not have enough hardware resources to support this in practice - for example, for both cameras, only one camera image processor is often used.

There are no requests in the Android API that will tell you if you can use multiple cameras at the same time.

The only way to tell is to try to open the second camera when you already have one open. If you can open the second camera, then you can take pictures in a picture, etc. If you get an exception trying to open a second camera, then this particular device does not support opening both cameras.

+10
source share

You cannot access cameras in all Android mobile phones due to hardware limitations. The best alternative can be used as a camera one after another. To do this, you can use the object with one camera and change the face of the camera to take another photo.

I did this in one of my applications. https://play.google.com/store/apps/details?id=com.ushaapps.bothie

0
source share

It is possible to use the Android Camera2 API, but, as indicated above, most devices do not have hardware support. If you have a Nexus 5X, Nexus 6 or Nexus 6P, it will work, and you can test BothCameras with this app . I implemented blitting to allow video recording (in addition to still images) using a hardware h264 encoder.

0
source share

All Articles