At the moment I am using a custom overlay on a UIImagePickerController
, calling takePicture()
to capture images. However, it takes a good few seconds to call the delegate method didFinishPickingMediaWithInfo
. I've heard about using AVCaptureSession
for my control over the camera. Would this allow me to get faster picture-taking speeds (similar to that of Snapchat)? Or are there any other ways that I can
Thanks
EDIT
I'm implementing my image capture as follows.
First I initialise a UIImagePickerController, using a UIView subclass called CustomCameraOverlayView
for the overlay view, and present it in a modal view. The delegate of the CustomCameraOverlayView
is set to the UIImagePickerControllerDelegate
(self) so that I can call takePicture
from the CustomCameraOverlayView
.
imagePickerController = UIImagePickerController()
if UIImagePickerController.isSourceTypeAvailable(.Camera) {
imagePickerController.sourceType = UIImagePickerControllerSourceType.Camera
imagePickerController.cameraDevice = UIImagePickerControllerCameraDevice.Rear
imagePickerController.editing = true
imagePickerController.delegate = self
imagePickerController.showsCameraControls = false
var customCameraOverlayView = CustomCameraOverlayView()
customCameraOverlayView.delegate = self
imagePickerController.cameraOverlayView = customCameraOverlayView
imagePickerController.cameraOverlayView!.frame = self.view.frame
var screenBounds: CGSize = UIScreen.mainScreen().bounds.size
var imageHeight = (screenBounds.width/3)*4
var scale = screenBounds.height / imageHeight
imagePickerController.cameraViewTransform = CGAffineTransformConcat(CGAffineTransformMakeScale(scale, scale), CGAffineTransformMakeTranslation(0, (screenBounds.height - imageHeight)/2))
self.presentViewController(imagePickerController, animated: true, completion: nil)
}
Then inside the CustomCameraOverlayView
I have a action set up from the "take picture" button in IB to my code. It sends a message back to the delegate to take the picture:
@IBAction func takePicture(sender: UIButton) {
delegate!.imagePickerController.takePicture()
}
A few seconds later the delegate method is called. What could be slowing my implementation down?