BradLarson / GPUImage

An open source iOS framework for GPU-based image and video processing
http://www.sunsetlakesoftware.com/2012/02/12/introducing-gpuimage-framework
BSD 3-Clause "New" or "Revised" License
20.24k stars 4.62k forks source link

Issue with lookup filters #1131

Open kissfro opened 11 years ago

kissfro commented 11 years ago

I notice that when you apply Amatorka, Soft Elegance, or Miss Etikate to an GPUImagePicture, if you remove the filter, and try to readd it again later, it won't apply (nothing happens).

BradLarson commented 11 years ago

Yeah, I think there's something odd about the way that it handles the second (lookup) texture. It tends to get corrupted after using a blend somewhere else, too, so I think there's something wrong with how it handles state somewhere.

iamcam commented 11 years ago

This sounds familiar to a bug I fixed quite a while ago. Take a look at https://github.com/BradLarson/GPUImage/pull/766 to see if it gives you any clues.

kissfro commented 11 years ago

Thanks for the responses guys. I actually did take a lot at that a couple of days ago, but I'm still getting the issue with the look up filters. I have Amorteka, Elegance, and Miss Etikate in a chain with some other filters, and every time another filter changes, if I don't reinstantiate the look up filter, then it won't get applied.

kissfro commented 10 years ago

Solved this by calling [lookUpFilter prepareForImageCapture]; right before [self.filterImage processImage]; So had to figure out which and if any lookUpFilters were in my chain, then had to cycle through them and call prepareForImageCapture before applying the filter and it works (maybe this is what you were trying to say Cam). Anyways, thanks guys.

kissfro commented 10 years ago

I'm going to reopen this because the work around has become obsolete with "prepareForImageCapture" being eliminated with the new frame buffer architecture. The problem still exists with the new memory system i.e. once a look-up filter is applied, it's unable to have other filters chained on top of it.

bhr commented 10 years ago

@kissfro: Calling processImageWithCompletionHandler:(void (^)(void))completion; and processing the lookupImageFilterGroup manually in the completionHandler did the trick for me.

My setup: StillImageSource->Filter->Filter->LookupFilterGroup(LUTFilter)->Output

For clarification here the code snippet.

__weak typeof(self) weakSelf = self;
[self.stillImageSource processImageWithCompletionHandler:^{
    [weakSelf.lutFilter processImage];
}];

Hope this helps.

@BradLarson : Maybe we could note in the lookup filter tutorial?

Cheers Ben