iOS 自定义相机


这个模式非常重要,可以使相机全屏 AVLayerVideoGravityResizeAspectFill,如果写错了 可能在刘海屏上出现上下的安全区域,站不满全屏了就

 

前置摄像头拍照后 成像是反的,需要

今天才发现,苹果的前置摄像头拍的照片出来是反的!!!为了解决这个问题在自定义拍照的时候只需要做两部工作,

 1.是判断当前的摄像头是前置还是后置的:
enum {
    AVCaptureDevicePositionBack = 1,//后置
摄像头
    AVCaptureDevicePositionFront = 2 //前置摄像头
};
typedef NSInteger AVCaptureDevicePosition;
2.对图片进行处理:

   

        UIImageOrientation imgOrientation; //拍摄后获取的的图像方向

        

        if ([self.inputDevice device].position == AVCaptureDevicePositionFront) {

                        // 前置摄像头图像方向 UIImageOrientationLeftMirrored

            // IOS前置摄像头左右成像

            imgOrientation = UIImageOrientationLeftMirrored;

            NSLog(@"前置摄像头");

            NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageSampleBuffer];

     UIImage *t_image = [UIImage imageWithData:imageData];

 

             UIImage *image = [[UIImage alloc]initWithCGImage:t_image.CGImage scale:1.0f orientation:imgOrientation];

        }

 

 

参考链接:https://www.jianshu.com/p/81b70b455546

https://www.jianshu.com/p/8af2a56e6d49

http://blog.sina.com.cn/s/blog_14ddfbc6f0102wuvc.html

 

posted on 2016-05-03 10:13  🌞Bob  阅读(260)  评论(0编辑  收藏  举报

导航