我如何通过iPhone Camera计算勒克斯或照度。我已经计算了所有exif数据,如:
key = FocalLength, value = 3.85
key = MeteringMode, value = 5
key = ShutterSpeedValue, value = 4.591759434012097
key = ExposureProgram, value = 2
key = FocalLenIn35mmFilm, value = 32
key = SceneType, value = 1
key = FNumber, value = 2.4
key = PixelXDimension, value = 480
key = ExposureTime, value = 0.04166666666666666
key = BrightnessValue, value = -0.2005493394308445
key = ApertureValue, value = 2.526068811667588
key = Flash, value = 32
key = ExposureMode, value = 0
key = PixelYDimension, value = 360
key = SensingMethod, value = 2
key = ISOSpeedRatings, value = (
1250
)
key = WhiteBalance, value = 0
我也阅读了http://en.wikipedia.org/wiki/Light_meter,并且知道Lux的计算方法是 (N*N*C)/tS
Where N is the relative aperture (f-number)
t is the exposure time (“shutter speed”) in seconds
S is the ISO arithmetic speed
C is the incident-light meter calibration constant
我不明白这个值是指什么。 N是键值数据的ApertureValue或FNumber,t是曝光时间或快门速度。什么是C(320-540或250)的值。 我将不同组合中的每个相似值应用于此公式但是得到了错误的结果,因为我与一些计算勒克斯值的应用程序进行比较。 我还需要根据照度来测量辐照度。
此外,我还计算了捕获图像的亮度:
UIImage* image = [UIImage imageNamed:@"image.png"];
unsigned char* pixels = [image rgbaPixels];
double totalLuminance = 0.0;
for(int p=0;p<image.size.width*image.size.height*4;p+=4) {
totalLuminance += pixels[p]*0.299 + pixels[p+1]*0.587 + pixels[p+2]*0.114;
}
totalLuminance /= (image.size.width*image.size.height);
totalLuminance /= 255.0;
NSLog(@"Image.png = %f",totalLuminance);
http://b2cloud.com.au/tutorial/obtaining-luminosity-from-an-ios-camera
在此先感谢。任何帮助将不胜感激。
答案 0 :(得分:2)
你真的需要照度的绝对值吗?或者你可以逃避可以相互比较的相对价值,例如已知的值达到一个恒定的比例因子?
如果前者运气不好:exif数据中没有C,并且使用校准程序检索它需要具有已知强度的光源,并且可能在积分球中拍照。
如果是后者,只需将表达式重写为Lux = C *(N * N / St),其中N == FNumber,t == ExposureTime,S == ISOSpeedRatings,设置C == 1(或任意值) )
答案 1 :(得分:0)
这是我建议的代码:
(void)imagePickerController:(UIImagePickerController *)anImagePickerController didFinishPickingMediaWithInfo:(NSDictionary *)info
{
//NSLog(@"%@",info);
NSDictionary *temp=[info objectForKey:@"UIImagePickerControllerMediaMetadata"];
NSDictionary *temp2=[temp objectForKey:@"{Exif}"];
float fnumber=[[temp2 objectForKey:@"FNumber"]floatValue];
float ExposureTime=[[temp2 objectForKey:@"ExposureTime"]floatValue];
NSArray *iosarray=[temp2 objectForKey:@"ISOSpeedRatings"];
float ISOSpeedRatings=[[iosarray objectAtIndex:0]floatValue];
int c=80;//you need to calibrate this value
float illuminanace=c*(fnumber*fnumber /(ISOSpeedRatings*ExposureTime));
//NSLog(@"fnumber=%f ",fnumber);
//NSLog(@"ExposureTime=%f ",ExposureTime);
//NSLog(@"iosarray=%@",iosarray);
//NSLog(@"ISOSpeedRatings=%f",ISOSpeedRatings);
NSLog(@"illiminace =%f lux",illuminanace);
}