detect if a picture was taken with the front camera - android

In my application, i want to take picture using built-in camera application. Taking picture process is working fine. I want to know is picture taken from front camera or back camera, because after taking picture i want to get the rotation angle and rotate the picture to that angle and store it in sdcard. ExifInterface always return the same angle(90) rather user take the picture from front/back camera. When user take the picture from back camera, rotation is fine but when user take the picture from front camera, picture rotation is wrong. Please suggest any solution for this problem.
Thanks

I believe that your device does something wrong with the rotation flag. You should try other devices, too.
Note that MediaStore.ACTION_IMAGE_CAPTURE may be fulfilled by different Camera apps on different devices, or even on the same device: the end user is free to choose. Some downloaded applications will respect an extra to choose the front camera (see https://stackoverflow.com/a/11159760/192373), other won't. Some will do a better job to provide correct EXIF, others will mess it up.

Related

Samsung front camera issue

I'm using
Intent(MediaStore.ACTION_IMAGE_CAPTURE)
to get a photo from the camera, it works fine on all devices, except for samsung devices where if you take photo with the frontal camera it appears rotated 180 degrees.
I can rotate the image 180 degrees to correct the issue with the frontal camera, but this causes the rear camera photos to be rotated as well.
Is there any way I can detect which camera is taking the picture, and therefore only rotate the frontal camera's images?
it works fine on all devices
No offense, but I rather doubt that. There are a lot of buggy camera apps. Bear in mind that some of those buggy camera apps are user-installed, not just pre-installed.
Is there any way I can detect which camera is taking the picture
Not really. I do not see an EXIF tag for that, and there is no requirement that the camera app put the tag in the image anyway. You are not told any details about the picture other than the picture itself. You could try playing some games, looking at the image resolution and comparing it with possible camera resolutions, but that will be unreliable.
In general, with ACTION_IMAGE_CAPTURE, you just wind up living with spotty results. Your primary alternative is to use a library to embed photo capture into your app (e.g., CameraKit-Android, Fotoapparat), trading off the unreliability of third-party camera apps with the unreliability of device manufacturer camera API support.

How to know which camera a photo was taken by on android?

I got a requirement to know which images were taken by the front camera and which were taken by the back camera on android device, i tried with SQLiteEditor to read system images database, but there is no useful information about which camera the images were taken by, also i tried with Exif Viewer, and the only thing may help are the FNumber and ApertureValue, here is the data copy from my Nexus5, running the newest lollipop system.
all the photos taken by front camera
FNumber f/2.4 ApertureValue 2.52
all the photos taken by back camera
FNumber f/2.9 ApertureValue 3.07
This is a part of exif data of the photos on my phone, i don't have other device, i want to know what's the relationship between those two values with two cameras on android device ? Is that information is enough to know which camera a photo was taken by ?
Thanks in advance.

Hint user to flip device when taking a Picture

In a part of an app I'm building the user should take an image / pick one from the gallery. The thing is, the image must be oriented horizontally. I would like to show the user a hint on-screen to flip his device if he is holding it in portarit, like google is doing in their new camera app (only in video mode, though)
Is it possible to do this without creating my own camera activity? I'm currently using ACTION_IMAGE_CAPTURE intent to open the default camera.
Eventually, I've built my own camera application which detects rotation and hints the user to rotate the device if it's in portrait mode.

capture photo from both front and back camera simultaneously

I would like to develop an Android application which has the technique of capturing a photo from camera(both front and back) at simultaneously.I searched over internet but unfortunately I couldn't find any better solution.
note for example if I capture the photo from back camera,once it captured from back means then it has to start front camera automatically for capture a photo.
You need to approach this problem step by step.
First build functionality to take picture by back camera.
Once you have done that, then build functionality to take picture by front camera (most of the code will be the same, just setting the back/font camera will be different.
Once you have these two options built, separately, then you can combine the two by making it a three-step process: 1) take picture by back camera 2) switch the camera to front 3) take picture by front camera.
Again, as mentioned, taking picture by back and front cameras are not different, it only involves switching the cameras.
Edited after seeing new comment:
If you are using the built-in camera, that is using intents, then this task is not going to be an automatic and immediate thing. I thought you were building custom camera, where you can do all this by code (without intents and built-in camera). But anyways, you can still do it.
So now, the process will be:
Use intent to go to Camera.
Take a picture (which is by default back camera). Do whatever you
want to do with this picture, save, process, etc.
Use another intent to go to Camera again. This time, add an extra to your intent to so the camera defaults to front camera intent.putExtra("android.intent.extras.CAMERA_FACING", 1);
Take picture again.
Refer to this thread for how to launch front camera with intent:
How to launch front camera with intent?

Front camera capture while the screen is blank

I wish to use the front camera of a device to capture the image without any preview and the screen to remain blank.
I have a way to remotely activate this but not sure how to do it.
I found this: https://stackoverflow.com/questions/10702906/showing-blank-screen-while-recording-video-in-motorola-attrix-2-with-android-2-2.
It is pretty close to what I want but I'm not sure how to use the code and change it to camera.

Categories

Resources