5

我如何通过 iPhone 相机计算勒克斯或照度。我计算了所有的 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 是来自 Key Value Data 的 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

提前致谢。任何帮助将不胜感激。

4

2 回答 2

2

你真的需要照度的绝对值吗?或者你能摆脱可以相互比较的相对值,例如已知值达到恒定比例因子?

如果前者你不走运:exif 数据中没有 C,并且使用校准程序检索它需要具有已知强度的光源,并且可能在积分球中拍照。

如果是后者,只需将表达式重写为 Lux = C * (N*N /St),其中 N == FNumber,t == ExposureTime,S == ISOSpeedRatings,设置 C == 1(或任意值)

于 2012-12-14T18:09:08.370 回答
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);
}
于 2018-08-17T11:24:28.407 回答