3

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!

Saurabh Passolia
  • 8,099
  • 1
  • 26
  • 41
  • Could you please make a mockup image of what you're trying to do. I read that paragraph several times but I still can't quite make out what you're trying to do. Maybe you can make a screenshot of Debug View Hierarchy, with what you have now and what views you want to switch? – pteofil Apr 28 '15 at 12:55
  • 1
    please check the question again. i have added the screenshot – Saurabh Passolia Apr 29 '15 at 06:07
  • 1
    I am really sorry, but I can't understand what you want to achieve too. May you please rephrase question and/or add image of final result you want to achieve. – Sergey Kuryanov May 01 '15 at 20:44

2 Answers2

1

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];
Community
  • 1
  • 1
bzz
  • 5,556
  • 24
  • 26
0

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

[(GPUImageChromaKeyBlendFilter *)filter setThresholdSensitivity:[(UISlider *)sender value]];
nip_magic
  • 21
  • 3