Chaining GPUImageChromaKeyBlendFilter
I started playing around with GPUImage yesterday and I am impressed. I was up using it in matter of minutes, but today I have been struggling with chaining the GPUImageChromaKeyBlendFilter filter.
currently I am doing something similar to.
[chroma1 addTarget:chroma2];
[foreground addTarget:chroma1];
[foreground processImage];
[background addTarget:chroma1];
[background processImage];
return [chroma1 imageFromCurrentlyProcessedOutput];
For one filter (only having chroma1) this technique is working but not for 2 or more.
Any ideas is much apprechiated.
Try reordering it to this:
[foreground addTarget:chroma1]; [foreground addTarget:chroma2]; [background addTarget:chroma1]; [background addTarget:chroma2]; [foreground processImage]; [background processImage];
Under the new way that I've configured the blends, this should ripple down the filter chain appropriately.
Thanks that seems to work fine and is much faster.
Another related question. It seems like the thresholdSensitivity setting responds quite differently to different colors. Red requires a very low threshold to be replaces whereas blue and green seem to be quite hard to replace and need a higher threshold.
This seems a bit odd to me, but maybe I am doing something wrong.
The color "distances" are based on Y, Cb, and Cr, and are based on a distance algorithm proposed by Apple in one of their samples. You can look at the fragment shader code to see how I calculate this. There might be a better way to calculate this, but that's what I'm using right now.
I finally got it working by doing the following:
[foreground addTarget:chroma1];
[foreground addTarget:chroma2];
[foreground processImage];
[background addTarget:chroma1];
[background processImage];
[foreground processImage];
[background addTarget:chroma2];
[background processImage];
return[chroma1 imageFromCurrentlyProcessedOutput];
Seems a bit wasteful to run processimage twice on each image. Am I doing things backwards? Is there a more effective way to do this?
(I see a pretty harsh slowdown for each new chroma filter I add).