Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/109.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使用GPUImage筛选实时视图_Ios_Gpuimage - Fatal编程技术网

Ios 使用GPUImage筛选实时视图

Ios 使用GPUImage筛选实时视图,ios,gpuimage,Ios,Gpuimage,我试图使用GPUImage来过滤视图,因为它是在一种iOS7风格的覆盖中更新的。为此,我在NSTimer上运行以下代码,但是我的NSLog显示,[self.backgroundUIImage imageFromCurrentlyProcessedOutput]正在返回(null)。我知道视图self.background在添加到视图中时工作正常(self.finalImageView也已添加到视图中)。我不确定我是否以正确的方式进行这项工作,因为在GPUImage github页面上没有关于如何

我试图使用GPUImage来过滤视图,因为它是在一种iOS7风格的覆盖中更新的。为此,我在NSTimer上运行以下代码,但是我的NSLog显示,
[self.backgroundUIImage imageFromCurrentlyProcessedOutput]
正在返回(null)。我知道视图self.background在添加到视图中时工作正常(self.finalImageView也已添加到视图中)。我不确定我是否以正确的方式进行这项工作,因为在GPUImage github页面上没有关于如何进行这项工作的真正文档。有人知道这样使用GPUImage是否可行吗

if (!self.backgroundUIImage) {

        self.backgroundUIImage = [[GPUImageUIElement alloc] initWithView:self.background];

        GPUImageFastBlurFilter *fastBlur = [[GPUImageFastBlurFilter alloc] init];
        fastBlur.blurSize = 0.5;
        [self.backgroundUIImage addTarget:fastBlur];
        [self.backgroundUIImage update];

    }

    [self.backgroundUIImage update];

    NSLog(@"image : %@",[self.backgroundUIImage imageFromCurrentlyProcessedOutput]);

    self.finalImageView.image = [self.backgroundUIImage imageFromCurrentlyProcessedOutput];

    [self bringSubviewToFront:self.finalImageView];
编辑1

我现在已经看了FilterShowcase示例代码,因此我现在尝试实现live blur,如下所示:

NSLog(@"regenerating view");

    if (!self.backgroundUIImage) {

        GPUImageAlphaBlendFilter *blendFilter = [[GPUImageAlphaBlendFilter alloc] init];
        blendFilter.mix = 1.0;

        self.backgroundUIImage = [[GPUImageUIElement alloc] initWithView:self.background];

        NSLog(@"self.backgroundUIImage : %@",self.backgroundUIImage);

        self.filter = [[GPUImageFastBlurFilter alloc] init];
        self.filter.blurSize = 10;

        [self.filter addTarget:blendFilter];
        [self.backgroundUIImage addTarget:blendFilter];

        [blendFilter addTarget:self.finalImageView];

        __unsafe_unretained GPUImageUIElement *weakUIElementInput = self.backgroundUIImage;

        [self.filter setFrameProcessingCompletionBlock:^(GPUImageOutput * filter, CMTime frameTime){

            [weakUIElementInput update];

        }];

    }

    __unsafe_unretained GPUImageUIElement *weakUIElementInput = self.backgroundUIImage;

    [self.filter setFrameProcessingCompletionBlock:^(GPUImageOutput * filter, CMTime frameTime){

        [weakUIElementInput update];

    }];

    [self bringSubviewToFront:self.finalImageView];
@property (nonatomic, strong) GPUImageView *finalImageView;
@property (nonatomic, strong) SMBouncingBubblesBackground *background;

@property (nonatomic, strong) GPUImageUIElement *backgroundUIImage;
@property (nonatomic, strong) GPUImageFastBlurFilter *filter;
其中@properties设置如下:

NSLog(@"regenerating view");

    if (!self.backgroundUIImage) {

        GPUImageAlphaBlendFilter *blendFilter = [[GPUImageAlphaBlendFilter alloc] init];
        blendFilter.mix = 1.0;

        self.backgroundUIImage = [[GPUImageUIElement alloc] initWithView:self.background];

        NSLog(@"self.backgroundUIImage : %@",self.backgroundUIImage);

        self.filter = [[GPUImageFastBlurFilter alloc] init];
        self.filter.blurSize = 10;

        [self.filter addTarget:blendFilter];
        [self.backgroundUIImage addTarget:blendFilter];

        [blendFilter addTarget:self.finalImageView];

        __unsafe_unretained GPUImageUIElement *weakUIElementInput = self.backgroundUIImage;

        [self.filter setFrameProcessingCompletionBlock:^(GPUImageOutput * filter, CMTime frameTime){

            [weakUIElementInput update];

        }];

    }

    __unsafe_unretained GPUImageUIElement *weakUIElementInput = self.backgroundUIImage;

    [self.filter setFrameProcessingCompletionBlock:^(GPUImageOutput * filter, CMTime frameTime){

        [weakUIElementInput update];

    }];

    [self bringSubviewToFront:self.finalImageView];
@property (nonatomic, strong) GPUImageView *finalImageView;
@property (nonatomic, strong) SMBouncingBubblesBackground *background;

@property (nonatomic, strong) GPUImageUIElement *backgroundUIImage;
@property (nonatomic, strong) GPUImageFastBlurFilter *filter;
这看起来好像没有生成图像,因为我可以通过self.finalImageView看到背景视图。关于如何做到这一点的一些文档将非常棒