1 新建一个singleview工程,导入GPUImage库

2 添加属性

    GPUImageVideoCamera *videoCamera;

    GPUImageOutput *filter;

3 viewDidload里面添加代码:

    videoCamera = [[GPUImageVideoCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionBack];

    videoCamera.outputImageOrientation = UIInterfaceOrientationPortrait;

    videoCamera.horizontallyMirrorFrontFacingCamera = NO;

    videoCamera.horizontallyMirrorRearFacingCamera = NO;

 

    filter = [[GPUImageColorInvertFilter alloc] init];

 

    [videoCamera addTarget:filter];

    GPUImageView *filterView = (GPUImageView *)self.view;

 

    [filter addTarget:filterView];

    [videoCamera startCameraCapture];

4 注意,这里要非常地注意!!

在storyboard里面把viewControl的view的类改为GPUImageView!!不然会报错,这也是烦扰了我半天的问题!google到了stackOverFlow才找到的答案。。

如果还报错,看看target-build setting里面,other linker flags 里面是否添加了   -fobjc-arc   -ObjC 这两项