Trying to set up a trigger for directional movement detected from a live video feed.
Currently I have cv.jit blobs detection coupled with an lkflow object that only displays movement. A bang is triggered whenever the left or right side of the video frame detects a moving form (people walking in front of the video camera). There's a separate bang for each side, left and right. The bangs send a message for each side, "L" for left and "R" for right. I then tried to use the MATCH object to logically filter the results "LR" and "RL" so that I can have a separate trigger for people who walk through the video frame left to right, and a separate trigger for people who walk through the video frame right to left. It works somewhat but it creates a glitch after the first trigger: the last letter of the previous sequence is used as the first letter of the new sequence, i.e. after "LR" bangs, it holds the "R" to use next, so that if "L" is triggered next, it bangs "RL". Here, the sequence "LRL" bangs twice, once for "LR" and once for "RL". I need it to bang only when a new two letters are given, so I introduced a dummy letter "X" hoping that it would act to clear the slate for the next sequence. Every time a two letter sequence "LR" or "RL" is banged from MATCH, it also bangs an "X" back into MATCH, so that the sequences are broken up, i.e. "LRXRLXRLXLRX..." etc. However, in execution, it only works in one way: starting with "L", an input sequence "LRLR" works, it only bangs twice, once for each sequence of "LR". But starting on "R", it doesn't work, a sequence "RLR" bangs twice times, at "RL" and at "LR" and then the sequence is "reset" to only bang for "LR" now, so a continuation starting on "R", i.e. "RLRLRL", bangs once for "RL" but then only for the following "LR"'s, starting with the very next "R". I'm not sure why it only works one way, because the logic is identical for both "LR" and "RL" type MATCH inputs.
It seems overly complicated in this written description, but if you try it in the patch it should be pretty clear.
Could anyone tell me why this is happening, suggest a way to fix it or offer a different way for me to either create a logical gate for LR/RL or a completely different way for me to get the same result for triggering separate bangs depending on horizontal blob direction?
*(Attached is the full patch "timeisafourletterword" and a patch of just the MATCH objects logic gate "matches".)