I followed the example of changing filter intensity on video camera from GPUImage2 examples, I am trying to change the filter intensity on a static image with iOS slider control, but it's not changing the intensity.
@IBOutlet weak var renderView: RenderView!
var filterContrast:ContrastAdjustment!
@IBOutlet weak var sliderContrast: UISlider!
let inputImage = UIImage(named:"WID-small.jpg")!
var picture:PictureInput!
// setting dynamic observable property.
dynamic var filterValue = 3.0 {
didSet {
filterContrast.contrast = GLfloat(filterValue)
picture.processImage()
}
}
on viewDidLayoutSubviews
picture = PictureInput(image: inputImage)
filterContrast = ContrastAdjustment();
picture --> filterContrast --> renderView
filterValue = 3; // will call did set property and call processimage from it
on Slider Update
filterValue = Double(nm);
is there any thing wrong, with this approach?
Thanks
Every time your slider value changes, you're creating a new ContrastAdjustment filter instance and attaching it to the picture. Your old filter instance is still there, and the RenderView will ignore any inputs beyond the first one that goes into it. In fact, you should have been seeing warnings on the console telling you about that fact that you're adding too many inputs to the RenderView.
Instead of creating a whole new ContrastAdjustment filter each time, simply save your contrast filter as an instance variable and adjust its contrast
property when the slider changes.