ArchDoco - Document Archival Motion Detection Script for CHDK


This script is intended for document archiving.
The camera waits for a motion event such as turning a page in a book, then snaps a photo.

Click here to download the script: ArchDoco.bas

All settings are adjustable as script parameters so you can set your
timing requirements without altering the program.
Read the script itself for details on these parameters.

These default settings correspond to my particular physical setup:


(click the image for a larger copy - video available upon request)

It takes about 1-2 seconds to remove the page and center the new page.
The camera waits until it has seen 2 contiguous motions (Actions)
in a minimum of 1.5 seconds (ActionWindow). 
Actions are checked at intervals of 350 msecs (ActionRez).

Note: The script doesn't run during saving & photo review.
Be sure to disable or set the standard option for photo review accordingly,

I stop all motion for 2.0 seconds (IdleTimeout) and the camera takes the photo.
The process repeats, waiting for a new page.

*Shooting is disabled in debug modes above 1
You can easily change "if t<2 then shoot" at end of script.
LogMode parameter is just an argument to the "print_screen" call. See \CHDK\LOGS

By using the "shoot" command I allow the camera to autofocus for every photo.
This takes some extra time and could be avoided.
1. You could set your camera to manual mode and run the script normally?
2. You could modify the script to half-press the shutter at the start of the script
   and from then on to take photos press full shutter and release back to half shutter.
   (I bet this uses a ton of battery power)
3. Use the remote cable and forget scripts. http://chdk.wikia.com/wiki/USB_Remote_Cable
4. You could just not care and use the script as-is, like me :)

*I built this script from:
*Fudgey's Fast/Slow/Video Motion Detector with masks.
*See MDFB-080914.txt for documentation.
*Trunk autobuild 509 or higher (or compatible) required.

Motion documentation culled from http://chdk.wikia.com/wiki/UBASIC/TutorialScratchpad

md_detect_motion a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p

a COLUMNS to split picture into
b ROWS to split picture into
c MEASURE MODE (Y,U,V R,G,B) - U=0, Y=1, V=2, R=3, G=4, B=5
d TIMEOUT
e COMPARISON INTERVAL (msec)
f THRESHOLD ( difference in cell to trigger detection)
g DRAW GRID (0-no, 1-yes)
h RETURN VARIABLE number of cells with motion detected

OPTIONAL PARAMETERS:

i REGION (masking) mode: 0-no regions, 1-include,2-exclude
j REGION FIRST COLUMN
k REGION FIRST ROW
l REGION LAST COLUM
m REGION LAST ROW
 
n PARAMETERS: 
    1-make immediate shoot,
    2-log debug information into file,
    4-dump liveview image from RAM to a file,
    8-on immediate shoot, don't release shutter.
    OR-ed values are accepted, e.g. use 9 for immediate shoot & don't release shutter
 
o PIXELS STEP - Speed vs. Accuracy adjustments (1-use every pixel,2-use every second pixel, etc)
p MILLISECONDS DELAY to begin triggering - can be useful for calibration with DRAW-GRID option.


References:
CHDK Forum Thread for this script: http://chdk.setepontos.com/index.php/topic,2650.0.html
CHDK: http://chdk.wikia.com/wiki/CHDK
CHDK SX210IS Porting Thread: http://chdk.setepontos.com/index.php?topic=5045.0
Motion documentation: http://chdk.wikia.com/wiki/UBASIC/TutorialScratchpad#MX3.27s_Motion_Detection_Build
CHDK Scripts Forum http://chdk.setepontos.com/index.php/board,7.0.html
e . c

Revision History:
Revised 29 Oct 2012
commented out the check for video record as it prevented the script from running on sx210is

Created 19 Nov 2008

Copyright © 2012 By Sean McLaughlin All Rights Reserved.

Email: archdoco@seanster.com

http://www.seanster.com/archdoco/

//End of File