gpt4 book ai didi

ios - 使用混合滤镜时 GPUImage 崩溃 ('over release framebuffer')

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:07:19 25 4
gpt4 key购买 nike

我很头疼,因为我在尝试将混合滤镜应用于图像并显示它时遇到崩溃。我想要做的只是将一个叠加图像放在另一个图像上。

这是我的代码:

- (GPUImageOutput<GPUImageInput> *)myFilter
{
GPUImageFilterGroup *filtersGroup = [GPUImageFilterGroup new];

// Saturation
GPUImageSaturationFilter *saturationFilter = [GPUImageSaturationFilter new];
saturationFilter.saturation = 0.0;
[filtersGroup addFilter:saturationFilter];

// Noise
UIImage *noiseImage = [UIImage imageNamed:@"noise.png"];
GPUImagePicture *noisePicture = [[GPUImagePicture alloc] initWithImage:noiseImage];
GPUImageAddBlendFilter *blend = [GPUImageAddBlendFilter new];
[blend useNextFrameForImageCapture];
[filtersGroup addFilter:blend];
[noisePicture addTarget:blend atTextureLocation:1];
[noisePicture processImage];

[saturationFilter addTarget:blend];

filtersGroup.initialFilters = @[saturationFilter];
filtersGroup.terminalFilter = blend;

return filtersGroup;
}


    // Applying filter
GPUImageOutput <GPUImageInput> *effect = [self myFilter];
self._photoHandle = [[GPUImagePicture alloc] initWithImage:staticImage];
[self._photoHandle addTarget:effect];
[effect addTarget:self.targetPreviewView];
[self._photoHandle processImage]; // Crash

当我尝试运行它时,应用程序崩溃并收到此消息:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Tried to overrelease a framebuffer, did you forget to call -useNextFrameForImageCapture before using -imageFromCurrentFramebuffer?'

我确实在混合滤镜上调用了“useNextFrameForImageCapture”,那么我的代码有什么问题吗?

最佳答案

啊,我找到了导致崩溃的原因。

请注意,我没有保留对 noisePicture 对象的任何强引用。替换:

GPUImagePicture *noisePicture

@property (nonatomic, strong) GPUImagePicture *noisePicture;
...
self.noisePicture = ...

解决了这个问题。感谢帮助! :)

关于ios - 使用混合滤镜时 GPUImage 崩溃 ('over release framebuffer'),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24395093/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com