我正在尝试制作一个应用程序,我必须像这个应用程序一样计算相机的亮度:http://itunes.apple.com/us/app/megaman-luxmeter/id455660266?mt = 8
我找到了这个文件:http://b2cloud.com.au/tutorial/obtaining-luminosity-from-an-ios-camera
但我不知道如何直接适应相机,而不是图像.这是我的代码:
Image = [[UIImagePickerController alloc] init];
Image.delegate = self;
Image.sourceType = UIImagePickerControllerCameraCaptureModeVideo;
Image.showsCameraControls = NO;
[Image setWantsFullScreenLayout:YES];
Image.view.bounds = CGRectMake (0, 0, 320, 480);
[self.view addSubview:Image.view];
NSArray* dayArray = [NSArray arrayWithObjects:Image,nil];
for(NSString* day in dayArray)
{
for(int i=1;i<=2;i++)
{
UIImage* image = [UIImage imageNamed:[NSString stringWithFormat:@"%@%d.png",day,i]];
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 …Run Code Online (Sandbox Code Playgroud) 我下载框架JSON,添加到我的项目,我认为它是正确添加因为我放
#import <JSON/JSON.h>
Run Code Online (Sandbox Code Playgroud)
我没有任何警告.但是,当我想使用它时,问题就开始了:
NSMutableDictionary * attachement = [NSMutableDictionary dictionary];
NSString *requestJson = [attachement JSONRepresentation];
Run Code Online (Sandbox Code Playgroud)
但我对JSONRepresentation有一个警告:
Instance method '-JSONRepresentation' not found (return type defaults to 'id')
Run Code Online (Sandbox Code Playgroud)
我该如何解决?
谢谢