GPUImage--视频流处理之AVCaptureVideoDataOutputSampleBufferDelegate

本文介绍了如何使用GPUImage框架在iOS应用中处理CMSampleBufferRef视频流数据,展示从获取视频流到实现美颜效果的过程。通过AVCaptureVideoDataOutputSampleBufferDelegate获取视频流,然后添加滤镜进行图像处理,最终实现实时的美颜效果。
摘要由CSDN通过智能技术生成

如果你是第一次看到这篇博客请看http://blog.csdn.net/xoxo_x/article/details/52695032

如果app需求仅仅是自己得到美颜的效果, 请看这里http://blog.csdn.net/xoxo_x/article/details/52743107

如果想了解更多的滤镜使用方法,请看这里http://blog.csdn.net/xoxo_x/article/details/52749033

接下来咱们要做的工作是如何对 CMSampleBufferRef 数据进行渲染、然后显示 美颜效果

一、通过AVCaptureVideoDataOutputSampleBufferDelegate获取视频流:

#import "ViewController.h"
#import <AVFoundation/AVFoundation.h>
#import "ViewController.h"
#import <AVFoundation/AVFoundation.h>

@interface ViewController ()<AVCaptureVideoDataOutputSampleBufferDelegate>

@property (nonatomic, strong) AVCaptureVideoPreviewLayer  *preLayer;
@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self setupCaptureSession];
}
//捕获到视频的回调函数
- (void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
       fromConnection:(AVCaptureConnection *)connection
{

}
//开启摄像头
- (void)setupCaptureSession
{
    NSError *error = nil;

     // 创建session
    AVCaptureSession *session = [[AVCaptureSession alloc] init];

       // 可以配置session以产生解析度较低的视
评论 14
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值