Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
611 views
in Technique[技术] by (71.8m points)

android - Access both back and front cameras simultaneously

What I'm trying to achieve: access both front and back cameras at the same time.

What I've researched: I know android camera API doesn't give support for using multiple instances of the Camera and you have to release a camera before using the other one. I've read tens of questions about this, I know on some devices it's possible (like Samsung S4, or other new devices from them). I've also found out that it's possible to have access to both of them in Android KitKat on SOME devices. I also know that on api >= 21, using the camera2 API, it's possible to access both of them at the same time because it's thread safe.

What I've got so far: implementation for accessing the cameras one at the time in order to provide a picture-in-picture.

I know it's not possible to implement dual simultaneously camera on every device, I just want a way to make it available to some devices.

How can I test to see if the device is capable of accessing both of them?

I've also searched for a library that can allow me such thing, but I didn't find anything. Is there such a library?

I would like to make this feature available for as many devices as possible, and for the others, I'll leave the current state (one by one) of the feature.

Can anyone please help me, at least with some pieces of advice?

Thanks !

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The Android camera APIs generally allow multiple cameras to be used at the same time, but most devices do not have enough hardware resources to support that in practice - for example, there's often only one camera image processor shared by both cameras.

There's no query that's included in the Android APIs that'll tell you up front if you can use multiple cameras at the same time.

The only way to tell is to try to open a second camera when you already have one open. If you can open the second camera, then you can do picture-in-picture, etc. If you get an exception trying to open the second camera, then that particular device doesn't support having both cameras open.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share

2.1m questions

2.1m answers

63 comments

56.6k users

...