Android - Utilise both front and back cameras in app - android

I have searched quite a bit about whether or not it is possible to utilise both front and back cameras simultaneously in app. I found threads from several years ago saying it is possible on certain devices and on all Samsung phones after something like the S4. However that feature is locked to Samsung developed applications only. I then looked into whether or not it is possible to switch rapidly between the two cameras to achieve the same goal but apparently that would be extremely taxing on the hardware. I was wondering if anyone has some information about this in 2017 and if developing an application that is able to use both front and back cameras simultaneously is viable?

I know this is way late but here are two post I made on this to help anyone who runs into this:
https://stackoverflow.com/a/28811277/1138878
https://stackoverflow.com/a/43445052/1138878
Short answer: it's possible but depends on hardware/chipset (Snapdragon 801 and higher level hardware).
What it boils down to is that you need a Camera object for each camera which feeds a SurfaceView for each camera. Also make sure to check, in code, the capabilities (resolution and image format) and use one of the supported formats/sizes.

Related

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

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
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.

Capturing a photo from only one lens, in dual-camera phones?

Dual-camera smartphones are relatively new in the market, but I was wondering if a camera app could explicitly choose to use only one lens, or to manually retrieve separate input from each lens.
I couldn't find any Android API documentation that is specifically designed for dual-lens phones, so I guess this is a hardware/OS-level implementation that would be difficult to override or bypass.
Android's Camera HAL documentation page doesn't mention dual-lens devices as well, but it does seem to strengthen that assumption.
I don't have much experience with iOS, but I guess it wouldn't be easier.
So the question is - how, if at all, would such task be possible on either Android or iOS?
Edit: seems that in iOS it is possible, as explained here (thanks to the4kman for pointing this out in the comments). So I guess the question remains for Android only.
Different vendors provide dual cameras for their Android devices in hope to improve the photo quality for average user, more often than not, specifically tuned for special conditions like challenging illumination or distortions of selfie mode. Each vendor uses proprietary technologies to handle dual cameras, and they are not interested to disclose the implementation details. The only public interface they support is a virtual single camera which is more or less compliant with Google specs.
This does not mean that you cannot be lucky chance be able to unlock the camera for some specific device. Playing with photo modes, or scenes, or other parameters, may accidentally give you a picture that only passed one lens of the dual setup.
In some rare cases some documentation is actually present. E.g. HTC let you control stereo vs. mono setting for the circa'2011 Evo 3D device.
Another example: this review implies that for Huawei P9 and P10, you will actually get one-camera result if you choose monochrome mode.
A recent article gives some perspective how different are approaches to dual camera among different manufacturers.

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
!
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.
It is possible using the Android Camera2 API, but as indicated above most devices don't have hardware support. If you have a Nexus 5X, Nexus 6, or Nexus 6P it will work and you can test with this BothCameras app. I've implemented blitting to allow video recording as well (in addition to still pictures) using the hardware h264 encoder.
You can not access both the cameras in all android mobile phones due to hardware limitations. The best alternative can be using both the camera one by one. For that you can use single camera object and can change camera face to take another photo.
I have done this in one of my application.
https://play.google.com/store/apps/details?id=com.ushaapps.bothie
I've decided to mention that in some cases just opening two cameras with Camera2 API is not enough to know about support.
There are some devices which are not throwing error during opening. The second camera is opened correctly but the first one will call onCaptureFailed callback.
So the most accurate way is starting both cameras and wait frames from each of them and check there are no capture failure errors.

Android, Open Front and Back Cameras Simultaneously [duplicate]

This question already has answers here:
Using both front and back cameras simultaneously android
(3 answers)
Closed 5 years ago.
I am attempting to use 2 Surface Holder objects tied to 2 separate SurfaceViews.
I am for the one set doing a Camera.Open(0) for the back camera and Camera.Open(1) for the front.
I am able to get a perfect preview for whichever I call to open first, but am unable to open both Cameras at the same time, even though I am using separate SurfaceViews and SurfaceHolders for each Camera.
Is it just impossible to do this under Android ? I have seen a couple of post suggesting that it is either not possible, or that it is phone hardware dependent, but no concrete explanations as to why.
Could somebody explain why Android does not appear to support this ?
If it is supported, could someone suggest the correct way of opening both Cameras at the same time ?
I have also seen some suggestions that it should be possible to do using OpenCV. If so, could someone please provide a link to an example or similar ?
Thanks and Regards,
Steed.
It is possible because I've done it on my Nexus 6, even recording video from both cameras simultaneously when using Camera1 APIs. However, it is very much limited to a few devices.
Any unsupported device should give an error during the 2nd Camera.open() call. It seems each hardware manufacturer provides a different implementation of the Camera APIs. You could pretty easily try/catch the exception if a camera does not allow it.
This is possible on certain phones and pretty much all newer phones. I have found that devices which use the Snapdragon 801 and higher chipsets support this (OnePlus 1, HTC M8 etc). This was somewhere in 2014.
It all depends on the hardware/manufacturor and you should test this on real devices.
Also be aware that the first Camera API outputs in YUV so you will have to deal with this conversion to another format if you want to use the images/video; you can display it fine on a SurfaceView in realtime but saving to picture/video I suggest you save the YUV and convert later/on a seperate thread although you could save and convert single images in realtime on a seperate thread.
Sorry for the late answer but I hope you or someone else can use this info!

How to develop a Smart Magnifier using the mobile camera?

I would like to use the mobile camera and develop a smart magnifier that can zoom and freeze-frame what we are viewing, so we don't have to keep holding the device steady while we read. Also should be able to change colors as given in the image in the link below.
https://lh3.ggpht.com/XhSCrMXS7RCJH7AYlpn3xL5Z-6R7bqFL4hG5R3Q5xCLNAO0flY3Fka_xRKb68a2etmhL=h900-rw
Since i'm new to android i have no idea on how to start, do you have any idea?
Thanks in advance for your help :)
I've done something similar and published it here. I have to warn you though, this is not a task to start Android development with. Not because of development skills, the showstopper here is a need for massive amount of devices to test it on.
Basically, two reasons:
Camera API is quite complicated and the different HW devices behave differently. Forget about using emulator, you would need a bunch of real HW devices.
There is a new API, Camera2 for platform 21 and higher, and the old Camera API is deprecated (kind of 'in limbo' state).
I have posted some custom Camera code on GitHub here, to show some of the hurdles involved.
So the easiest way out in your situation would be to use camera intent approach, and when you get your picture back (it is a jpeg file) just decompress it and zoom-in to the center of the resulting bitmap.
Good Luck

Categories

Resources