AVCaptureConnection AVCaptureConnection 代表的是 AVCaptureSession 里 AVCaptureInput 与 AVCaptureOutput 对象之间建立的连接 AVCaptureOutput AVCaptureOutput 是一个抽象类,有很多具体的实现类,如AVCaptureVideoDataOutput、AVCaptureMovieFileOutput等。 它继承自 AVCaptureOutput。 下图是AVCaptureDeviceInput、AVCaptureConnection及AVCaptureOutput关系图: 采集视频的步骤 创建并初始化 AVCaptureSession。
AVCaptureOutput 同样,AVCaptureOutput 也是抽象类,常用的有:AVCaptureMovieFileOutput,AVCaptureVideoDataOutput,AVCaptureAudioDataoutput avCaptureSession startRunning]; [avCaptureSession stopRunning]; 获取采集数据 //视频采集数据回调 - (void)captureOutput:(AVCaptureOutput
AVCaptureOutput:硬件输出对象,用于接收各类输出数据,通常使用对应的子类AVCaptureAudioDataOutput(声音数据输出对象)、AVCaptureVideoDataOutput (视频数据输出对象) AVCaptionConnection:当把一个输入和输出添加到AVCaptureSession之后,AVCaptureSession就会在输入、输出设备之间建立连接,而且通过AVCaptureOutput AVCaptureAudioDataOutput),并且设置样品缓存代理(setSampleBufferDelegate)就可以通过它拿到采集到的音频数据 6.将数据输入对象AVCaptureDeviceInput、数据输出对象AVCaptureOutput
addInput:(AVCaptureInput *)input 添加采集输入设备 removeInput:(AVCaptureInput *)input 移除指定的采集输入设备 canAddOutput:(AVCaptureOutput *)output 是否可以添加指定的输出接口 addOutput:(AVCaptureOutput *)output 添加采集输出接口 removeOutput:(AVCaptureOutput *)
self.queue]; // 检测人脸是为了获得“人脸区域”,做“人脸区域”与“身份证人像框”的区域对比,当前者在后者范围内的时候,才能截取到完整的身份证图像 -(void)captureOutput:(AVCaptureOutput 从输出的数据流捕捉单一的图像帧 // AVCaptureVideoDataOutput获取实时图像,这个代理方法的回调频率很快,几乎与手机屏幕的刷新频率一样快 -(void)captureOutput:(AVCaptureOutput
} session.commitConfiguration() 二、实现音视频的采集代理 音视频虽然需要遵守的代理名称不一样,但是需要实现的方法是一致的,所以要拿到音频或者视频就得先进行判断,需要用到AVCaptureOutput AVCaptureVideoDataOutputSampleBufferDelegate, AVCaptureAudioDataOutputSampleBufferDelegate { func captureOutput(_ captureOutput: AVCaptureOutput
前期录制方案如下: 创建AVCaptureSession,设置拍摄分辨率 添加AVCaptureInput,如摄像头和麦克风 添加AVCaptureOutput,如AVCaptureVideoDataOutput 综上所述,要想拍视频不卡,就要在录制过程中尽量不做CPU耗时操作,而且AVCaptureOutput传递数据给上层时不能卡住AV线程。 最终想到个方案,加个Cache层,先把AVCaptureOutput传递的SampleBuffer缓存下来,不在AV的线程写视频;等CPU空闲时,再唤起movieWriter线程写视频。
AVCaptureSession)来管理 input 和 output 之前的数据流: 类名 简介 AVCaptureDevice 输入设备,例如 摄像头 麦克风 AVCaptureInput 输入端口 [使用其子类] AVCaptureOutput CMSampleBufferGetDuration : 获取当前帧播放时间 CMSampleBufferGetImageBuffer : 获取当前帧图片信息 */ // 获取帧数据 - (void)captureOutput:(AVCaptureOutput
startRunning]; 3、实现代理方法 #pragma mark - AVCaptureVideoDataOutputSampleBufferDelegate - (void)captureOutput:(AVCaptureOutput
import AVFoundation.AVCaptureInput import AVFoundation.AVCaptureMetadataOutput import AVFoundation.AVCaptureOutput AVAssetWriterInput写入文件的输入类 AVAssetDownloadTask资源文件下载任务 AVCaptureDevice硬件捕获设备类 AVCaptureInput从硬件捕获设备获得输入的数据 AVCaptureOutput
avCaptureSession.commitConfiguration() 58 avCaptureSession.startRunning() 59 } 60 func captureOutput(_ captureOutput: AVCaptureOutput
AVCaptureOutput:输出数据管理对象,用于接收各类输出数据,有很多子类,每个子类用途都不一样,该对象将会被添加到AVCaptureSession中管理。 removeObserver:self]; } #pragma mark - 代理方法 /** * 如果扫描到了二维码 回调该代理方法 */ - (void)captureOutput:(AVCaptureOutput
直接开始启动二维码扫描就可以了,成功扫码并识别到信息时候会调用对应的 AVCaptureMetadataOutputObjectsDelegate 代理的 - (void)captureOutput:(AVCaptureOutput #pragma mark - AVCaptureMetadataOutputObjectsDelegate //后置摄像头扫描到二维码的信息 - (void)captureOutput:(AVCaptureOutput
AVCaptureVideoDataOutputSampleBufferDelegate { // 摄像头捕获后的代理方法 func captureOutput(_ output: AVCaptureOutput
vedioPreviewLayer removeFromSuperlayer]; } pragma mark - AVFoundation delegate method -(void)captureOutput:(AVCaptureOutput
(void)viewDidLoad { [super viewDidLoad]; [self setupAVCapture]; } - (void)captureOutput:(AVCaptureOutput
vedioPreviewLayer removeFromSuperlayer]; } pragma mark - AVFoundation delegate method -(void)captureOutput:(AVCaptureOutput
import AVFoundation.AVCaptureInput import AVFoundation.AVCaptureMetadataOutput import AVFoundation.AVCaptureOutput
AVCaptureSession需要一个 AVCaptureInput和一个AVCaptureOutput 作为输入和输出,AVCaptureSession会链接input和output,从而从input
[session startRunning]; } 之后我们的UI上已经可以看到摄像头捕获的内容,只要实现代理中的方法,就可以完成二维码条形码的扫描: -(void)captureOutput:(AVCaptureOutput