video threshold to bang or simple number?
I’ve been trying to find a way to do simple motion detection. I was thinking that I could do somethign like the following: put the camera image through a difference effect, and then down to b&w (no greys) and then doing something as simple as adding up the white pixels in each frame and comparing that number to the number in the next frame. Assume anything under 50 pixels of white is just noise, but anything above is motion and then sending a bang do do other things with that info.
So, first question, is this a viable idea of how this could work?
2nd question, I haven’t figured out a way to get a concrete value (or bang) out of video put through some object. From the name, I thought cv.jit.threshold would do it, but it looks to be just another image processor. Is there a way to get a simple number out of that or some other object from a video source? Or is there another way I should be thinking about this?
Thanks much, Ian
one way of doing what you described:
-- Pasted Max Patch, click to expand. --Copy all of the following text. Then, in Max, select New From Clipboard.----------begin_max5_patcher---------- 1103.3oc6YEsiahCE84juBq73JJqswXC6Cil86XU0Hf3ICUfcJ3LY5V0+80X G1ISav0jPHcGsUZhCFv8bO264bwgutbwpb4K71Uf+.7WfEK95xEKLS0MwhCG uXUc1KEUYslKaUgrtlKTqBrmSweQYlWJp9BXCWAjBNHOSrAr+It.jkKelCvw PvGtSepB843Ux8cyD.ZUYM5a3YdS+xUUJ3ExcByZhOL41LUwSkhMOzvKTVrh ojP8BPQlADE0MfSCgfOd3lJWagU9m9.F1u7OJEJQVM2bp+roLqp+Lhc0khJt xDjnWmTtS0OK7nEos7uMKBBFB6l8aKW18QfmjnfuWCrefCUf7UNh4nXSLCMw LFah7jSGxnjIIjQCDxGl1dkpurkaQ3pt79JvGmNFQWLYpkPN3ETJ0vKXyPbh SdgMRdAeRdAeN7RvkvO46TJovCVH1JLv8edRVfdF0.W+jcKuxqDMzn1ivgwN RznaZhdR4k65bK+47RLiY3EpSA.bR3kwZLT14neNTRMusMaC+G3DBIzEiDAs LhwwLFZaRbZFI8lPHmGa7oRU318kh0x8tZTXr.IcsCC.IPql4zAOaDFA3Aik ytfenrqbK2oWWhoRGihLE7QtRuz+CkdUxMap3tBbaOND0jgwv9OOUfSlBO9y V2NfU1mq4pFIHB5QPlZpeicZmguIY2IuyWmt9ypvMMY459ZP.l3AAc34ASQN 86mjmCbrsA0wyC0YplxWl7lg+ttYXrauei4PbjgWHVue1.rSzUq9IcX14wJY 1zJq9M.il.g9PKPy.g3jVHuOnkNYUT8OWIQRhrkLNIk3IQJQFGoXzOAWROVG bSylbb0t5LO7Zr6vl5rrglb0LaRutdM5ROMFb8HUVeDBxt0iXWz.6b+4FzwP aQVk4xggomA4juoPVIarXFFlP0+iEbxugNB7O0UU716jAiSRBN42N9NGPDGb k5QJ2BtW+2cf6eNqRCIrGZa6VAPPpyb10a6ho2j1jcrUaU4ZN3dyvC61BH8e Wu8AA3U+rgIunzCVhINIO76Wcu8mYKhv7P2G8+59YR2i7nzkx7Q2Sdmo6UfJ PkG8ySrCLmjS7sPWeUrBOT.kk2tt7wGskQnPOphr+DCHrakO8WspHCJMuMku 6k6XB0t4eKO1J20Tzuv8u.AvqA6ZdqpTjoJkhiuHl9hPuZmTtdMWb7qJotb8 VYoPc.DCjU8FSn27e2.X5s.+piIlO7DcdwDx2b2LhInOXBMuXJxGLA+0CSoy pri4S4zLWME6iS.YdwDwmponYESTefzrhHeHI7rhH7zyQH8FEh6dE8lgiO5R qw7.qz4sAnWtCF853IPh882c7QWJZi8wKiNN+0C3KxtUCLA8uGcon0mllLz3 PKljZXS6aIraCt8Gcon0mVWca3ZN6cg8kAmQEiOdfr40DjQ8M2MiXxml7rQ9 n0HRzQZ0iUtWZqVe1vDK9BXP8Aea4+7htYXA -----------end_max5_patcher-----------
Well, I think that got me. I think this is faster and cleaner than what I was coming up with for the video processing side of things, and jit.3m was the key piece to get the data out.
For the jit.slide piece, it looks sort of like a motion blur, and seems to have effect of making fewer bangs out of the same motion instead of banging the whole time. Is that the intent of that piece?
jit.slide is simply a motion smoother, or a low pass filter for the image…it smooths out transitions between frames…it eliminates motion detection from camera noise or really small amounts of motion..try taking it out and see what you get
onebang is the object that is limiting the number of bangs you’re getting from the motion detection
Gotcha. Thank you.
Don’t know whether it’s best to reply to this or start a new post, but it’s inversely related, so I’ll follow up on this one.
I’ve been tweaking the settings and the video input into this type of setup and I’ve gotten it to work fairly well. I’m trying to do something where the LACK of motion also causes things to happen.
What I’ve been trying to do so far is take this same block of code and change out the section with the greater than (> 250) to a less than. Specifically, >150 causes a start bang, and <140 causes a stop bang, and still using the onebang to smooth things out. The start bangs seem to have no problem. However, the stop bangs don't work as well. Watching the video and the numbers, I'm getting fairly close to the values put out by noise in the system (camera, and crumblies through the processing), but the numbers do get consistently below 140. However, every once in a while I will not get a stop bang, and then the system runs on until a "more obvious" high to low situation happens, like walking through the area.
I’m not at the machine (it’s currently installed), but I’m thinking that maybe the onebang could be the problem? If I took out the onebang for the stop/"lack of motion" action, and then lowered the low number into the top of the noise range, would I get a better stop? I’d think that this could help as then the system would be more vigilant about dropping under, I’d just have to find a safe value for the stop action.
Any ideas for a better method for low/no motion detection?
hard to say without seeing the patch. onebang and < 140 should work... then again, don't know your setup or what kind of noise you are getting.
Thanks, I’ll play around a bit more. It works fairly well as is, it’s just that sometimes when a person barely grazes a detection zone, they’ll trigger the motion, but not the anti-motion. I don’t have Max on this machine or I’d post the patch.
I wonder if my initial idea of having space between the two values (>150 and <130 or whatever I have them set to right now) is sort of flawed. Maybe I should just do >150 and <150. It's either that or the < value needs to be higher.
Forums > Jitter