简体   繁体   English

Android相机获取光传感器值

[英]android camera get light sensor value

I know how to get a lux value from the light sensor using android.hardware.sensor . 我知道如何使用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. android camera API不会为其捕获的图像数据提供任何绝对单位。 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. 您可以从JPEG EXIF中找出拍摄静止图像所用的曝光时间,仅此而已。

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). 使用Android 4.0中引入的自动曝光和自动白平衡锁定会有所帮助,但勒克斯和捕获的像素值之间仍然存在未知的转换曲线(不仅仅是比例系数,它是伽玛曲线)。

Take a look at the Camera.Parameters class. 看一下Camera.Parameters类。

It has all functions supported by the Camera. 它具有相机支持的所有功能。 Probably setExposureCompensation . 可能是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). 还可以看看Camera.Parameters类中给定的功能如何工作(请查看android源代码)。

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: 来自android文档:

Sensor.TYPE_LIGHT: Sensor.TYPE_LIGHT:

values[0]: Ambient light level in SI lux units 值[0]:环境照度,以SI lux为单位

Android Developer: Light Sensor-Sensor Event Android开发人员:光传感器事件

You can find more information about the light sensor in the documentation. 您可以在文档中找到有关光传感器的更多信息。

Android Developer: Sensor Android开发人员:传感器

Agree, the trick is taking the picture and read its EXIF data. 同意,诀窍是拍照并读取其EXIF数据。 You can find more about ExifInterface docs http://developer.android.com/reference/android/media/ExifInterface.html 您可以找到有关ExifInterface文档的更多信息http://developer.android.com/reference/android/media/ExifInterface.html

Depending iso and aperture values, then you can calculate the shuyy 根据iso和光圈值,您可以计算出shuyy

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM