Canon SX30 - Motion Detection Script for Continuous Shooting - Problems - Script Writing - CHDK Forum

Canon SX30 - Motion Detection Script for Continuous Shooting - Problems

  • 2 Replies
  • 4205 Views
Advertisements
Hi,

I'm trying to get motion detection to work on my SX30 and and trigger continuous shooting for 7 shots.

I'm using the latest CHDK firmware.

I have the camera set to continuous shooting - I'm running on custom settings C1.

I'm running CHDK auto Iso as well.

I'm trying to adapt the following md universal.bas script for my SX30 (SEE BELOW).

I had to make some changes to the script using:

http://chdk.wikia.com/wiki/PropertyCase

When I run get_prop 102 y => it returns a state of 1, which indicates continuous shooting with no autofocus.

I had to change the prop id from 6 to 102 to get the proper drive mode read (if it is actually necessary).

My script runs as follows:

I turn on the camera - press CHDK button to get alt appearing.

I start the script after the prop id change - I get 24 green squares and everything seems to work.

If I wave something in front of the camera the motion is detected but...  nothing...

No photo(s) are taken by the camera, green grid disappears and the camera goes to single green focus square.

It appears to go to the focus state and stops.

I have to restart the script to get the grid back again.

I want to be able to leave the camera and let it take 7 shots whenever motion is detected.

Any suggestions?

Reference script:

http://chdk.wikia.com/wiki/UBASIC/Scripts:_Universal_motion_detection

Here's the original script:

Code: [Select]
rem Author ~SuperManu~
rem For A610
rem May work on others digicII

@title MD Universal
@param a Columns
@default a 6
@param b Rows
@default b 4
rem Threshold: 10=Lightning, 12=Sunshine, 24=Cloudy, 36=Dawn/Dusk
@param c Threshold (0-255)
@default c 10
@param d Comparison Interval (mSec)
@default d 1
rem Delay: 0=Ultrafast(Lightning), 16=Normal, 32=Slow
@param e Trigger Delay (0.1 secs)
@default e 1
@param f Pixel block size
@default f 6
rem 1=luminance (Y), 0=blue – luminance (U), 2=red – luminance (V) or individual 3=Red, 4=Green or 5=Blue values
@param h Measure Mode(0-U,1-Y,2-V)
@default h 1
@param i Masking (0=No 1=Incl 2=Excl)
@default i 0
@param j Incl/Excl Cols & Rows
@default j 0
rem on A610, the camera sleeps after 3 minutes, time-out (k) of 170 seconds ovoid this
rem in the case of pre-focusing (param u), it is nice to not have to long time-out, because exposure condition may change on time
rem feel free to set up k much higher if your camera stay awake a longer time
@param k Time-out period (s)
@default k 170
rem n is the number of shoots taken in continuous mode (continuous mode has to be selected before)
@param n Continuous shoot (s)
@default n 5
rem s value: f=direct shoot, nf=shoot without refocusing, c=continuous shoot without refocus
@param s Shoot (0=f/1=nf/2=c)
@default s 1
rem u value: Pre-focus before detection 0:No, normal shoot, 1:Yes, faster (e.g. lightning storm)
@param u Pre-focus (0=No)
@default u 1
if j>a/2 then j=a/2
if j>b/2 then j=b/2
if j<0 then j=0

if s<0 then let s=0
if s>2 then let s=2
get_prop 0 x
if x=18 then let s=3
get_prop 6 y
if s<>2 and y=1 then
let s=2
else if s=2 and y<>1 then
let s=0
endif
if s=0 then let g=1 else let g=0
e=e*100
k=k*1000
print "press Shutter Button to Stop"
while 1
if x<>18 and u<>0 then gosub "make_focus"
md_detect_motion a, b, h, k, d, c, 1, t, i, j+1, j+1, a-j, b-j, g, f, e
if t>0 then print t, " cells detected"
if t=0 then gosub "awake"
if t>0 and u=0 and s=2 then gosub "make_focus"
if t>0 and s=1 then click "shoot_full"
if t>0 and s=2 then gosub "shoot_continuously"
if t>0 and s=3 then gosub "record_video"
if t>0 and x<>18 then
do
get_prop 205 p
until p<>1
let t=0
endif
wend

:make_focus
press "shoot_half"
do
   get_prop 205 p
until p=1
return

:shoot_continuously
press "shoot_full"
sleep n*1000
release "shoot_full"
return

:record_video
click "shoot_full"
sleep n*1000
click "shoot_full"
return

:awake
  release "shoot_half"
  if x<>18 and u=0 then
click "set"
click "set"
  endif
return

end

I modified it as follows to run on the SX30...

Code: [Select]
@title sx30 md
@param a Columns
@default a 6
@param b Rows
@default b 4
@param c Threshold (0-255)
@default c 15
@param d Comparison Interval (mSec)
@default d 1
@param e Trigger Delay (0.1 secs)
@default e 0
@param f Pixel block size
@default f 6
@param h Measure Mode(0-U,1-Y,2-V)
@default h 1
@param i Masking (0=No 1=Incl 2=Excl)
@default i 0
@param j Incl/Excl Cols & Rows
@default j 0
@param k Time-out period (s)
@default k 60
@param n Continuous shoot (s)
@default n 7
@param s Shoot (0=f/1=nf/2=c)
@default s 2
@param u Pre-focus (0=No)
@default u 1
if j>a/2 then j=a/2
if j>b/2 then j=b/2
if j<0 then j=0
if s<0 then let s=0
if s>2 then let s=2

CHANGES MADE BELOW...
******
get_prop 102 y
if s<>2 and y=1 then
let s=2
endif
******
CHANGES MADE ABOVE

if s=0 then let g=1 else let g=0
e=e*100
k=k*1000
print "press Shutter Button to Stop"
while 1
if x<>18 and u<>0 then gosub "make_focus"
md_detect_motion a, b, h, k, d, c, 1, t, i, j+1, j+1, a-j, b-j, g, f, e
if t>0 then print t, " cells detected"
if t=0 then gosub "awake"
if t>0 and u=0 and s=2 then gosub "make_focus"
if t>0 and s=1 then click "shoot_full"
if t>0 and s=2 then gosub "shoot_continuously"
if t>0 and s=3 then gosub "record_video"
if t>0 and x<>18 then
do
get_prop 205 p
until p<>1
let t=0
endif
wend

:make_focus
press "shoot_half"
do
   get_prop 205 p
until p=1
return

:shoot_continuously
press "shoot_full"
sleep n*1000
release "shoot_full"
return

:record_video
click "shoot_full"
sleep n*1000
click "shoot_full"
return

:awake
  release "shoot_half"
  if x<>18 and u=0 then
click "set"
click "set"
  endif
return

end

Basically

I had to make some changes to the script using:
http://chdk.wikia.com/wiki/PropertyCase
When I run get_prop 102 y => it returns a state of 1, which indicates continuous shooting with no autofocus.
I had to change the prop id from 6 to 102 to get the proper drive mode read (if it is actually necessary).
...
Any suggestions?
One problem with many of these old scripts is the use of "hard coded" ProperyCase values.   The script you are trying to use here is almost six years old - long before there were so many propset's supported. I see you corrected one of the propset values already.

Assuming you are running the script with the default @parameter values, then your problem is almost certainly here :

Code: [Select]
:make_focus
     press "shoot_half"
     do
       get_prop 205 p
     until p=1
return
Property case 205 only exists in propset1 (PROPCASE_SHOOTING).

The SX30 uses propset4 where the value for PROPCASE_SHOOTING is 210.  Try that and see if things work better?
Ported :   A1200    SD940   G10    Powershot N    G16

It works now.

I changed the property case from 205 to 210.

Thanks.

I suspected this to be the case but I didn't get a parse error so I wasn't sure.

The original script (which I now know to be quite old) gave me a parse error which I was able to find a fix for using google and google translate - found a working solution on a german forum page.

I'm new to scripting and with some searching on google I was only able to find this old script to work with chdk - no where did I find scripts for the SX30.

I've got it working now... big thanks.

I like the fact that the script detects motion, takes a bunch of photos and then resets so it's ready to trigger again... I was worried that it might only run once... but it works so no complaints.

Keep up the great work.

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal