我正在开发一个应用程序并使用UIImagePickerController
捕获图像。当应用程序启动 UIImagePickerController 的对象时,它会将后置摄像头作为默认选择。后置摄像头一切正常。
但是,当我从 imagePicker 的切换相机按钮将相机源更改为 frontFacingCamera
并捕获图像时,我得到了镜像图像。我的左臂在图像中显示为右臂。我该如何解决这个问题?
- 那么可以使用
UIImagePickerController
解决这个问题吗? - 如果不是,有什么方法可以进行图像处理以获得正常图像?
- 是否必须学习
AVFoundation
类才能解决此问题? - 如果是,则第三个。请引导我找到一个很好的教程。
不幸的是,我在AVFoundation
方面非常薄弱。
最佳答案
我遇到了同样的问题,并使用此方法以相反的方式镜像图像。
- (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;
}
关于iphone - 图像通过 frontFacingCamera 镜像到 UIImagePickerController 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12949612/