捕捉媒体

2017-12-04  本文已影响5人  学学学q

对物理硬件设备定义了大量的控制方法,比如控制摄像头的对焦、曝光、白平衡和闪光灯等。最常用的是defaultDeviceWithMediaType,根据给定的媒体类型返回一个系统指定的默认设备。

AVCaptureDevice *videoDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];

    NSError *error;
    
    AVCaptureDeviceInput *videoInput = [AVCaptureDeviceInput deviceInputWithDevice:cameraDevice error:&error];


   [self.imageOutput captureStillImageAsynchronouslyFromConnection:conntion completionHandler:^(CMSampleBufferRef  _Nullable imageDataSampleBuffer, NSError * _Nullable error) {
       if (imageDataSampleBuffer == nil) {
            return ;
        }
        NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer];
        [_session stopRunning];
        
        
        UIImage *faceImage = [UIImage imageWithData:imageData];
        _currentImage = faceImage;    
    }];

上一篇下一篇

猜你喜欢

热点阅读