AVCam保存全屏捕获的图像

我正在使用苹果公司生产的AVCam来定制相机视图。 老实说,如果你第一次看到AVCamViewController类,那么理解AVCamViewController是怎么回事呢?

现在我感兴趣的是他们如何设置捕获图像的帧。 我试图find一些名人或类似的东西,但我还没有find。

我在谷歌search,并find答案在这里AVCam不全屏

但是当我实现这个解决scheme时,我只是意识到它只是制作了与我的视图相同大小的实时相机预览图层,但是当应用程序将图像保存在方法中时- (IBAction)snapStillImage:(id)sender从左边和右边2条。

我的问题是如何删除这个条纹或在源代码中的哪一行苹果设置这个东西?

另外作为附加的子问题,我怎样才能设置types创build照片,因为应用程序要求我“麦克风设置”,我不需要它只是需要照片,就是这样。

这个苹果来源的代码将图像保存到照片库。

 - (IBAction)snapStillImage:(id)sender { dispatch_async([self sessionQueue], ^{ // Update the orientation on the still image output video connection before capturing. [[[self stillImageOutput] connectionWithMediaType:AVMediaTypeVideo] setVideoOrientation:[[(AVCaptureVideoPreviewLayer *)[[self previewView] layer] connection] videoOrientation]]; // Flash set to Auto for Still Capture [AVCamViewController setFlashMode:AVCaptureFlashModeAuto forDevice:[[self videoDeviceInput] device]]; // Capture a still image. [[self stillImageOutput] captureStillImageAsynchronouslyFromConnection:[[self stillImageOutput] connectionWithMediaType:AVMediaTypeVideo] completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error) { if (imageDataSampleBuffer) { NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer]; UIImage *image = [[UIImage alloc] initWithData:imageData]; UIImage *proccessingImage = [SAPAdjustImageHelper adjustImage:image]; NSNumber *email_id = [SAPCoreDataEmailHelper currentEmailId]; [SAPFileManagerHelper addImage:proccessingImage toFolderWithEmailId:email_id]; } }]; }); } 

你是否设置会话预设?

您可以使用会话预设在AVCaptureSessionPresetPhoto设置的会话。

对于另一个子问题:您只需添加AVCaptureStillImageOutput输出。

如何设置会话预设?

 [session setSessionPreset:AVCaptureSessionPresetPhoto]; 

如何configuration会话以仅使用StillImageOutput拍摄照片?

 - (void)viewDidLoad { [super viewDidLoad]; // Create the AVCaptureSession AVCaptureSession *session = [[AVCaptureSession alloc] init]; [self setSession:session]; // Setup the preview view [[self previewView] setSession:session]; // Setup the session Preset [session setSessionPreset:AVCaptureSessionPresetPhoto]; // Check for device authorization [self checkDeviceAuthorizationStatus]; dispatch_queue_t sessionQueue = dispatch_queue_create("session queue", DISPATCH_QUEUE_SERIAL); [self setSessionQueue:sessionQueue]; dispatch_async(sessionQueue, ^{ //[self setBackgroundRecordingID:UIBackgroundTaskInvalid]; NSError *error = nil; AVCaptureDevice *videoDevice = [AVCamViewController deviceWithMediaType:AVMediaTypeVideo preferringPosition:AVCaptureDevicePositionBack]; AVCaptureDeviceInput *videoDeviceInput = [AVCaptureDeviceInput deviceInputWithDevice:videoDevice error:&error]; if (error) { NSLog(@"%@", error); } if ([session canAddInput:videoDeviceInput]) { [session addInput:videoDeviceInput]; [self setVideoDeviceInput:videoDeviceInput]; dispatch_async(dispatch_get_main_queue(), ^{ // Why are we dispatching this to the main queue? // Because AVCaptureVideoPreviewLayer is the backing layer for AVCamPreviewView and UIView can only be manipulated on main thread. // Note: As an exception to the above rule, it is not necessary to serialize video orientation changes on the AVCaptureVideoPreviewLayer's connection with other session manipulation. [[(AVCaptureVideoPreviewLayer *)[[self previewView] layer] connection] setVideoOrientation:(AVCaptureVideoOrientation)[self interfaceOrientation]]; }); } AVCaptureStillImageOutput *stillImageOutput = [[AVCaptureStillImageOutput alloc] init]; if ([session canAddOutput:stillImageOutput]) { [stillImageOutput setOutputSettings:@{AVVideoCodecKey : AVVideoCodecJPEG}]; [session addOutput:stillImageOutput]; [self setStillImageOutput:stillImageOutput]; } }); } 

需要黑场来保持纵横比,如果想要避开它们,你应该改变AVCaptureVideoPreviewLayervideoGravity ,或者在UIImageViewcontentMode中显示拍摄的图像。
这是一个预期的行为,不理解你的关注。