Motion-detection feature by 'MX3'

Max Sagaydachny (aka 'MX3') has developed a motion-detection version of CHDK that, for convenience, has been merged into this version of SDM.

(You may contact Max at win dot drivers at gmail dot com).

This very powerful feature allows a script to detect whether a defined amount-of-change has occurred in a particular area of the image (or the entire image) in a certain time.

Combined with SDM's script commands for operating the camera's LED's, it allows for external devices to be actuated, as well as capturing the image.

A number of motion-detection scripts are included with the SDM download, cameras with a separate Video button use their own version.
As from SDM 1.82, the motion-detector command now has an option to display the location of the monitored points.
The points may be as closely-spaced as ten pixels and up to 1,000 in number.
Fudgey's motion-detection script now has a parameter to turn-on this option and also to display or hide the overlay cell grid.
It has been renamed MD_SDM.bas and is in the Scripts folder of the download.

Disable Synch mode before using those scripts

(the quick way to do that is to directly press the shutter button and take a photo).

You are also advised to make sure that flash is turned-off.
There is an option in the script parameters to run in Test mode so that no photos are taken.

At first glance, the parameters for the motion-detection script appear numerous but are really straightforward.

A description of the original MX3 commands may be found in the WIKI.

Readme text files are provided in the SCRIPTS folder.
Referring to the 'md_detect_motion' command-parameters in the WIKI article, 'a' and 'b' define the number of rows and columns to split the screen into.
(If values less than zero are entered or if total number of cells is greater than 1024, it defaults to 3 x 3.)

Parameter 'g' determines if the a grid showing the detected cells is displayed.

Parameters 'j,k,l,m' define a sub-area of the screen where motion-detection is restricted-to or excluded-from.

Parameter 'i' determines if the region is inclusion/exclusion or do not use regions.

You may detect motion based on changes of luminance (Y), blue – luminance (U), red – luminance (V) or individual R, G or B values.

Parameter 'c' sets that mode.

( For an example of an image split into it's YUV components, see this WIKI article. )

For non-specialised use, luminance (c = 1) will be used.

You then need to set a threshold-value (in parameter 'f') for the desired mode that will not result in triggering in 'normal' operation.

The motion-detection event may be triggered by quick or slow changes in the screen image, set a suitable value with parameter 'e'.

The greatest accuracy of movement-detection results when every pixel is sampled but a faster response (suitable for some applications) may be obtained with a larger pixel-step.

Set an appropriate value in parameter 'o'.

Set a maximum-time for a motion-detection event to occur with parameter 'd' so that after that time the script-command terminates.