目标:自拍并结合C++算法,识别人脸信息,第一步骤,调用相机并且自定义界面和转场效果
先复习一下
https://developer.apple.com/library/prerelease/tvos/documentation/UIKit/Reference/UIImagePickerController_Class/index.html
The UIImagePickerController
class manages customizable, system-supplied user interfaces for taking pictures and movies on supported devices, and for choosing saved images and movies for use in your app. An image picker controller manages user interactions and delivers the results of those interactions to a delegate object.
cameraOverlayView 自定义用户的界面
#pragma mark - Private - (BOOL)availableCamera { if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { NSLog(@"您的相机没有或者无法使用"); return NO; } _pickerController = [[UIImagePickerController alloc] init]; _pickerController.delegate = self; _pickerController.view.backgroundColor = [UIColor orangeColor]; _pickerController.sourceType = UIImagePickerControllerSourceTypeCamera; _pickerController.allowsEditing = YES; if (![UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceFront]) { NSLog(@"您的手机不支持前置摄像头"); return NO; } _pickerController.cameraDevice = UIImagePickerControllerCameraDeviceFront; return YES; }
但是由于,上述效果达到不了设计效果,所以只能启用。
所以决定,自定义摄像头,下面是学习整理的资料,如有错误麻烦指出
在进行视频捕获时,有输入设备及输出设备,程序通过 AVCaptureSession 的一个实例来协调、组织数据在它们之间的流动。
在正式学习之前,先了解一下AVFoundation框架
#import <AVFoundation/AVFoundation.h>
1.AVFoundation在相关框架栈中的位置:
2.跟视频相关的几种类
// 用于协调输入与输出之间的数据流 @property (nonatomic, strong) AVCaptureSession * session; // 用于设备输入数据源 @property (nonatomic, strong) AVCaptureDeviceInput * videoInput; // 限制自定义相机只有拍照功能 @property (nonatomic, strong) AVCaptureStillImageOutput * stillImageOutput; // 提供摄像头的预览功能 @property (nonatomic, strong) AVCaptureVideoPreviewLayer * previeLayer;
他们的作用衔接起来可以用下图概括
3.用AVFoundation框架捕捉视频流
(1.创建AVCaptureSession
作为协调输入与输出的中心,第一步创建一个session
...
最终效果实现,但是,在解决图片的时候,出现了问题,因为忽略了EXIF中的UIImage的imageOrientation,我将会再一次重写自定义照相机
参考链接:
http://course.gdou.com/blog/Blog.pzs/archive/2011/12/14/10882.htmlhttp://blog.csdn.net/wrathli/article/details/39431287?utm_source=tuicool