Giter VIP home page Giter VIP logo

Comments (8)

zubco avatar zubco commented on May 30, 2024 1

@0x6368
Hi, your question is same as #85.
Somewhere in your getCurrentFilter() method, you should have smth like: previousFilter.removeAllTargets().
Cheers 😄

from gpuimage2.

BradLarson avatar BradLarson commented on May 30, 2024 1

@0x6368 - Before attaching a new filter to previewView, you have to make sure the old one has been removed from it. Otherwise, it will remain the only input to that view, and trying to add any additional inputs will be rejected. A view can only have one input at a time.

from gpuimage2.

joshbernfeld avatar joshbernfeld commented on May 30, 2024 1
func removeAllTargets(rootTarget: ImageSource) {
    //Only this type of iterator is supported for TargetContainer
    for (target, _) in rootTarget.targets {
        //Can this target also have targets of its own?
        if let target = target as? ImageSource {
            self.removeAllTargets(rootTarget: target)
        }
    }
    rootTarget.removeAllTargets()
}

Thanks @0x6368. Here is the recursive solution if you have more than one item in your pipeline. Pass in your camera as the rootTarget.

from gpuimage2.

BradLarson avatar BradLarson commented on May 30, 2024

Yes, that should be the same between the two.

from gpuimage2.

andrewabdalla avatar andrewabdalla commented on May 30, 2024

Once I perform .removeAllTargets the camera completely freezes. What am I missing?
This is what I have:

let sat1 = ToonFilter()
camera?.removeAllTargets()
camera! --> sat1 --> renderView

Thank you!

from gpuimage2.

BradLarson avatar BradLarson commented on May 30, 2024

Is your camera going directly to the renderView, or is there another operation between there and the view? If so, you'll need to remove the targets of the thing that is currently targeted at the view. The view can only take one input at a time.

The old framework let you do this, which lead to bizarre image corruption and flickering if you weren't careful. You should be seeing warnings on the console about trying to add too many inputs to the view, if that's the case.

from gpuimage2.

0x6368 avatar 0x6368 commented on May 30, 2024

Hi Brad,

I have the same problem. I initialize the view with
camera = try Camera(sessionPreset:AVCaptureSessionPreset1280x720)
camera --> getCurrentFilter() --> previewView
camera.logFPS = true
camera.startCapture()

Once I call the function to get a new filter, the previewView freezes.
camera.removeAllTargets()
camera --> getCurrentFilter() --> previewView

As you noted in the previous comment, I have to

remove the targets of the thing that is currently targeted at the view

which is in my case the targets of camera, right? But I removed them by calling camera.removeAllTargets(). I don't get any warnings in the console either.

Any idea on what the problem could be?

from gpuimage2.

0x6368 avatar 0x6368 commented on May 30, 2024

@zubco @BradLarson Thank you guys, fixed it by adding this in front of the removal of the targets from the camera:

for (target, _) in camera.targets {
    if (target is BasicOperation) {
        (target as! BasicOperation).removeAllTargets()
    }
}

I think this issue can be closed.

from gpuimage2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.