Motion - Area Detect
You are here: Foswiki>Motion Web>AreaDetect (09 Oct 2017, RaC)Edit Attach

Area Detect Feature

Description of Patch

This patch adds the ability to detect motion in predefined areas and execute an event immediately upon detection. The event is exectued once during an event when the center of motion is located in one of the listed areas. There are currently 9 predefined areas - numbered from 1 to 9. Just imagine the screen split into 9 equal areas like that:

Area definition:

1 2 3

4 5 6

7 8 9

Two new config options have been added:

- area_detect: Here you can list all areas where an event will be triggered upon motion detection.

- on_area_detected: The script that will be executed when there is motion in one of the above listed areas.

Installation of Patch

Download the patch file. If it is packed as a gz or tar.gz unpack it first. Then copy it to the motion source directory and issue the command (assuming the patch file is called filename_of_patch_file.diff)

patch < filename_of_patch_file.diff

Then re-build Motion and test the patch.

Change History of Patch

  • 1.0 Initial revision

Discussion and Comments


Cool feature. Thanks for that.

It has all the qualities I like.

What is the syntax for the area detect? Just a string with numbers like 1234?

-- KennethLavrsen - 05 Nov 2007

Yes, exactly. Just put any of these area numbers in a row. I'm using it to get a short accoustic alert, when the cat is waiting at the door. smile

-- JoergWeber - 05 Nov 2007

I have added this patch into SVN r248.

-- JoergWeber - 07 Nov 2007

This is great, but could there be more control over where to detect the motion? -- Maybe something along the line of the html image maps syntax and then people can use an image map generating tool?

Like say:

area_detect 1 128,132,241,179

on_area_detect 1 /bin/bash cmd

area_detect 2 68,211,35,62

on_area_detect 2 /bin/bash cmd2

-- RomanGaufman - 21 Nov 2007

You can use the %K, motion center X, %L, motion center L, %i, motion width and %J, motion height command modifiers to get out the actual motion area. It can be passed to the cmd as arguments. This modifiers can also be used on the on_picture_save command. If you are planning to do anything with the saved picture it must be there as the picture might not be saved in the on_area_detected event.

-- DagErlandsson - 21 Nov 2007

I though about many things a while, but the numbers from 1 to 9 were just simple to understand and even implement. I will most probably never implement much more complicated mehanisms, because at the end of the day a new user must be able to understand how to use this feature. The only thing I can imagine is a (single!) mask that - just like the static mask to lower sensitivity - defines the areas where a script will be executed. The code to read masks is there and the detection overhead is just one if-statement more per loop.

Since the mask needs memory, I'll definitely redesign the way we parse config options first, so that the memory can be allocated only when i's needed.

-- JoergWeber - 21 Nov 2007

I agree about the mask option for AreaDetect. For those that want to use the simple 1-9 options, can you not make it 16 areas instead (4x4)? - it could simply use a hex number; 0123456789abcdef

-- MarkFord - 09 Nov 2012

I have started playing with raspberry pi and pi camera. My pi camera gets view of the mail box, drive way and the front door all in one. What I am trying to do is, area_detect 478 (grid 4, 7, 8 contains the view of my front door) and then on_area_detected mpack -s "someone on the front door" %f email@emailPLEASENOSPAM.com

Of course, %f gonna throw error since file is not available. I'm wondering if there is a way to get the image that motion is currently working on and I can attach that to an email and send it out? Any ideas? It works like a charm if it is on_picture_save but I get 1000s of emails because of cars, people going around. thanks in advance!

-- RaC - 09 Oct 2017
Topic revision: r11 - 09 Oct 2017, RaC
Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Please do not email Kenneth for support questions (read why). Use the Support Requests page or join the Mailing List.
This website only use harmless session cookies. See Cookie Policy for details. By using this website you accept the use of these cookies.