Movement activates video

HumanNature's icon

Hi,
I'm trying to set up a patch that plays a video depending on the amount of movement detected. I tried looking through the cv library, no luck yet.
I just need help figuring out the basic set up.

No movement=static/black screen-no play
Little movement=cut signal or 5fps
More movement=smooth signal
MORE movement=fast forward in the video-24fps

Note that it will be connected to .mov/.avi files. No live streams.

Thanks!

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

Try this for starters. Should get you going on the movement part... no cv library required if you are just interested in amount of movement...

HumanNature's icon

MIB,
Thanks for your reply.
Unfortunately, I'm still a little lost.
I'm trying to set up an interactive installation. Basically a video will play based on the motion we make with our body coming in from a live stream (will not be displayed).

Sorry for the misunderstanding, I'm looking into the patch you sent. - thank you very much btw :)

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

as I said, it's a starting point. I am only displaying the video so you can see what happens at each step of the analysis. You certainly don't want all those pwindows in your patch. Very inefficient!!!!
I quickly hooked up jit.qt.grab and added a simple video playback thing to it. right now the amount of movement controls the rate of the video, but you could certainly do many different things...
no movement, video stops (doesn't go to black, yet); if every pixel were to be ON, the video would play back at 6 times the original speed...
Hope this clarifies things a bit more.

HumanNature's icon

OMG. You are-AWESOME!!
thank you SO MUCH MIB!

seejayjames's icon

yeah that's great---love the chain of events, very clear, thanks!

in my experience .avi files play back really clunky, .mov is probably your best bet. so when you're testing, .avi might give unexpected results (choppiness) and because you're testing movie rate, it might throw you for a loop...

HumanNature's icon

Thank you 'seejayjames' for the fyi. I will put that into consideration.

tacvalorg's icon

awesome work and help.

I had a question though, I looked at your example posted, bare with me im a rookie. I was wondering if there was a way to have the movement not play the video but stop it? Also while im here, if there was a way so to delay the time it takes for the motion to interfere with the video?

MIB's icon

have a look at the [scale] object towards the bottom of the patch. it scales the amount of movement to the rate of the video. play with those numbers and it should be easy to make the video stop when there is movement. TIP: you probably don't want to scale the movement from 0. to 1. since 1. would be every single pixel in the matrix set to ON. maybe something like [scale 0. 0.2 3. 0.] would be better. this would mean that if there is NO movement the video plays back at 3 times the speed and if 0.2 (or 20%) of the pixels are ON the video is stopped... you probably also want to [clip] your values unless you are ok with the possibility of the video running backwards if the movement is more than 0.2.

to do the delay, have a look at the objects [delay] and [pipe]. I would guess [pipe] is the one you want here since it deals with numbers and lists and [delay] only handles bangs.