Motion Detect Video Record a movie when motion is detected.

Introduction

The purpose of this script is to record a movie when motion is detected. The screen will be divided into a number of Rows and Columns. The Treshold value determines the treshold for detection. Recommended experimental values are 10=Lightning, 12=Sunshine, 24=Cloudy, 36=Dawn/Dusk. Motion can be detected in the following Modes: 0=U, 1=Y, 2=V, 3=R, 4=G, 5=B. The Pixel Blocksize determines how many pixels are seen as one block. Smaller blocks are more accurate but detection will be slower. The Triggering Delay value should be big enough to avoid shoot-looping after first detection. A value of at least 16 (=1.6 secs) will be ok. The Video Length can be specified in minutes and seconds.

If you want to motion-detect for longer periods, you should disable the power-save options of your camera, so that your camera will not power-off after a certain time. This can be done in the <ALT> menu. In the Miscellaneous Stuff menu item set the Disable LCD Off value to Script, so the display won't turn off while in <ALT> mode or while a script is running.

Written for: Canon A640
Also works on: Other Canon AXXX (Not tested), A590 (tested OK), A620 (tested OK), SD300 (tested OK)


Parameters (Save as "MDVideo.txt" file to your /CHDK/SCRIPTS/ folder)

Select Movie mode on your Canon A640.

  • Number Of Columns (Default=6)
  • Number Of Rows (Default=4)
  • Treshold (0-255) (Default=24) recommended values: 10=Lightning, 12=Sunshine, 24=Cloudy, 36=Dawn/Dusk
  • Comparison Interval (mSec) (Default=1)
  • Triggering Delay (.1 Sec) (Default=0) recommended values: 0=Ultrafast(Lightning), 16=Normal, 32=Slow
  • Pixel BlockSize (Default=8) number of pixels as one block (smaller size is more accurate but slower)
  • Detection Mode (Default=1) values: 0=U, 1=Y, 2=V, 3=R, 4=G, 5=B
  • Initial Delay (Sec) (Default=1)
  • Video length (Min) (Default=0)
  • Video length (Sec) (Default=10)

Script Code (save as "MDVideo.bas" to your /CHDK/SCRIPTS/ folder)

rem Johan Van Barel 02-04-2008
rem Motion Detect Video for Canon A640

@title MD Video

@param m Video Length (Min) 
@default m 0
@param s Video Length (Sec) 
@default s 10

@param a Cols
@default a 6
@param b Rows
@default b 4
rem Treshold: 10=Lightning, 12=Sunshine, 
rem Treshold: 24=Cloudy, 36=Dawn/Dusk
@param c Threshold (0-255)
@default c 24
@param d Interval (mSec)
@default d 1
@param e Delay (.1 Sec)
@default e 16
@param f BlockSize
@default f 8
@param g Mode(U=0,Y=1,V=2)
@default g 1
@param h Initial Delay (Sec)
@default h 1


if m<0 then m=0
if s<0 then s=0
if a<1 then a=1
if b<1 then b=1
if c<0 then c=0
if e<1 then e=1
if f<1 then f=1
if g<0 then g=0
if g>5 then g=5
if h<0 then h=0

l=60000*m+1000*s
if l<1000 then l=1000

e=e*100

sleep h*1000

rem time in msecs md will detect
x=5000

i=0
rem click "shoot_full"

while 1
    t=0
    md_detect_motion a,b,g,x,d,c,1,t,0,1,1,a,b,0,f,e
    if t>0 then
        i=i+1 
        print "Video", i, "(blocks="; t; ")"
        click "shoot_full"
        sleep l
        click "shoot_full"
    endif
wend

Download and Installation

This script is freeware. Before you can install it, you need to download and install the CHDK Firmware Extension for your specific Canon camera. CHDK is freeware and can be downloaded for a broad range of Canon PowerShot and Digital Ixus cameras here. If you own a Canon A640, you can download a specific build here, which already contains all the CHDK scripts from this site, including the one mentioned above. Copy all the files in this archive to the root of your SD card. If you have problems installing CHDK, please refer to the CHDK Wiki Pages.


Disclaimer

This software and the accompanying files are supplied "as is", without any express or implied warranty. In no event shall the author be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages from the use of this software. By using this software you agree with these conditions.

Copyright © 2008 by Johan Van Barel. All Rights Reserved