我知道如何使用android.hardware.sensor
.
我在市场上看到了测光表工具。应用程序描述说它可以从相机中获取勒克斯值。它怎么能做到这一点?
另外,如何设置快门速度和光圈?
android camera API 不为其捕获的图像数据提供任何绝对单位。此外,它不允许手动控制曝光或光圈(尽管基本上所有手机相机都没有可调光圈)。
您可以从 JPEG EXIF 中找出静态捕捉所用的曝光时间,仅此而已。
由于这些限制,您将很难从捕获的相机图像中获得绝对光测量值。您可能能够校准给定设备以将图像像素值转换为真实光照水平,但这会很复杂,因为所有设备都运行自动曝光和自动白平衡。使用 Android 4.0 中引入的自动曝光和自动白平衡锁定会有所帮助,但在勒克斯和捕获的像素值之间仍然存在未知的转换曲线(不仅仅是比例因子,它是伽马曲线)。
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.
同意,诀窍是拍照并读取其 EXIF 数据。您可以找到更多关于 ExifInterface 文档 http://developer.android.com/reference/android/media/ExifInterface.html
根据 iso 和光圈值,您可以计算 shuyy