android camera get light sensor value - android

I know how to get a lux value from the light sensor using android.hardware.sensor.
I saw light meter tools on the market. The application description said it can get the lux value from the camera. How can it do that?
Also how can I set the shutter speed and the aperture?

The android camera API doesn't provide any absolute units for the image data it captures. In addition, it does not allow for manual control of exposure or aperture (although essentially all cell phone cameras have no adjustable aperture anyway).
You can find out what exposure time used for a still capture from the JPEG EXIF, but that's about it.
Because of those limitations, you'll have a hard time getting an absolute light measurement from a captured camera image. You may be able to calibrate a given device to convert from image pixel value to true light level, but it'll be complicated since all devices run auto-exposure and auto-white-balance. Using auto-exposure and auto-white-balance locks introduced in Android 4.0 will help a bit, but there's still an unknown conversion curve between lux and a captured pixel value (not just a scale factor, it's a gamma curve).

Take a look at the Camera.Parameters class.
It has all functions supported by the Camera. Probably setExposureCompensation.
I don't know much about photography but my guess would be that exposure compensation is changing aperture or speed.
It could be that the tool you mentioned is using a bundled native library. Also have a look at how the functions given in Camera.Parameters class work (check android source code).
you can also use Ambient light sensor to get the light level in lux units (if this is within the scope of your project). From android documentation:
Sensor.TYPE_LIGHT:
values[0]: Ambient light level in SI lux units
Android Developer: Light Sensor-Sensor Event
You can find more information about the light sensor in the documentation.
Android Developer: Sensor

Agree, the trick is taking the picture and read its EXIF data.
You can find more about ExifInterface docs
http://developer.android.com/reference/android/media/ExifInterface.html
Depending iso and aperture values, then you can calculate the shuyy

Related

Camera Sensor partially parsed/processed to improve framerate

I'm working on a project which ultimately uses an app to recognize spoken words via face recognition and gives feedback how good your pronunciation was.
I would like to know if there is a way to only partially get the data from the camera sensor (ROI) so not all pixels have to be parsed and processed to possibly improve framerates and lower the datastream.
I'm fairly new to android app dev, so I don't know if there is a way to call the sensor on this level or if such intervention on hardware specific elements can't be handeled by software methods.
So I would appreciate if there is anyone who could tell me if there is a way. Researching android docu didn't get me any results so far.
Thanks in advance and regards from Germany
Generally speaking, this isn't supported.
While the camera API allows for setting a level of digital zoom (for the deprecated android.hardware.Camera API) or an explicit crop region (on the current android.hardware.camera2 API), there's no guarantee that frame rate will increase when you select a smaller region.
This is because digital zoom is expected to be variable per-frame, and image sensors can generally not reconfigure their readout region that quickly. So digital zoom / crop is implemented in the camera image processing pipeline instead, and the sensor always reads out the full frame.
Some lower-resolution output configurations may set the sensor to skipping/binning modes, which does increase the maximum frame rate by reducing the number of pixels read off the sensor, but you indicate you need full resolution on a small ROI, so this doesn't help you.

Android minimum exposure compensation

In android camera i am able to set the exposure compensation and lock the camera to minimum using the given methods
params = mCamera.getParameters();
params.setExposureCompensation(params.getMinExposureCompensation());
params.setAutoExposureLock(true);
but still this is not the minimum exposure. In the program i do it by pointing the camera to a bright light source and then lock the camera exposure on click of a button. This is however not a good method. Is there any other way to reduce the exposure to absolute minimum?
Latest update : Ios 8 supports better minimum exposure compensation
Both S5 and Nexus S use Qualcomm Snapdragon. You can find the code of its HAL in AOSP. You can modify this code to allow lower manual exposure levels. You don't even need to make changes on kernel level.
No, there is no easier way to do it - neither in Java nor using NDK.
I guess that using a torch the way you described it may be automated (let SW decide when to lock exposure, instead of a button), and will work for a wider range of devices, and don't need replacing system libraries.

Get the Android camera Aperture and Exposure Time

Is there any API instruction or calculation to obtain the android camera Aperture F value, and the Exposure Time?
The Camera API exposes methods to get the White Balance, the Focal Length, etc, but I couldn't find anything related to the Aperture and the Exposure Time.
Thanks
In the Android Developer's Guide for ExifInterface, which is a class in the android.media API (not, the now deprecated Camera API), there is information for Aperture and Exposure Time
Sample code showing how it could be used is available at ExifHelper

How to adjust amplitude of flash light on android mobile?

I am using Note 3 (rooted) and I used Adjustable Torch [ROOT] - Android Apps on Google Play to adjust lighting power of flash light. Can you help me answer some below questions:
How to know value of brightness of flash on default camera (some
people said that I can find it in file on android system folder, but
I cannot find)
When I use Adjustable Torch to change value of flash, how to know value of brightness.
My purpose is to compare 2 values and find the suitable value of brightness (lower is better) to calculate heart rate using camera.
Thank you!

Get camera's intrinsic orientation in API <9

In API level 9, Android added the CameraInfo class, which includes information on each physical camera in the device. In particular, it includes an orientation attribute, which is "the angle that the camera image needs to be rotated clockwise so it shows correctly on the display in its natural orientation." This is distinct from the actual rotation of the device, which is found from getContext().getWindowManager().getDefaultDisplay().getRotation().
Android's sample code subtracts the rotation of the device from the orientation of the camera for rear-facing cameras (it's slightly more complicated for front-facing ones), and rotates the camera preview by this amount. This allows the preview to display properly in both portrait and landscape orientations of the screen.
How can I get the intrinsic orientation of the camera in API levels less than 9, where there is no CameraInfo class?
There is some platform specific solutions. But there is no easy general solution.
Android has a Hardware Abstract Layer(HAL), different vendors will implement the HAL differently. For example, different camera device may have different drivers, so they have different ways to get their data out, including your cameraInfo. When Android adds an API into the HAL, it requires its vendors to implement that API based on their hardwares. Then the Android framework and Android application can use that feature in a uniform way.
However, as you said, the getCameraInfo is not in the HAL Before Froyo. So a straightforward approach would be get those info from the driver or platform-specific library yourself.
For MSM Camera, there is a mm_camera_get_camera_info function in liboemcamera.so. You can use it to get a list of camera_info_t structs.
typedef struct {
int modes_supported;
int8_t camera_id;
cam_position_t position;
uint32_t sensor_mount_angle;
}camera_info_t;
The function encapsulates the actual system call to the target camera device. ioctl(controlfd, MSM_CAM_IOCTL_GET_CAMERA_INFO, &cameraInfo). You may directly call it if you like.
So unfortunately, you need to get that info based on the device you are working on. But may be you are expecting a general approach. Then I think the only way to achieve this is to implement the HAL yourself. Many if-else to decide which device or which ioctl command you need to use. Good luck man.

Categories

Resources