2

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?

BryanH
  • 5,826
  • 3
  • 34
  • 47
Alexander Ho
  • 503
  • 2
  • 7
  • 18

3 Answers3

3

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

Eddy Talvala
  • 17,243
  • 2
  • 42
  • 47
2

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

Community
  • 1
  • 1
Orlymee
  • 2,349
  • 1
  • 22
  • 24
  • 1
    I made an edit to my answer, take a look at the source of those functions as this will give you an indication about light sensing. – Orlymee Jul 11 '12 at 09:47
2

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

Lam Do
  • 520
  • 4
  • 12