我在实现GPUImageLookupFilter时遇到问题。
我在这行代码中出现错误:UIImage *adjustedImage = [lookupFilter imageFromCurrentFramebufferWithOrientation];

它说(错误):
"No visible @interface for 'GPUImageLookupFilter' declares the selector 'imageFromCurrentFramebufferWithOrientation'"

这是我的代码:

- (IBAction)filter1:(id)sender;
{
GPUImageLookupFilter *lookup = [[GPUImageLookupFilter alloc] init];
GPUImagePicture *stillImageSource = [[GPUImagePicture alloc] initWithImage:imgView];

GPUImagePicture *lookupImageSource = [[GPUImagePicture alloc] initWithImage:[UIImage imageNamed:@"lookup_Invert.png"]];
GPUImageLookupFilter *lookupFilter = [[GPUImageLookupFilter alloc] init];
[stillImageSource addTarget:lookupFilter];
[lookupImageSource addTarget:lookupFilter];


[stillImageSource processImage];
[lookupFilter useNextFrameForImageCapture];
[lookupImageSource processImage];

UIImage *adjustedImage = [lookupFilter imageFromCurrentFramebufferWithOrientation];
}

最佳答案

首先,请通读我在the very first page of the project上编写的文档。通过在继续学习之前阅读该书,可以省去很多麻烦。从Internet盲目复制代码不是构建应用程序的好方法。

正如我在my answer中向您指出的上一个问题中所指出的那样,框架处理帧缓冲区的方式已更改,因此您发现的许多示例代码现在已过时。为了使用查找过滤器处理静止图像,您需要在触发上述-useNextFrameForImageCapture之前,立即将-processImage发送到查找过滤器。 -processImage会导致初始图像通过链接的滤镜操作进行级联,并且您需要告诉最终滤镜,您将在触发该处理之前从中提取图像。

完成后,您可以使用-imageFromCurrentFramebuffer-imageFromCurrentFramebufferWithOrientation:提取图像(请注意后者中的参数,因为上面的代码无法编译)。

同样,请在继续进行之前,阅读我在GPUImage的GitHub存储库首页上链接的资源以及我以前的回答。您确实应该了解它是如何工作的,这就是为什么我不向您提供此处需要的代码的原因。

关于ios - 如果插入此函数-imageFromCurrentFramebufferWithOrientation-(GPUImageLookupFilter),则会收到错误消息,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23173213/

10-12 03:08