Iphone 根据Exif数据计算照度
我如何通过iPhone摄像头计算勒克斯或照度。我计算了所有exif数据,如下所示:Iphone 根据Exif数据计算照度,iphone,objective-c,image-processing,camera,rgb,Iphone,Objective C,Image Processing,Camera,Rgb,我如何通过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 =
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
我也读过,并且知道勒克斯是由(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是光圈值或键值数据中的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);
UIImage*image=[UIImage-imagename:@“image.png”];
无符号字符*像素=[image rgbaPixels];
双总照度=0.0;
对于(int p=0;p你真的需要照度的绝对值吗?或者你可以不使用可以相互比较的相对值,例如已知的恒定比例因子值吗
如果是前一种情况,那么你就不走运了:exif数据中没有C,通过校准程序检索它需要有一个已知强度的光源,并且很可能在积分球中拍照
如果是后者,只需将表达式重写为Lux=C*(N*N/St),其中N==FNumber,t==ExposureTime,S==ISOSpeedRatings,set C==1(或任意值)这是我建议的代码:
(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);
}
谢谢你的回答。我计算你给出的公式,但它计算的是1和0之间的值。那么,计算照度的确切方法是什么,有没有其他方法来计算照度(以勒克斯为单位)…提前感谢我说过,除非你能从规格表中计算出仪表常数,否则唯一的方法就是校准它。到你需要一个积分球(),一个用于测量光源强度的校准仪表,以及一系列使用校准相机拍摄的照片。请告诉我我可以在iOS Sdk中应用的完整过程。为此,我将非常感谢你。iPhone上有许多应用程序可以计算照度(以勒克斯为单位)。