Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Live filtering with slider #78

Open
agruchala opened this issue Dec 21, 2020 · 4 comments
Open

Live filtering with slider #78

agruchala opened this issue Dec 21, 2020 · 4 comments

Comments

@agruchala
Copy link

Is there an option to change filter values in fly, with slider or other control?

@Silence-GitHub
Copy link
Owner

For camera and video, just change the filter value.

contrastFilter.contrast = slider.value

For static image, change the filter value and transmit texture.

contrastFilter.contrast = slider.value
imageSource.transmitTexture()

@niraj547
Copy link

niraj547 commented Feb 15, 2021

Hi
It's not working, what I was doing wrong??

@objc func sliderValueDidChange(_ sender:UISlider!){
        let roundedStepValue = Float(round(sender.value / step) * step)
        sender.value = roundedStepValue
       
        var contrastFilter = BBMetalContrastFilter(contrast: roundedStepValue)
        contrastFilter.contrast = roundedStepValue
        
        if let filter = self.filter {
           camera.add(consumer: filter).add(consumer: filterView)
            filter.add(consumer: videoWriter)
            if let source = imageSource {
                camera.willTransmitTexture = { [weak self] _, _ in
                    guard self != nil else { return }
                    source.transmitTexture()
                }
                source.add(consumer: filter)
            }

        } else {
            camera.add(consumer: filterView)
            camera.willTransmitTexture = nil
            imageSource = nil
            camera.add(consumer: videoWriter)
         
        }
        
    }

@Silence-GitHub
Copy link
Owner

@niraj547 Hi, the problem is the contrastFilter (local variable) is not in the filter chain.

Set up filter chain before changing the slider value. When changing the slider value, do not change the filter chain. Please try the code below.

// Call this function before changing the slider value
func setupFilterChain() {
    if let filter = self.filter {
        camera.add(consumer: filter).add(consumer: filterView)
        ...
    } else {
        camera.add(consumer: filterView)
        ...
    }
}

@objc func sliderValueDidChange(_ sender:UISlider!) {
    self.filter.contrast = ...
}

@niraj547
Copy link

Hi
It doesn't work and also I think I have multiple filter buttons and each of them has a slider, doing this freeze the whole screen that might be the reason?

Also 1 quick question
can we chain multiple filters in a single video recording or do I have to join all the video after each filter has been applied??
For example: filter1 applied 32sec + filter2 applied 32sec = final Video something like this

Sorry for asking a dumb question, I'm really new in ios
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants