Motion Detection

I hoping to make a plugin to run in vdmx to detect the amount of motion in a video stream, using a difference blend of the last two frames and then sampling the brightness of the resulting image. But im having issues with inconsistent results.

In the hope of getting to the bottom of this issue - i have rebuilt the plugin as a stand alone vuo patch that plots the output value, which is attached.
It rotates a square as a substitute input image - as this is at a constant speed i would expect a constant output value. But this value fluctuates between an expected reading and almost zero.

My guess is that my timing is off and the progression of the two comparison frames is out of sync - but being new to vuo iā€™m unsure about this.

Also there is another glitch that gives higher than expected results - this is caused by actions is other apps. Minimizing a browser for example. I guess this is causing vuo to skip a beat and results in the comparison of frames with a greater difference in time.

Iā€™m hoping this is a noob error - as i purchased vuo for this purpose and hope its capable of the task.
cheers Howie

MotionDetect_deBug.vuo (9.41 KB)

1 Like

I get a nice curve using the difference of 2 squares (see joined MotionDetect_deBug 1), but using video frames I see what you mean about skipping frames when the computer does other things (joined MotionDetect_deBug 2).

I guess resizing the movie down, to reduce hardware load is a way to go, but here Iā€™m testing it with a small macOS movie so itā€™s already small.
You can also right-click on time nodeā€™s output ports, and choose event throttling ā€œDrop Eventsā€ or ā€œEnqueue Eventsā€ and check the best results.
But Iā€™m letting the team answer more deeply about this, too technical for me ;)

EDIT : Added MotionDetect_deBug 3 with a Smooth over the resulting value.

Ā 

MotionDetect_deBug 1.vuo (8.4 KB)

MotionDetect_deBug 2.vuo (7.82 KB)

MotionDetect_deBug 3.vuo (8.33 KB)

1 Like

Brilliant the throttling on the display refresh fixes the zeros in the debug patch. I hadnā€™t tried this as the final plugin dosnā€™t render anything - but if I drive the smooth node with a throttled display refresh it does keep the output value in sync.
Still the issue of dropped frames from external influences - but iā€™m not sure that this can be fixed inside the patch.
Many Thanks.

Still the issue of dropped frames from external influences - but iā€™m not sure that this can be fixed inside the patch.

@howie, are you still running into this problem with the latest version of your composition? (Based on your recent posts, Iā€™m guessing itā€™s evolved since the conversation here.) If so, could you post that version?

Hi Jaymie _ thanks for asking about this. The issue is still present but we have learned to live with it.
The vuo patch is attached along with a VDMX project - which sends the syphon and osc controls.
If its useful to look into this from a Vuo view then it would be great to hear your thoughts but its not a pressing issue.
Let me know if things need more explanation.
cheers_ Howie

MoMo-example.zip (45.2 KB)

Hello all,
Iā€™m trying to trigger a movie recording using this motion detection patch and canā€™t figure out the event blocking process that is requiredā€¦
How do I block the events coming from the camera input from reaching the Save Images to Movie node until it receives the trigger from the detected movement?
This is what Iā€™ve been tryingā€¦

See this thread, might be useful. As far as I can tell, youā€™re doing it the same way I am.
https://community.vuo.org/t/-/6649

Your approach should be working afaict, but perhaps you might share a .vuo file (or show more of the upstream?)

As for dropped frames, you might consider just holding the last value if the frame difference is practically 0.
Iā€™ve done a bunch of experiments in this space, happy to help where I can.

As a sidenote, I think this is an example of where Save Images to Movie would be more intuitive to use with a ā€˜Recordā€™ and ā€˜Stopā€™. I know team Vuo has a philosophy on this, but this feels like a special kind of patch. :grinning: Ā 

Iā€™d also love to hear what the output (difference) is used for in your plugin? Are plugins popular/in demand? Iā€™ve done some research, but donā€™t have finger on the pulse, so to speak.

I did find the problem upstream. When the camera first sends a frame the difference calculation throws out a 1 and that was triggering a recording.
I added a couple of seconds delay when the composition starts up before it can start recording using a Measure Time and an All True so that it ignores the first trigger.

Iā€™m not sure what @Howie is using this for but I am just making a very simple ā€˜security cameraā€™ type app for myself as I wanted to identify a nocturnal animal which has burrowed next to my home.

1 Like

Looking forward to some video, then!

My Motion Triggered Video Recorder composition is attached.
Not sure itā€™s all using the best methods but itā€™s working, mostly as I want.
It saves movies to the desktop at 25fps when motion is being detected and waitā€™s 4 seconds to stop recording after the motion stops. Also sequentially names the .movs

EDIT: trying it out now with a miniDV camera as input rather than isight/facetime camera. By having a look at the number coming out of the RGB addition I was able to set the sensitivity quite accurately.

No video of the suspected rat yet as the weather has been too cold and wet. Ā 

MotionDetect_Camera 2.vuo (11.8 KB)

Hello again,
Attached a revised and improved composition. Added a couple of UI elements to choose camera input and adjust sensitivity.
The composition saves movs to whatever folder the comp is within but when I try the same with an exported app it fails to save the movies anywhere.
What is the correct shortcut URL for saving files to within the enclosing folder for use within an exported app?

Also, meet my neighbour:

Ā 

Motion Detection Video Recorder.vuo (23.4 KB)

2 Likes

Very cool! I havenā€™t looked at the composition yet, but I believe the normal path to the enclosing (parent) folder is ā€˜ā€¦/myFileā€™ (without the quotes)

However, running some tests on a sample app here shows that path doesnā€™t seem to work, instead only ā€˜myFileā€™ is working, which writes to the Desktop folder, regardless of how deeply nested my test app is. You can always write in the whole path, with ~ being the user directory. for example ā€˜~/Desktop/mySubFolder/myOtherFolder/ā€™

Found the relevant bit about relative file paths in the manual: ā€˜If the fileā€™s location doesnā€™t start with file:// or /, then itā€™s treated as a relative path. This is the option youā€™d typically want when sharing the composition with others. If running the composition on a different computer than it was created on, the file needs to exist in the same location relative to the composition (.vuo) file. If running an application exported from the composition, the file needs to exist in the Contents/Resources folder inside the application packageā€™

So I should probably add a text/URL field/ save pathā€¦ Ā 

Your composition posted about is using a path relative to the user thoughā€¦so it should be good, right? #puzzled

Youā€™re on the right track with relative paths. Use some double-dots to elevate it up out of the app bundle. Details here.

I tried every configuration of dots and dashes I could think of to no avail and opted for a drag folder option. Ā 

Could the problem be because the path is relative to the resources folder (which is two levels deeper than the .app file itself)?
ie.,

ā€¦/ā€¦/ā€¦/MyImage

1 Like

In case anyone lands here with the same question, see this more thorough answer.