Front Facing Camera in Uiimagepickercontroller

UIImagePickerController - How do I access the front facing camera by default?

UIImagePickerControllerCameraDeviceFront is not a valid enum for the sourceType property. The sourceType property defines whether you're using the camera or the photo library. You need to set the cameraDevice property instead.

Objective-C

self.imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
self.imgPicker.cameraDevice = UIImagePickerControllerCameraDeviceFront;

Swift 2

imgPicker.sourceType = .Camera
imgPicker.cameraDevice = .Front

Swift 3

imgPicker.sourceType = .camera
imgPicker.cameraDevice = .front

Front facing camera in UIImagePickerController

You can flip the image from the source image use this

UIImage *flippedImage = [UIImage imageWithCGImage:picture.CGImage scale:picture.scale orientation:UIImageOrientationLeftMirrored];

Edit: Added swift code

let flippedImage = UIImage(CGImage: picture.CGImage, scale: picture.scale, orientation:.LeftMirrored)

iPad uiimagepickercontroller only front camera

This is a bit of a work around, but because there is no delegate for what you're looking for this will do the trick.

Sign up notifications from the PickerController in ViewDidLoad (In this case because you implement your own controls you may have to setup your own notification)

   [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(retakeImage:)
name:@"_UIImagePickerControllerUserDidRejectItem" object:nil];

Then when the user chooses to retake the photo reassert the picker to use the front camera.

  - (void)retakeImage:(NSNotification *)notification
{
self.pickerController.cameraDevice = UIImagePickerControllerCameraDeviceFront;
}

Hope this helps!

UIImagePickerController front camera show mirror image on preview view

finally, i can not solve this issue in UIImagePickerController, but i solve this issue using AVFoundation and CoreMotion, you can see AVCam

//init the motionManager
- (void)initializeMotionManager{
motionManager = [[CMMotionManager alloc] init];
motionManager.accelerometerUpdateInterval = .1;
motionManager.gyroUpdateInterval = .1;

[motionManager startAccelerometerUpdatesToQueue:[NSOperationQueue currentQueue]
withHandler:^(CMAccelerometerData *accelerometerData, NSError *error) {
if (!error) {
[self outputAccelertionData:accelerometerData.acceleration];
}
else{
NSLog_DEBUG(@"%@", error);
}
}];
}

//detect the device orientation
- (void)outputAccelertionData:(CMAcceleration)acceleration{

if (acceleration.x >= 0.75) {
_orientationNew = UIInterfaceOrientationLandscapeLeft;
}
else if (acceleration.x <= -0.75) {
_orientationNew = UIInterfaceOrientationLandscapeRight;
}
else if (acceleration.y <= -0.75) {
_orientationNew = UIInterfaceOrientationPortrait;
}
else if (acceleration.y >= 0.75) {
_orientationNew = UIInterfaceOrientationPortraitUpsideDown;
}
else {
// Consider same as last time
return;
}

if (_orientationNew == _orientationLast)
return;

_orientationLast = _orientationNew;
}

UIImagePickerController how to do animated switch from rear to front camera?

I was trying to do this today, and I was able to get it working with the following code:

[UIView transitionWithView:imagePickerController.view duration:1.0 options:UIViewAnimationOptionAllowAnimatedContent | UIViewAnimationOptionTransitionFlipFromLeft animations:^{
imagePickerController.cameraDevice = UIImagePickerControllerCameraDeviceRear;
} completion:NULL];

I hope this helps anyone who comes across this question.

Weird issue with Front facing camera pictures

It turns out that I can get the result I want with smaller numbers. The front camera must have a different number of pixels than the back camera. Anyhow, if anyone is trying to do this, try smaller numbers rather than larger ones.



Related Topics



Leave a reply



Submit