项目介绍:
<audio controls="controls" style="display: none;"></audio>
简介
XDCaptureService是一个简易及稳定的相机组件,能够帮助你快速构建你的音视频场景,组件支持拍照、录像、人脸检测、景深数据捕获、ISO、白平衡、聚焦等功能
源码地址
https://github.com/caixindong/XDCaptureService
使用
启动组件
@property (nonatomic, strong) XDCaptureService *service;
self.service = [[XDCaptureService alloc] init];
_service.delegate = self;
[_service startRunning];
代理实现
@protocol XDCaptureServiceDelegate <NSObject>
@optional
//service lifecylce
- (void)captureServiceDidStartService:(XDCaptureService *)service;
- (void)captureService:(XDCaptureService *)service serviceDidFailWithError:(NSError *)error;
- (void)captureServiceDidStopService:(XDCaptureService *)service;
- (void)captureService:(XDCaptureService *)service getPreviewLayer:(AVCaptureVideoPreviewLayer *)previewLayer;
- (void)captureService:(XDCaptureService *)service outputSampleBuffer:(CMSampleBufferRef)sampleBuffer;
//record module
- (void)captureServiceRecorderDidStart:(XDCaptureService *)service ;
- (void)captureService:(XDCaptureService *)service recorderDidFailWithError:(NSError *)error;
- (void)captureServiceRecorderDidStop:(XDCaptureService *)service;
//photo capture
- (void)captureService:(XDCaptureService *)service capturePhoto:(UIImage *)photo;
//face detect
- (void)captureService:(XDCaptureService *)service outputFaceDetectData:(NSArray <AVMetadataFaceObject*>*) faces;
//depth map
- (void)captureService:(XDCaptureService *)service captureTrueDepth:(AVDepthData *)depthData API_AVAILABLE(ios(11.0));
@end
更多细节
更多细节可以查看项目里的Example过程。