Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

automatically start FrontCamera and capture image

I want to make a camera application in which i want to start front camera automatically and capture image without user interaction. thanks in advance.

like image 393
I_User Avatar asked Jun 18 '26 00:06

I_User


2 Answers

In addition to Robin's answer, add the following statements (before presentModalViewController:) to ensure that if the device has a front camera, that should be opened by default

if([UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceFront]){
 self.imagePicker.sourceType=UIImagePickerControllerSourceTypeCamera; //skipping this was crashing my app with some ** Assertion failure.
    picker.cameraDevice = UIImagePickerControllerCameraDeviceFront;
}

Please note, if your app is compatible with devices running OS older than 4.0, you will have to put in conditional checks since cameraDevice property is available only in iOS 4.0 and later

like image 165
lostInTransit Avatar answered Jun 19 '26 15:06

lostInTransit


The UIImagePickerController is a higher level abstraction to the camera. Have a look at AVFoundation examples to see how to get to the camera more directly.

The documentation for AVFoundation is here.

To do it while still using the picker, have a look at.1317978. Look around for some examples using UIGetScreenImage(). It used to be a private API but I think it is now allowed.

You might also want to look around at some examples concerning custom overlay, like this one.

like image 41
my fat llama Avatar answered Jun 19 '26 14:06

my fat llama