video threshold to bang or simple number?

v8media's icon

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

MIB's icon
Max Patch
Copy patch and select New From Clipboard in Max.

one way of doing what you described:

v8media's icon

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?

Thanks!

laserpilot's icon

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

v8media's icon

Gotcha. Thank you.

v8media's icon

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

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?

MIB's icon

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.

v8media's icon

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 150 and