小编use*_*903的帖子

来自iOS相机的亮度

我正在尝试制作一个应用程序,我必须像这个应用程序一样计算相机的亮度: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)

objective-c brightness ios luminance

1
推荐指数
1
解决办法
5139
查看次数

NSMutableDictionary和JSONRepresentation

我下载框架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)

我该如何解决?

谢谢

json frameworks ios

-1
推荐指数
1
解决办法
5049
查看次数

标签 统计

ios ×2

brightness ×1

frameworks ×1

json ×1

luminance ×1

objective-c ×1