GPUImage - ChromaKeyBlendFilter - sourceImage

169 Views Asked by At

I have an GPUImageStillCamera layered over a UIView (on which some realtime animation is happening) in which for GPUImagePicture I am passing the sourceImage with smoothlyScaleOutput:YES for ChromaKeyBlendFilter

The code works perfectly (most humble thanks to Brad Larson!) and I get a camera feed with green pixels removed where the sourceImage is shown.

What I want to do is to pass a sourceImage which could name the background transparent for the feed i.e. I don't want to show the sourceImage in background where the green pixels are removed but instead, I want that pixel to be transparent.

Here's the image from my project:enter image description here See that blurry square area in the center, I want it to be transparent so that it shows the actual background image which is absolutely clear. right now I am passing the background image separately to the filter and it is showing blurry image.

To achieve the same, I tried with passing the transparent PNG but, I got a black color background. What should I be doing to achieve the thing I am looking for? Please suggest.. Thanks!

2

There are 2 best solutions below

1
bzz On

If I understand you correctly, you want to make the background of GPUImageView transparent. As mentioned here, you can do it by setting both of the following properties:

strengthPreviewImageView.backgroundColor = [UIColor clearColor];
[strengthPreviewImageView setBackgroundColorRed:0 green:0 blue:0 alpha:0];
0
nip_magic On

You can try by setting up the filter's "thresholdSensitivity" by using UISlider.

[(GPUImageChromaKeyBlendFilter *)filter setThresholdSensitivity:[(UISlider *)sender value]];