美文网首页
iOS:GPUImage滤镜+采集

iOS:GPUImage滤镜+采集

作者: 豆浆油条cc | 来源:发表于2019-08-02 11:48 被阅读0次

    使用GPUImage进行采集摄像头数据,并且能够实现大部分的美颜效果 并且集成了闪光灯 摄像头切换 焦点缩放 聚焦功能
    GIF演示


    Untitled.gif

    主要几个核心类:
    GPUImageVideoCamera:封装系统的AVCaptureSession,AVCaptureDevice,AVCaptureDeviceInput,AVCaptureVideoDataOutput
    演示

    -(CCGPUImageVideoCamera *)videoCamera{
        if (!_videoCamera) {
            _videoCamera = [[CCGPUImageVideoCamera alloc] initWithSessionPreset:AVCaptureSessionPreset1280x720 cameraPosition:AVCaptureDevicePositionFront];
            _videoCamera.delegate = self;
            _videoCamera.audioDelegate = self;
            _videoCamera.outputImageOrientation = UIInterfaceOrientationPortrait;
            _videoCamera.horizontallyMirrorFrontFacingCamera = YES;// 前置摄像头需要 镜像反转
            _videoCamera.horizontallyMirrorRearFacingCamera = NO;// 后置摄像头不需要 镜像反转
            [_videoCamera addAudioInputsAndOutputs];//避免录制第一帧黑屏闪屏
            if ([_videoCamera.inputCamera lockForConfiguration:nil]) {
                //自动对焦
                if ([_videoCamera.inputCamera isFocusModeSupported:AVCaptureFocusModeContinuousAutoFocus]) {
                    [_videoCamera.inputCamera setFocusMode:AVCaptureFocusModeContinuousAutoFocus];
                }
                //自动曝光
                if ([_videoCamera.inputCamera isExposureModeSupported:AVCaptureExposureModeContinuousAutoExposure]) {
                    [_videoCamera.inputCamera setExposureMode:AVCaptureExposureModeContinuousAutoExposure];
                }
                //自动白平衡
                if ([_videoCamera.inputCamera isWhiteBalanceModeSupported:AVCaptureWhiteBalanceModeContinuousAutoWhiteBalance]) {
                    [_videoCamera.inputCamera setWhiteBalanceMode:AVCaptureWhiteBalanceModeContinuousAutoWhiteBalance];
                }
                [_videoCamera.inputCamera unlockForConfiguration];
            }
            
        }
        return _videoCamera;
    }
    

    GPUImageView:获取采集到的数据进行展示
    GPUImageMovieWriter:采集的视频 音频数据进行写入
    GPUImageFilter:滤镜核心类

    github:https://github.com/qw9685/GPUImage-

    相关文章

      网友评论

          本文标题:iOS:GPUImage滤镜+采集

          本文链接:https://www.haomeiwen.com/subject/fsnkdctx.html