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.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.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.