With AVCapturePresets, you have an explicit size by which videos or photos will be taken. After you take a picture, you can manipulate (crop, resize) according to your desired size, but you cannot set a predefined capture size.
There are acceptable presets:
NSString *const AVCaptureSessionPresetPhoto; NSString *const AVCaptureSessionPresetHigh; NSString *const AVCaptureSessionPresetMedium; NSString *const AVCaptureSessionPresetLow; NSString *const AVCaptureSessionPreset320x240; NSString *const AVCaptureSessionPreset352x288; NSString *const AVCaptureSessionPreset640x480; NSString *const AVCaptureSessionPreset960x540; NSString *const AVCaptureSessionPreset1280x720;
source: https://developer.apple.com/library/mac/#documentation/AVFoundation/Reference/AVCaptureSession_Class/Reference/Reference.html
This method is what I use, which should help you scale to the right size:
-(UIImage*)imageWithImage:(UIImage*)image scaledToSize:(CGSize)newSize; { UIGraphicsBeginImageContext( newSize ); [image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)]; UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return newImage; }
Initializing a session and setting up a preset:
// create a capture session if(session == nil){ session = [[AVCaptureSession alloc] init]; } if ([session canSetSessionPreset:AVCaptureSessionPreset320x240]) { session.sessionPreset = AVCaptureSessionPreset320x240; } else { NSLog(@"Cannot set session preset"); }
propstm Jan 14 '13 at 16:23 2013-01-14 16:23
source share