Triggering a script from a TOP change

hey there!
I’m struggling from some time to detect the change in a TOP operator to then trigger a script.
Basically, let’s consider I have a VideoDeviceIn showing my camera flow. Attached to it, I have a Cache TOP. Then I do some processing on my image (chroma key) which might take some time. Once the processing is done, I use a Select TOP to get the chroma key output. Now I want a way to detect when the Select content changed to run my script.
Here is a screen capture of the simplified version of what I have (I removed the chroma key part).
I was thinking of using the “total_cooks” value of the TOP and detect when this value changes, but I notice that it is actually cooking twice. Not very clean then…
Is there a cleaner way of doing that?
Thanks a mil guys! :smiley:
Cooks.mp4 (174 KB)