iOS taking photo programmatically
This is very simple, just use the AVFoundation reference guide:
If you don't want the user to see the preview input you can just skip the set preview layer part of the code.
Edit: To be more detailed.
1)You set your capture configuration using the AVFoundation.
- Set the camera input to frontal, turn off flash etc etc.
2)You SKIP the part where the video preview layer is set.
3)You call the captureStillImageAsynchronouslyFromConnection:completionHandler: method whenever you want the picture to be taken.
Note: If you want the flash to not be heard and such then you might be violating the user rights in some countries (japan for example). One workaround I know of to do so is by capturing a frame of a video (does not trigger flash).
You can also do it without AVFoundation and it is in my opinion an easier way to implement it using only the UIImagePickerController.There are 3 conditions:
- Obviously the device needs to have a camera
- You must hide the camera controls
- Then simply use the takePicture method from UIImagePickerController
Below is a simple example that you woul typically trigger after a button push
- (IBAction)takePhoto:(id)sender { UIImagePickerController *picker = [[UIImagePickerController alloc] init]; picker.delegate = self; picker.sourceType = UIImagePickerControllerSourceTypeCamera; picker.cameraDevice = UIImagePickerControllerCameraDeviceFront; picker.showsCameraControls = NO; [self presentViewController:picker animated:YES completion:^ { [picker takePicture]; }];}
VLBCameraView is a library that uses AVFoundation to take photo.
A preview is shown in the view, which you can then call the method VLBCameraView#takePicture programmatically to take a photo.
Comes with CocoaPods.