I am using AVCam made by apple for my custom camera view. Honestly it is not to simple to understand what's going on in the class AVCamViewController
if you see it at first time.
Right now I am interested how they set frame of captured image. I tried to found where some fames setters or something like this, but I have not found any.
I searched in Google and found answer here AVCam not in fullscreen
But when I implemented that solution I just realised that it just made live camera preview layer with the same size as my view, but when app saves image in the method - (IBAction)snapStillImage:(id)sender
in the gallery images still was with 2 stripes from left and right.
My question is how can I remove this stripes or in which line in source code apple set this stuff?
Also as additional sub-question how can I set type create just photo, because the app requests me "Microphone settings" and I don't need it just need make a photo and that's it.
This code from apple sources will save image to the photo library.
- (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];
}
}];
});
}
Are you setting the session preset?
You can use your session with the session preset set in
AVCaptureSessionPresetPhoto
.For the another subquestion: You need to add only the
AVCaptureStillImageOutput
output.How to set the session Preset?
How to configure the session to use only StillImageOutput to take photos and ?
The blacks fields are needed to keep the aspect ratio, if want to avoid them you should change the
videoGravity
in theAVCaptureVideoPreviewLayer
, or in thecontentMode
of theUIImageView
displaying the captured image.This is an expected behavior, don't understand your concern.