Android configuration for camera "front" vs 'rear" - android

I have an HTC One M8, and I have flashed cyanogen to it.
I am using it for testing some cameras that attach via the micro USB port.
When testing applications they seem to have a preference for front or rear, not a camera list, and assuming that different device models have different camera models, features, etc, I can only assume android provides some abstraction level between direct accessing the camera and the application. Furthermore is seems safe to assume that somewhere that is configured as front or rear respectively.
So the question is can that be edited, for instance a device has an internal camera that does not have the feature or resolution I need, can I plug one into the USB port, and change a configuration somewhere that says "when an application requests the rear camera, give it this one?"
Essentially can you edit somewhere what CAMERA_FACING_FRONT and CAMERA_FACING_BACK refers to on a hardware level?
I have looked and not be able to find much, and I do not compile my own android ROMS, so I am afraid it may end up being one of the reason ROMs are device specific because this is compiled into the OS and coded specifically for the camera native to that device, therefor not configurable, however if someone could nudge me in the correct direction that would be great.
Example, http://developer.android.com/training/camera/cameradirect.html states a call to open() on the Camera object returns the first rear facing camera. Something somewhere has instructed android what that camera is and that it is facing rear. It is specifically that configuration point I want to see if I can pick up and redirect. an example of why, I have an application that given the known size of something in the field of the camera, it can accurately measure distance to that object, it only does it through the rear camera, I want to try to make it do it through the thermal camera.
The third camera works fine on the device, and its native app consistently finds it (albeit not sure how or if it is a specific protocol over USB, driver, etc...)

It appears the setting I am looking for is defined in the HAL https://source.android.com/devices/camera/index.html#implementing
camera_common.h defines an important struct, camera_module, which
defines a standard structure to obtain general information about the
camera, such as its ID and properties that are common to all cameras
such as whether or not it is a front or back-facing camera.
Since this is modified in the header file and compiled into the kernel, then without hacking the ROM it would appear it is simply NOT configurable at any level outside a custom ROM.
Id est, I will never force another app into the camera of my choosing unless I choose to build a ROM to do it or without overly invasive hacking at the running ROM :-(

Related

Can two apps use camera at the same time in android phone?

Or is it impossible no matter how you build or code apps?
I am saying in android version 5.0
Which was released 2014-2016.
I mean if when one app is using camera in “background” , is using another camera app at the same time possible??
Some people say it depends on how the applications is coded.
Also the app “sound assistant” makes 2 music apps using speaker at the same time.
Then how about camera???
And i saw a comment saying
“Our current frame work does support limited support for multi-app access to the camera.
We allow one (and only one) "controlling" app to the camera, but an arbitrary number of "shared" apps to access the same camera.
There are some limitations for "shared" apps:
No camera controls Exposure/White
Balance/Focus, etc...).
No media type selection (can't choose VGA vs.
720p vS. 1080p, etc...).
Only access to a video stream by default, photo pins are blocked (any photo operation will use a video frame instead).
The "controlling" app decides what media type to use and can set any camera control. Any of the sharing app can register to be notified if a controlling app releases control of the camera, at which point, the sharing app can re-open the camera in controlling mode.
The mechanism described above does not require any copying of the captured frame so the overhead is minimal.”
What this comment means? does it say 2apps can access to camera at the sametime anyway in android??
Any way thanks for reading and I want to know if the phone is rooted , this can be possible
thank you for reading !

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.

Wrong Camera Orientation with Android & Vuforia

We are developing our own Android-based hardware and we wish to use Vuforia (developed via Unity3D) for certain applications. However, we are having problems making Vuforia work well with our current camera orientation settings.
On our hardware, when the camera is placed horizontally - everything works fine. That is, when the camera is parallel to the placement of the display. However, we need to place the camera vertically, or in other words, with a 90 degree difference to the placement of the display. These are all hardware settings. Our kernel is programmed according to such settings and every other program that utilises the camera works compatibly with everything, including our IMU sensors. However, apps developed with Vuforia behave completely odd when the camera is placed vertically.
We assume the problem to be related to Vuforia's algorithms of processing raw camera data however we are not sure. Moreover, we do not know how to fix the situation. For further details, I can list:
-When "Enable Video Background" is on, the projected image is distorted and no video feed is available. The AR projection appears on a black background with distorted dimensions.
-When "Enable Video Background" is on and the device is rotated, the black background is replaced by flickering solid colors.
-When "Enable Video Background" is off, the AR projection has normal dimensions (no distortion) however it is tracked with wrong axis settings. For example, when the target moves left in real world, the projection moves up.
-When "Enable Video Background" is off and the device is rotated, the AR projection is larger compared to its appearance when the device is in it's default state.
I will be glad to provide any more information you need.
Thank you very much, have a nice day.
PS: We have found out that applications that use the camera as a main purpose (Camera apps, Barcode Scanners, etc) work fine while apps for which camera usage is an extra quality (such as some games) have the same problem as Vuforia. This make me think that apps who access the camera directly work fine whereas those who use Android API and classes fail for some reason.
First understand that every platform deals with cameras differently and that beyond this different android phone manufacturers deal with these differently as well. In my testing WITHOUT vuforia I had to transform the plane I cast the video feed onto 0,-90,90 for android/iphone and -270,-90,90 for the windows surface tablet. Past this the iPhone rear camera was mirrored, the android front camera was mirrored as well as the surface front camera. That is easy to account for, but an annoying issue is that the Google Pixel and Samsung front cameras were mirrored across the y (as were ALL iOS on the back camera), but the Nexus 6p was mirrored across the x. What I am getting at here is that there are a LOT of devices to account for with android so try more than just that one device. Vuforia so far has dealt with my pixel and 4 of my iOS devices just fine.
As for how to fix your problem:
Go into your player settings for unity and look at the orientation. There are a few options here and my application only uses portrait so I force portrait and it seems to work fine (none of the problems I had to account for with the above mentioned scenario). Vuforia previously did NOT support auto rotation so you need to make sure you have the latest version since it sounds like that is what you need. If the auto rotate is set and it is not working right you may have to account for that specific device (don't do this for all devices until after you test those devices). To account for that device use an if (or construct a case statement if you have multiple instances of this problem with different devices) and then reflect or translate as needed. Cross platform development systems (like unity) doesn't always get everything perfect since there is basically no standard. In these cases you have to directly account for them by creating a method and a case statement within that so you can cleanly and modularly manipulate all necessary devices. It is a pain, but it beats developing for all devices separately.
One more thing is make sure you check out the vuforia configuration file as it has some settings such as camera mirror and direction settings on there. These seem to be public settings so you should also be able to script to these in your case statement in the event you need to use "Flip Horizontally" for one phone, but not another.

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.

Categories

Resources