AVFoundation清晰度设置

Here is the a table of all tested camera sessionPreset`s on devices, that support iOS 9

    +-----------------------+--------------+---------------------------------+---------------+
    |        Device         |    Camera    |     AVCaptureSessionPreset      |  Resolution   |
    +-----------------------+--------------+---------------------------------+---------------+
    | iPhone 4S             | FRONT        |                                 |               |
    |                       |              | AVCaptureSessionPresetPhoto     | 640x480       |
    |                       |              | AVCaptureSessionPresetHigh      | 640x480       |
    |                       |              | AVCaptureSessionPresetMedium    | 480x360       |
    |                       |              | AVCaptureSessionPresetLow       | 192x144       |
    |                       |              | AVCaptureSessionPreset640x480   | 640x480       |
    |                       |              | AVCaptureSessionPreset1280x720  | not supported |
    |                       |              | AVCaptureSessionPreset1920x1080 | not supported |
    |                       | BACK         |                                 |               |
    |                       |              | AVCaptureSessionPresetPhoto     | 3264x2448     |
    |                       |              | AVCaptureSessionPresetHigh      | 1920x1080     |
    |                       |              | AVCaptureSessionPresetMedium    | 480x360       |
    |                       |              | AVCaptureSessionPresetLow       | 192x144       |
    |                       |              | AVCaptureSessionPreset640x480   | 640x480       |
    |                       |              | AVCaptureSessionPreset1280x720  | 1280x720      |
    |                       |              | AVCaptureSessionPreset1920x1080 | 1920x1080     |
    +-----------------------+--------------+---------------------------------+---------------+
    | iPhone 5/5C/5S/6/6+   |              |                                 |               |
    |                       | FRONT        |                                 |               |
    |                       |              | AVCaptureSessionPresetPhoto     | 1280x960      |
    |                       |              | AVCaptureSessionPresetHigh      | 1280x720      |
    |                       |              | AVCaptureSessionPresetMedium    | 480x360       |
    |                       |              | AVCaptureSessionPresetLow       | 192x144       |
    |                       |              | AVCaptureSessionPreset640x480   | 640x480       |
    |                       |              | AVCaptureSessionPreset1280x720  | 1280x720      |
    |                       |              | AVCaptureSessionPreset1920x1080 | not supported |
    |                       | BACK         |                                 |               |
    |                       |              | AVCaptureSessionPresetPhoto     | 3264x2448     |
    |                       |              | AVCaptureSessionPresetHigh      | 1920x1080     |
    |                       |              | AVCaptureSessionPresetMedium    | 480x360       |
    |                       |              | AVCaptureSessionPresetLow       | 192x144       |
    |                       |              | AVCaptureSessionPreset640x480   | 640x480       |
    |                       |              | AVCaptureSessionPreset1280x720  | 1280x720      |
    |                       |              | AVCaptureSessionPreset1920x1080 | 1920x1080     |
    +-----------------------+--------------+---------------------------------+---------------+
    | iPhone 6S/6S          |              |                                 |               |
    |                       | FRONT camera |                                 |               |
    |                       |              | AVCaptureSessionPresetPhoto     | 1280x960      |
    |                       |              | AVCaptureSessionPresetHigh      | 1280x720      |
    |                       |              | AVCaptureSessionPresetMedium    | 480x360       |
    |                       |              | AVCaptureSessionPresetLow       | 192x144       |
    |                       |              | AVCaptureSessionPreset640x480   | 640x480       |
    |                       |              | AVCaptureSessionPreset1280x720  | 1280x720      |
    |                       |              | AVCaptureSessionPreset1920x1080 | not supported |
    |                       | BACK camera  |                                 |               |
    |                       |              | AVCaptureSessionPresetPhoto     | 4032x3024     |
    |                       |              | AVCaptureSessionPresetHigh      | 1920x1080     |
    |                       |              | AVCaptureSessionPresetMedium    | 480x360       |
    |                       |              | AVCaptureSessionPresetLow       | 192x144       |
    |                       |              | AVCaptureSessionPreset640x480   | 640x480       |
    |                       |              | AVCaptureSessionPreset1280x720  | 1280x720      |
    |                       |              | AVCaptureSessionPreset1920x1080 | 1920x1080     |
    +-----------------------+--------------+---------------------------------+---------------+
    | iPad 2                |              |                                 |               |
    |                       | FRONT        |                                 |               |
    |                       |              | AVCaptureSessionPresetPhoto     | 640x480       |
    |                       |              | AVCaptureSessionPresetHigh      | 640x480       |
    |                       |              | AVCaptureSessionPresetMedium    | 480x360       |
    |                       |              | AVCaptureSessionPresetLow       | 192x144       |
    |                       |              | AVCaptureSessionPreset640x480   | 640x480       |
    |                       |              | AVCaptureSessionPreset1280x720  | not supported |
    |                       |              | AVCaptureSessionPreset1920x1080 | not supported |
    |                       | BACK         |                                 |               |
    |                       |              | AVCaptureSessionPresetPhoto     | 960x720       |
    |                       |              | AVCaptureSessionPresetHigh      | 1280x720      |
    |                       |              | AVCaptureSessionPresetMedium    | 480x360       |
    |                       |              | AVCaptureSessionPresetLow       | 192x144       |
    |                       |              | AVCaptureSessionPreset640x480   | 640x480       |
    |                       |              | AVCaptureSessionPreset1280x720  | 1280x720      |
    |                       |              | AVCaptureSessionPreset1920x1080 | not supported |
    +-----------------------+--------------+---------------------------------+---------------+
    | iPad 3                |              |                                 |               |
    |                       | FRONT        |                                 |               |
    |                       |              | AVCaptureSessionPresetPhoto     | 640x480       |
    |                       |              | AVCaptureSessionPresetHigh      | 640x480       |
    |                       |              | AVCaptureSessionPresetMedium    | 480x360       |
    |                       |              | AVCaptureSessionPresetLow       | 192x144       |
    |                       |              | AVCaptureSessionPreset640x480   | 640x480       |
    |                       |              | AVCaptureSessionPreset1280x720  | not supported |
    |                       |              | AVCaptureSessionPreset1920x1080 | not supported |
    |                       | BACK         |                                 |               |
    |                       |              | AVCaptureSessionPresetPhoto     | 2592x1936     |
    |                       |              | AVCaptureSessionPresetHigh      | 1920x1080     |
    |                       |              | AVCaptureSessionPresetMedium    | 480x360       |
    |                       |              | AVCaptureSessionPresetLow       | 192x144       |
    |                       |              | AVCaptureSessionPreset640x480   | 640x480       |
    |                       |              | AVCaptureSessionPreset1280x720  | 1280x720      |
    |                       |              | AVCaptureSessionPreset1920x1080 | 1920x1080     |
    +-----------------------+--------------+---------------------------------+---------------+
    | iPad 4/Air            |              |                                 |               |
    | iPad Mini 1/2/3       |              |                                 |               |
    | iPod 5G               |              |                                 |               |
    |                       | FRONT        |                                 |               |
    |                       |              | AVCaptureSessionPresetPhoto     | 1280x960      |
    |                       |              | AVCaptureSessionPresetHigh      | 1280x720      |
    |                       |              | AVCaptureSessionPresetMedium    | 480x360       |
    |                       |              | AVCaptureSessionPresetLow       | 192x144       |
    |                       |              | AVCaptureSessionPreset640x480   | 640x480       |
    |                       |              | AVCaptureSessionPreset1280x720  | 1280x720      |
    |                       |              | AVCaptureSessionPreset1920x1080 | not supported |
    |                       | BACK         |                                 |               |
    |                       |              | AVCaptureSessionPresetPhoto     | 2592x1936     |
    |                       |              | AVCaptureSessionPresetHigh      | 1920x1080     |
    |                       |              | AVCaptureSessionPresetMedium    | 480x360       |
    |                       |              | AVCaptureSessionPresetLow       | 192x144       |
    |                       |              | AVCaptureSessionPreset640x480   | 640x480       |
    |                       |              | AVCaptureSessionPreset1280x720  | 1280x720      |
    |                       |              | AVCaptureSessionPreset1920x1080 | 1920x1080     |
    +-----------------------+--------------+---------------------------------+---------------+
    | iPad Air 2            |              |                                 |               |
    | iPad Mini 4           |              |                                 |               |
    | iPad Pro              |              |                                 |               |
    |                       | FRONT        |                                 |               |
    |                       |              | AVCaptureSessionPresetPhoto     | 1280x960      |
    |                       |              | AVCaptureSessionPresetHigh      | 1280x720      |
    |                       |              | AVCaptureSessionPresetMedium    | 480x360       |
    |                       |              | AVCaptureSessionPresetLow       | 192x144       |
    |                       |              | AVCaptureSessionPreset640x480   | 640x480       |
    |                       |              | AVCaptureSessionPreset1280x720  | 1280x720      |
    |                       |              | AVCaptureSessionPreset1920x1080 | not supported |
    |                       | BACK         |                                 |               |
    |                       |              | AVCaptureSessionPresetPhoto     | 3264x2448     |
    |                       |              | AVCaptureSessionPresetHigh      | 1920x1080     |
    |                       |              | AVCaptureSessionPresetMedium    | 480x360       |
    |                       |              | AVCaptureSessionPresetLow       | 192x144       |
    |                       |              | AVCaptureSessionPreset640x480   | 640x480       |
    |                       |              | AVCaptureSessionPreset1280x720  | 1280x720      |
    |                       |              | AVCaptureSessionPreset1920x1080 | 1920x1080     |
    +-----------------------+--------------+---------------------------------+---------------+
    | iPod Touch 5          |              |                                 |               |
    |                       | FRONT        |                                 |               |
    |                       |              | AVCaptureSessionPresetPhoto     | 1280x960      |
    |                       |              | AVCaptureSessionPresetHigh      | 1280x720      |
    |                       |              | AVCaptureSessionPresetMedium    | 480x360       |
    |                       |              | AVCaptureSessionPresetLow       | 192x144       |
    |                       |              | AVCaptureSessionPreset640x480   | 640x480       |
    |                       |              | AVCaptureSessionPreset1280x720  | 1280x720      |
    |                       |              | AVCaptureSessionPreset1920x1080 | not supported |
    |                       | BACK         |                                 |               |
    |                       |              | AVCaptureSessionPresetPhoto     | 2592x1936     |
    |                       |              | AVCaptureSessionPresetHigh      | 1920x1080     |
    |                       |              | AVCaptureSessionPresetMedium    | 480x360       |
    |                       |              | AVCaptureSessionPresetLow       | 192x144       |
    |                       |              | AVCaptureSessionPreset640x480   | 640x480       |
    |                       |              | AVCaptureSessionPreset1280x720  | 1280x720      |
    |                       |              | AVCaptureSessionPreset1920x1080 | 1920x1080     |
    +-----------------------+--------------+---------------------------------+---------------+
    | iPod Touch 6          |              |                                 |               |
    |                       | FRONT        |                                 |               |
    |                       |              | AVCaptureSessionPresetPhoto     | 1280x960      |
    |                       |              | AVCaptureSessionPresetHigh      | 1280x720      |
    |                       |              | AVCaptureSessionPresetMedium    | 480x360       |
    |                       |              | AVCaptureSessionPresetLow       | 192x144       |
    |                       |              | AVCaptureSessionPreset640x480   | 640x480       |
    |                       |              | AVCaptureSessionPreset1280x720  | 1280x720      |
    |                       |              | AVCaptureSessionPreset1920x1080 | not supported |
    |                       | BACK         |                                 |               |
    |                       |              | AVCaptureSessionPresetPhoto     | 3264x2448     |
    |                       |              | AVCaptureSessionPresetHigh      | 1920x1080     |
    |                       |              | AVCaptureSessionPresetMedium    | 480x360       |
    |                       |              | AVCaptureSessionPresetLow       | 192x144       |
    |                       |              | AVCaptureSessionPreset640x480   | 640x480       |
    |                       |              | AVCaptureSessionPreset1280x720  | 1280x720      |
    |                       |              | AVCaptureSessionPreset1920x1080 | 1920x1080     |
    +-----------------------+--------------+---------------------------------+---------------+


 **CODE** 

    + (NSDictionary*) cameraResolutions {
        NSString* deviceModel = [self deviceModel];
        
        // iPhone 4S
        if ([deviceModel isEqualToString:@"iPhone4,1"]) {
            
            NSString* lFrontCam = @"640x480,480x360,192x144";
            NSString* lBackCam = @"3264x2448,1920x1080,1280x720,640x480,480x360,192x144";
            NSDictionary* lCamResolutions = @{@"front":lFrontCam,
                                              @"back":lBackCam};
            return lCamResolutions;
        }
        // iPhone 5/5C/5S/6/6+/iPod 6
        else if ([deviceModel isEqualToString:@"iPhone5,1"]
                 || [deviceModel isEqualToString:@"iPhone5,2"]
                 || [deviceModel isEqualToString:@"iPhone5,3"]
                 || [deviceModel isEqualToString:@"iPhone5,4"]
                 || [deviceModel isEqualToString:@"iPhone6,1"]
                 || [deviceModel isEqualToString:@"iPhone6,2"]
                 || [deviceModel isEqualToString:@"iPhone7,1"]
                 || [deviceModel isEqualToString:@"iPhone7,2"]
                 || [deviceModel isEqualToString:@"iPod7,1"]) {
            
            NSString* lFrontCam = @"1280x960,1280x720,640x480,480x360,192x144";
            NSString* lBackCam = @"3264x2448,1920x1080,1280x720,640x480,480x360,192x144";
            NSDictionary* lCamResolutions = @{@"front":lFrontCam,
                                              @"back":lBackCam};
            return lCamResolutions;
        }
        // iPhone 6S/6S+
        else if ([deviceModel isEqualToString:@"iPhone8,1"]
                 || [deviceModel isEqualToString:@"iPhone8,2"]) {
            NSString* lFrontCam = @"1280x960,1280x720,640x480,480x360,192x144";
            NSString* lBackCam = @"4032x3024,1920x1080,1280x720,640x480,480x360,192x144";
            NSDictionary* lCamResolutions = @{@"front":lFrontCam,
                                              @"back":lBackCam};
            return lCamResolutions;
        }
        // iPad 2
        else if ([deviceModel isEqualToString:@"iPad2,1"]
                 || [deviceModel isEqualToString:@"iPad2,2"]
                 || [deviceModel isEqualToString:@"iPad2,3"]
                 || [deviceModel isEqualToString:@"iPad2,4"]) {
            
            
            NSString* lFrontCam = @"640x480,480x360,192x144";
            NSString* lBackCam = @"1280x720,960x720,480x360,192x144,640x480";
            NSDictionary* lCamResolutions = @{@"front":lFrontCam,
                                              @"back":lBackCam};
            return lCamResolutions;
        }
        // iPad 3
        else if ([deviceModel isEqualToString:@"iPad3,1"]
                 || [deviceModel isEqualToString:@"iPad3,2"]
                 || [deviceModel isEqualToString:@"iPad3,3"]) {
            
            
            NSString* lFrontCam = @"640x480,480x360,192x144";
            NSString* lBackCam = @"2592x1936,1920x1080,1280x720,640x480,480x360,192x144";
            NSDictionary* lCamResolutions = @{@"front":lFrontCam,
                                              @"back":lBackCam};
            return lCamResolutions;
        }
        // iPad 4/Air/Mini/Mini 2/Mini 3/iPod 5G
        else if ([deviceModel isEqualToString:@"iPad3,4"]
                 || [deviceModel isEqualToString:@"iPad3,5"]
                 || [deviceModel isEqualToString:@"iPad3,6"]
                 || [deviceModel isEqualToString:@"iPad4,1"]
                 || [deviceModel isEqualToString:@"iPad4,2"]
                 || [deviceModel isEqualToString:@"iPad4,3"]
                 || [deviceModel isEqualToString:@"iPad4,4"]
                 || [deviceModel isEqualToString:@"iPad4,5"]
                 || [deviceModel isEqualToString:@"iPad4,6"]
                 || [deviceModel isEqualToString:@"iPad4,7"]
                 || [deviceModel isEqualToString:@"iPad4,8"]
                 || [deviceModel isEqualToString:@"iPod5,1"]) {
            
            NSString* lFrontCam = @"1280x960,1280x720,640x480,480x360,192x144";
            NSString* lBackCam = @"2592x1936,1920x1080,1280x720,640x480,480x360,192x144";
            NSDictionary* lCamResolutions = @{@"front":lFrontCam,
                                               @"back":lBackCam};
            return lCamResolutions;
        }
        // iPad Air 2/Mini 4/Pro
        else if ([deviceModel isEqualToString:@"iPad5,3"]
                 || [deviceModel isEqualToString:@"iPad5,4"]) {
            NSString* lFrontCam = @"1280x960,1280x720,640x480,480x360,192x144";
            NSString* lBackCam = @"3264x2448,1920x1080,1280x720,640x480,480x360,192x144";
            NSDictionary* lCamResolutions = @{@"front":lFrontCam,
                                              @"back":lBackCam};
            return lCamResolutions;
        }
        return nil;
    }


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值