gpt4 book ai didi

ios - iOS 8 中的 GPUImage 崩溃

转载 作者:行者123 更新时间:2023-12-01 18:57:14 27 4
gpt4 key购买 nike

我已经实现了一个具有许多过滤器的过滤器工具机制。每个过滤器包含 2-3 个不同的过滤器,即我为此使用 GPUImageFilterGroup。现在,当我更新兼容 iOS 8 的 GPU 图像库时,它显示“找不到实例方法 prepareForImageCapture”并且应用程序崩溃。

enter image description here

我也尝试实现以下代码

GPUImageFilterGroup *filter = [[GPUImageFilterGroup alloc] init];

GPUImageRGBFilter *stillImageFilter1 = [[GPUImageRGBFilter alloc] init];
// [stillImageFilter1 prepareForImageCapture];

stillImageFilter1.red = 0.2;
stillImageFilter1.green = 0.8;
[stillImageFilter1 useNextFrameForImageCapture];
[(GPUImageFilterGroup *)filter addFilter:stillImageFilter1];

GPUImageVignetteFilter *stillImageFilter2 = [[GPUImageVignetteFilter alloc] init];
// [stillImageFilter1 prepareForImageCapture];
stillImageFilter2.vignetteStart = 0.32;
[stillImageFilter1 useNextFrameForImageCapture];
[(GPUImageFilterGroup *)filter addFilter:stillImageFilter2];

[stillImageFilter1 addTarget:stillImageFilter2];

[(GPUImageFilterGroup *)filter setInitialFilters:[NSArray arrayWithObject:stillImageFilter1]];
[(GPUImageFilterGroup *)filter setTerminalFilter:stillImageFilter2];

GPUImagePicture *stillImageSource = [[GPUImagePicture alloc] initWithImage:image];
[stillImageSource addTarget:(GPUImageFilterGroup *)filter];
[stillImageSource processImage];

UIImage *img = [(GPUImageFilterGroup *)filter imageFromCurrentFramebuffer];

它返回零图像。谁能告诉我正确的方法!!!

提前致谢。

最佳答案

首先,这并不是 iOS 8 的崩溃。您已经有一段时间没有更新 GPUImage 的副本了,并且几个月前在与任何 iOS 兼容性无关的更新中删除了该方法。原因解释here我将再次引用相关段落:

This does add one slight wrinkle to the interface, though, and I've changed some method names to make this clear to anyone updating their code. Because framebuffers are now transient, if you want to capture an image from one of them, you have to tag it before processing. You do this by using the -useNextFrameForImageCapture method on the filter to indicate that the next time an image is passed down the filter chain, you're going to want to hold on to that framebuffer for a little longer to grab an image out of it. -imageByFilteringImage: automatically does this for you now, and I've added another convenience method in -processImageUpToFilter:withCompletionHandler: to do this in an asynchronous manner.



如您所见, -prepareForImageCapture 已被删除,因为它在新的缓存系统中无用。

您更新的代码返回 nil 的原因是您在错误的过滤器上调用了 -useNextFrameForImageCapture。它需要在组中的终端过滤器 (stillImageFilter2) 上调用,并且只需要在调用 -processImage 之前调用一次。这意味着这个特定的帧缓冲区需要停留足够长的时间才能从中捕获图像。

老实说,您不需要上面的 GPUImageFilterGroup,因为它只会使您的过滤器链接复杂化。

关于ios - iOS 8 中的 GPUImage 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25947001/

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