I have a hard time finding a real world example usage of the GPUImageLookFilter
for still images from custom lookup tables.
From what I have gathered from around the Internet I have found this proposal:
// 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];
So I would be very grateful if some could write a fully working example, that uses the latest version og the GPUImage framework (0.1.6 as of this writing) and/or give an explanation as to how it should work.
-useNextFrameForImageCapture
is only to be called on the target filter that you're going to be extracting the image from, nothing else. In the above, you're calling that on your inputs, not your output.
You need to amend that to be something like the following:
stillImageSource addTarget:lookupFilter];
[lookupImageSource addTarget:lookupFilter];
[lookupFilter useNextFrameForImageCapture];
[stillImageSource processImage];
[lookupImageSource processImage];
lookupFilter
is what you're pulling the UIImage from, so that needs to be informed that you're going to be capturing from it. The processing is initiated by calling processImage
to upload both of your GPUImagePicture sources, so the -useNextFrameForImageCapture
call needs to come before those.