问题
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?
回答1:
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
回答2:
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).
回答3:
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
来源:https://stackoverflow.com/questions/11429614/android-camera-get-light-sensor-value