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)

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.

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.

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!