我很难找到来自自定义查找表的静态图像的GPUImageLookFilter
的真实示例用法。
根据我从互联网上收集到的内容,我发现了这个提议:
// The original image that should receive the filter
GPUImagePicture *stillImageSource = [[GPUImagePicture alloc] initWithImage:self.image];
// The image containing the lookup table (LUT) like https://github.com/BradLarson/GPUImage/blob/master/framework/Resources/lookup_amatorka.png
GPUImagePicture *lookupImageSource = [[GPUImagePicture alloc] initWithImage:[UIImage imageNamed:@"LUT1.png"]];
// From now on I don't really understand what's going on
GPUImageLookupFilter *lookupFilter = [[GPUImageLookupFilter alloc] init];
[stillImageSource addTarget:lookupFilter];
[lookupImageSource addTarget:lookupFilter];
[stillImageSource useNextFrameForImageCapture];
[stillImageSource processImage];
[lookupImageSource useNextFrameForImageCapture];
[lookupImageSource processImage];
// This is always nil
UIImage *filteredimage = [lookupFilter imageFromCurrentFramebuffer];
所以如果有人可以写一个完全正常工作的例子,我会非常感激,它使用最新版本和GPUImage框架(撰写本文时为0.1.6)和/或作出解释为如何应工作。
答案 0 :(得分:3)
-useNextFrameForImageCapture
只能在您要从中提取图像的目标过滤器上调用,而不是其他内容。在上面,你在输入上调用它,而不是输出。
您需要将其修改为以下内容:
stillImageSource addTarget:lookupFilter];
[lookupImageSource addTarget:lookupFilter];
[lookupFilter useNextFrameForImageCapture];
[stillImageSource processImage];
[lookupImageSource processImage];
lookupFilter
是你从中获取UIImage的东西,因此需要通知你将要从中捕获它。通过调用processImage
上传两个GPUImagePicture来源启动处理,因此-useNextFrameForImageCapture
调用需要先于这些来源。
答案 1 :(得分:-1)
GPUImagePicture *stillImageSource = [[GPUImagePicture alloc] initWithImage:self.image];
GPUImagePicture *lookupImageSource = [[GPUImagePicture alloc] initWithImage:[UIImage imageNamed:@"LUT1.png"]];
GPUImageLookupFilter *lookupFilter = [[GPUImageLookupFilter alloc] init];
[stillImageSource addTarget:lookupFilter];
[lookupImageSource addTarget:lookupFilter];
[stillImageSource useNextFrameForImageCapture];
[stillImageSource processImage];
[lookupImageSource processImage];
UIImage *filteredimage = [lookupFilter imageFromCurrentFramebuffer];