Basic Motion Detection Questions (MD works on SD780) - General Help and Assistance on using CHDK stable releases - CHDK Forum

Basic Motion Detection Questions (MD works on SD780)

  • 7 Replies
  • 2283 Views
Basic Motion Detection Questions (MD works on SD780)
« on: 15 / March / 2011, 17:27:43 »
Advertisements
Good News - Motion Detection works on SD780....hats off those developing CHDK and MD!  Really amazing.  Thanks!

I do have a few questions...could be my lack of understanding of programming (yes!), the SD780 (relatively untested with MD?), or other items.  Here are my questions...prioritized (followed by my camera/script settings):

Questions:
1)  What settings can I change to improve response time?  It appears as though developer MX3 was able to catch multiple pictures of a toy thrown across the room - should I be able to do this with the standard Lightning Script?  I can get one picture but even the object is more than 1/2 through the screen. Additionally, I can not get any continuous photos of an object in motion.  (Possible clue to one of these problems - after a MD triggered photo, a green box appears on the preview screen - like the camera is trying to identify something.)
2)  Could someone refer a Wiki location providing a basic explanation of the settings (and possibly the script itself).  
3)  When motion triggers the shutter, I frequently get a second picture ~1 second later when there is no motion.  What may cause this?

« Last Edit: 19 / March / 2011, 14:09:20 by rdy4trvl »

Re: Basic Motion Detection Questions (MD works on SD780)
« Reply #1 on: 20 / March / 2011, 19:14:18 »
Hey, I also have a 780IS and may be able to help you a little. I'm not sure which MD script you are using but I found this one to be the fastest. I got it from this thread http://chdk.setepontos.com/index.php?topic=471.210

Code: [Select]
rem Fudgey's Fast/Slow/Video Motion Detector with masks. For models with no video button.
rem See MDFB-080914.txt for documentation.
rem Trunk autobuild 509 or higher (or compatible) required.
@title Fast MD 080914

@param a Columns
@default a 6
@param b Rows
@default b 4
@param c Threshold (0-255)
@default c 10
@param g Burst/Review/Video time (s)
@default g 0
@param d Compare Interval (ms)
@default d 7
@param h Pixel Step (pixels)
@default h 6
@param f Channel (0U,1Y,2V,3R,4G,5B)
@default f 1
@param n Timeout (10s of seconds)
@default n 30
@param e Trigger Delay (0.1 sec)
@default e 5
@param i Masking (0=No 1=Mask 2=Use)
@default i 0
@param j -      Mask Columns Left
@default j 0
@param k -      Mask Columns Right
@default k 0
@param l -      Mask Rows    Top
@default l 0
@param m -      Mask Rows    Bottom
@default m 0
@param o Shoot fast=0,slow=1,test=2
@default o 0

if a<1 then a=1
if b<1 then b=1
if i<0 then i=0
if i>2 then i=2
if j<0 then j=0
if k<0 then k=0
if l<0 then l=0
if m<0 then m=0
if j>a then j=a
if k>a then k=a
if l>b then l=b
if m>b then m=b
if g<0 then g=0
if f<0 then f=1
if f>5 then f=1
if f=0 then print "Channel: U chroma"
if f=1 then print "Channel: Luminance"
if f=2 then print "Channel: V chroma"
if f=3 then print "Channel: Red"
if f=4 then print "Channel: Green"
if f=5 then print "Channel: Blue"
if n<1 then n=1
e=e*100
g=g*1000
n=n*10000

P=get_video_button
if P=1 then goto "VideoButtonError"

P=get_mode
if P=1 then goto "PlayModeError"
rem get_mode returns 2 if a we are in video mode (and the camera has no video button)
if P=2 then p=1 else p=0

P=get_flash_mode
if P=2 then goto "SkipFlashWarning"
  print "WARNING: Flash is not"
  print "disabled. May cause  "
  print "odd behavior.        "
:SkipFlashWarning

if o=0 and p=1 then goto "fast_video_md"
if o=1 and p=1 then goto "slow_video_md"
if o=1 and p=0 then goto "slow_md"
if o=2 then goto "test_md"

print "Fast react photo MD"
:fast_md_loop
  t=0
  do
    release "shoot_half"
    press "shoot_half"
    do
      P=get_shooting
    until P=1
    md_detect_motion a, b, f, n, d, c, 1, t, i, j+1, l+1, a-k, b-m, 9, h, e
  until t>0
  let X=get_tick_count
  :contloop1
    let U=get_tick_count
    let V=(U-X)
    if V<g then goto "contloop1"
  release "shoot_full" 
  release "shoot_half"
  do
    P=get_shooting
  until P<>1
goto "fast_md_loop"

:slow_md
print "Slow react photo MD"
:slow_md_loop
  t=0
  do
    md_detect_motion a, b, f, n, d, c, 1, t, i, j+1, l+1, a-k, b-m, 0, h, e
  until t>0
  if g>0 then goto "contshoot2" else shoot
  goto "slow_md_loop"
  :contshoot2
  press "shoot_full"
  let X=get_tick_count
  :contloop2
    let U=get_tick_count
    let V=(U-X)
    if V<g then goto "contloop2"
  release "shoot_full"
  release "shoot_half"
  do
    P=get_shooting
  until P<>1
goto "slow_md_loop"

:fast_video_md
if g<1 then g=1000
print "Fast react video MD"
:fast_video_md_loop
  t=0
  do
    release "shoot_half"
    press "shoot_half"
    sleep 1000
    md_detect_motion a, b, f, n, d, c, 1, t, i, j+1, l+1, a-k, b-m, 9, h, e
  until t>0
  rem press "shoot_full" was done by md_detect_motion
  print "starting video record" 
  sleep 300
  release "shoot_full"
  let X=get_tick_count
  :fastvideowaitloop
    let U=get_tick_count
    let V=(U-X)
    if V<g then goto "fastvideowaitloop"
  click "shoot_full"
  print "ending video record"
  rem Need to wait or shoot_half won't work and loop will work like slow react loop:
  sleep 1000
goto "fast_video_md_loop"

:slow_video_md
if g<1 then g=1000
rem Focusing takes time => add a second to make length argument a bit more accurate.
g=g+1000
print "Slow react video MD"
:slow_video_md_loop
  t=0
  do
    md_detect_motion a, b, f, n, d, c, 1, t, i, j+1, l+1, a-k, b-m, 0, h, e
  until t>0
  press "shoot_full"
  sleep 300
  release "shoot_full"
  print "starting video record" 
  let X=get_tick_count
  :slowvideowaitloop
    let U=get_tick_count
    let V=(U-X)
    if V<g then goto "slowvideowaitloop"
  click "shoot_full"
  print "ending video record"
goto "slow_video_md_loop"

:test_md
  print "MD test, no shooting."
  N=0
:test_md_loop
  t=0
  do
    md_detect_motion a, b, f, n, d, c, 1, t, i, j+1, l+1, a-k, b-m, 0, h, e
  until t>0
  N=N+1
  print t, "cells, trigger ", N
goto "test_md_loop"

:PlayModeError
  print "MDFB script ERROR:"
  print "Not in REC mode, exiting."
end

:VideoButtonError
  print "MDFB script ERROR:"
  print "Incompatible camera! Try"
  print "MDFB VideoButtonModels"
  print "version."
end

« Last Edit: 20 / March / 2011, 19:18:08 by jphphotography »

Re: Basic Motion Detection Questions (MD works on SD780)
« Reply #2 on: 20 / March / 2011, 19:17:13 »
I just tried posting the text file that accompanied the script but it exceeded the 7500 character limit. If you PM me your email address I can send you the zip file with everything in it.

*

Offline reyalp

  • ******
  • 12737
Re: Basic Motion Detection Questions (MD works on SD780)
« Reply #3 on: 20 / March / 2011, 19:34:45 »
I just tried posting the text file that accompanied the script but it exceeded the 7500 character limit. If you PM me your email address I can send you the zip file with everything in it.
You should be able to add an attachment to your post. Just hit 'reply' or 'preview' from the quick reply box, and then click additional options.
Don't forget what the H stands for.


Re: Basic Motion Detection Questions (MD works on SD780)
« Reply #4 on: 20 / March / 2011, 19:45:24 »
D'oh, thanks reyalp, I didn't see an icon for attaching files so I just assumed that only mods could add files.

Here is the original zip file, note there may be an updated version here on CHDK somewhere.

Re: Basic Motion Detection Questions (MD works on SD780)
« Reply #5 on: 20 / March / 2011, 23:39:32 »
Jphphotography,
I've tried a number of the posted scripts and some scripts modified by suggestions in the forum.  However, all were about 1/4 the length of MDFB-080914.  So I tried MDFB-080914 but could only get the shutter to trigger twice within 5 seconds.  (I have Continuous photo on, and the following off: focus, flash, display photo...).  Are there any special changes in the parameters needed to get continuous pictures?  Any ideas?
Thanks for the script suggestion.

Re: Basic Motion Detection Questions (MD works on SD780)
« Reply #6 on: 21 / March / 2011, 01:44:57 »
Here is what the author says (this is in the text file I included)

 Tip:  For the highest possible burst rate (photos per second),
      * Disable RAW.
      * Use a fast shutter speed (Tv).
      * Do not use ISO 200 or higher (camera will spend time applying
        some noise reduction filtering).
      * Use a sufficiently fast SD card and keep it defragmented by
        full erase as often as you find convenient.
      * Enable the digital telephoto feature and choose the one and only
        JPEG image size for which the camera doesn't need to resize
        the photo (for a570is 1,9x digital telephoto this means 1600x1200).
        At least on the a570is the digital telephoto feature is marked
        with a "T" symbol on the LCD, and the optimum JPEG resolution
        can be found by decreasing JPEG resolution setting until the "T" symbol
        is no longer blue. Note that reducing JPEG resolution further (or
        without the digital telephoto feature) will slow down the burst
        because the camera will have to resize the image (unless your SD card
        is very slow). Your camera may not have this feature.


He also says
This script is ment to shoot quickly after something moves on the LCD.
If you also want the script to be detecting motion again as soon as possible
after taking a shot, you should:
  - use manual exposure (camera in M mode), must be set before running the
    script
  - use manual focus, must be set before running the script
  - set trigger delay to the minimum allowable in your camera in your
    shooting conditions (possibly 0)
  - set burst/review time = 0 unless you want several images in
    continous shooting drive mode
  - disable shot review from Canon's menus
  - disable noise reduction in CHDK RAW menu (if using long exposures)
  - disable RAW saving
  - use a fast, defragmented memory card

It appears that parameter g has something to do with burst mode but I'm not sure what value it requires. In the one tip section he says not to set the burst/review time = 0 if you are wanting several images in continuous drive mode. So I would try setting it to 1 and test it out, then set it to 2 and see what happens.

Obviously you'll want the trip delay set as low as possible, however too low may cause it just start triggering as soon as the script starts which is no good. Also when looking through the code that if parameter O is set to zero (fast mode, which is default) it will automatically behave as if parameter G was set to 1 initially. I don't know what that means.

It has been quite a while since I've played around with any coding in CHDK and even then it was fairly simple stuff, however looking at the script it appears to still be using the "press "shoot_half" command which is what trips the AE and AF, if you already have it pre exposed and pre focused there may be away to avoid this. I could be wrong though, as I said it has been awhile. If you're feeling brave enough you can try editing the script to remove the shoot_half commands and the sleep1000 in the fast_video_md routine. It shouldn't hurt your camera but I don't take responsibility if it does ;)

Re: Basic Motion Detection Questions (MD works on SD780)
« Reply #7 on: 21 / March / 2011, 14:38:20 »
Absolutely fantastic.  Progress!   In addition to the above, the text file (which I completely overlooked) includes great detail on other settings. (I'm in the process of review the text -12 pages in Microsoft Word...not yet to the point of catching multiple pictures of a falling toy, but found the setting preventing continuous pictures!)  Jphphotograpy, thanks for pointing this out and thanks to Fudgey for documenting!


 

Related Topics