Reputation: 5232
I am working on an App and capturing images using UIImagePickerController
. When application launches UIImagePickerController
's object it has back camera as default selection. Everything works fine with back camera.
However, when I change the camera source to frontFacingCamera
from imagePicker's toggle camera button and capture image, I get a mirrored image. My left arm shows as right arm in image. How do I solve this issue?
UIImagePickerController
?AVFoundation
classes for this issue?Unfortunately, I am very weak in AVFoundation
.
Upvotes: 0
Views: 1456
Reputation: 332
Plz try below code
- (UIImage *)PictureFlipe:(UIImage *)picture
{
UIImage * flippedImage = [UIImage imageWithCGImage:picture.CGImage scale:picture.scale orientation:UIImageOrientationLeftMirrored];
return flippedImage;
}
Upvotes: 0
Reputation: 1576
I had the same problem and used this Method to mirror the image the other way round.
- (UIImage *) flipImageLeftRight:(UIImage *)originalImage {
UIImageView *tempImageView = [[UIImageView alloc] initWithImage:originalImage];
UIGraphicsBeginImageContext(tempImageView.frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
//CGAffineTransformMake(<#CGFloat a#>, <#CGFloat b#>, <#CGFloat c#>, <#CGFloat d#>, <#CGFloat tx#>, <#CGFloat ty#>)
CGAffineTransform flipVertical = CGAffineTransformMake(1, 0, 0, -1, 0, tempImageView.frame.size.height);
CGContextConcatCTM(context, flipVertical);
[tempImageView.layer renderInContext:context];
UIImage *flipedImage = UIGraphicsGetImageFromCurrentImageContext();
flipedImage = [UIImage imageWithCGImage:flipedImage.CGImage scale:1.0 orientation:UIImageOrientationDown];
UIGraphicsEndImageContext();
[tempImageView release];
return flipedImage;
}
Upvotes: 1