[英]How to check light intensity using iPhone camera
Is there any way to check the light intensity using iPhone? 有没有办法用iPhone检查光强度? Does API allows to do this? API是否允许这样做?
I suppose you can easily do this yourself: 我想你可以自己轻松做到这一点:
UIImage
. 拿一个静止=> UIImage
。 UIImage
to a CGImageRef
( UIImage.CGImage
). 将UIImage
转换为CGImageRef
( UIImage.CGImage
)。 x += (red + green + blue) / 3.f;
现在,读取每个像素的颜色并执行以下代码: x += (red + green + blue) / 3.f;
avg = x / numberOfPixels;
计算平均亮度: avg = x / numberOfPixels;
. 。 avg
will now give you a float indicating the average brightness of the still. avg
现在会给你一个浮动,指示静止的平均亮度。 Most of the time (if not always), this will be identical to the light intensity. 大多数时候(如果不总是),这将与光强度相同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.