CHDK Wiki
(Added Digic 4 G12)
 
(One intermediate revision by one other user not shown)
Line 4: Line 4:
 
:'''Also works on:''' PowerShot S3
 
:'''Also works on:''' PowerShot S3
 
:'''Required CHDK build:''' (unknown, built on AllBest #50)
 
:'''Required CHDK build:''' (unknown, built on AllBest #50)
:''Problems:'' Parsing Error on S3 using v0.8.3 (#593, latest of Nov 26, 2008) - works perfectly fine on my s3is with #593 [[Special:Contributions/85.178.114.198|85.178.114.198]] 11:19, 26 November 2008 (UTC)
+
[[Special:Contributions/85.178.114.198|85.178.114.198]] 11:19, 26 November 2008 (UTC)
   
This script adds bracketing and EV correction features. It is inspired by other bracketing scripts but does not depend on the camera menu layout and so should work with a large variety of camera models. It provides a menu for parameters settings and has been optimized for speed.
+
This script adds bracketing and EV correction features. It is inspired by other bracketing scripts but does not depend on the camera menu layout and so should work with a large variety of camera models. It provides a menu for parameters settings and has been optimized for speed.
   
 
'''Documentation/Help''' (save as a small "Bracketing.txt" file to your /CHDK/SCRIPTS/ folder)
 
'''Documentation/Help''' (save as a small "Bracketing.txt" file to your /CHDK/SCRIPTS/ folder)
Line 22: Line 22:
 
</pre>
 
</pre>
   
First, make focus by half pressing the shoot button, then run the script. A menu appears and let you modify the parameters' values (unfortunately they are not saved when the script ends, but initial parameters can be set via the CHDK script menu):
+
First, make focus by half pressing the shoot button, then run the script. A menu appears and let you modify the parameters' values (unfortunately they are not saved when the script ends, but initial parameters can be set via the CHDK script menu):
 
*<code>up</code> key selects previous parameter
 
*<code>up</code> key selects previous parameter
 
*<code>down</code> key selects next parameter
 
*<code>down</code> key selects next parameter
Line 32: Line 32:
 
'''Script Code''' (save as "Bracketing.bas" to your /CHDK/SCRIPTS/ folder)
 
'''Script Code''' (save as "Bracketing.bas" to your /CHDK/SCRIPTS/ folder)
   
This is written for Digic II processors, for Digic III change <code>get_prop 205 p</code> into <code>get_prop 206 p</code> (it appears twice) and all set_prop commands changed from <code>set_prop 25</code> and <code>set_prop 26</code> to <code>set_prop 107</code> and <code>set_prop 207</code> respectively.
+
This is written for Digic II processors, for Digic III change <code>get_prop 205 p</code> into <code>get_prop 206 p</code> (it appears twice). If you have the Digic IV (Canon G12 etc) this needs to be get_prop 210 and all set_prop commands changed from <code>set_prop 25</code> and <code>set_prop 26</code> to <code>set_prop 107</code> and <code>set_prop 207</code> respectively.
   
This script is written for AllBest build #50 but it shouldn't use special functions and so it may work with others. The CHDK forum has a [http://chdk.setepontos.com/index.php/topic,1068.0.html/ topic] for comments.
+
This script is written for AllBest build #50 but it shouldn't use special functions and so it may work with others. The CHDK forum has a [http://chdk.setepontos.com/index.php/topic,1068.0.html/ topic] for comments.
   
 
More comments on the code below.
 
More comments on the code below.
Line 127: Line 127:
 
</pre>
 
</pre>
   
The script uses EV correction properties. Save initial EV corrections so they can be restored when script ends. Save both separately even if they should be equal.
+
The script uses EV correction properties. Save initial EV corrections so they can be restored when script ends. Save both separately even if they should be equal.
 
<pre>
 
<pre>
 
get_prop 25 w
 
get_prop 25 w
Line 177: Line 177:
 
</pre>
 
</pre>
   
Print menu. As mini console is 5 row high, first line is blank so the last line from previous menu is not shown. Maybe something better could be done for EV printing (<code>-1 -1/3</code> is not very nice). <code>print</code> arguments do not need to be separated by commas. A comma adds an extra space character between the arguments, otherwise arguments are concatenated. Thanks to Jucifer for this [http://chdk.setepontos.com/index.php/topic,1068.msg9470.html#msg9470 tip].
+
Print menu. As mini console is 5 row high, first line is blank so the last line from previous menu is not shown. Maybe something better could be done for EV printing (<code>-1 -1/3</code> is not very nice). <code>print</code> arguments do not need to be separated by commas. A comma adds an extra space character between the arguments, otherwise arguments are concatenated. Thanks to Jucifer for this [http://chdk.setepontos.com/index.php/topic,1068.msg9470.html#msg9470 tip].
 
<pre>
 
<pre>
 
print ""
 
print ""
Line 209: Line 209:
 
</pre>
 
</pre>
   
Calculate initial underexposed EV correction. ⅓ EV is 32 property steps.
+
Calculate initial underexposed EV correction. ⅓ EV is 32 property steps.
 
<pre>
 
<pre>
 
let d=c*32-a*b*32
 
let d=c*32-a*b*32
Line 219: Line 219:
 
</pre>
 
</pre>
   
Set EV correction. Using properties avoid having to depend on menu layout and clicks. It's also quicker.
+
Set EV correction. Using properties avoid having to depend on menu layout and clicks. It's also quicker.
 
<pre>
 
<pre>
 
set_prop 25 d
 
set_prop 25 d
Line 226: Line 226:
 
</pre>
 
</pre>
   
Wait for the camera to be ready for next shoot (change <code>205</code> to <code>206</code> for Digic III processors). Also putting this just before shoot should be the quickest solution as all calculations are terminated at this time.
+
Wait for the camera to be ready for next shoot (change <code>205</code> to <code>206</code> for Digic III processors). Also putting this just before shoot should be the quickest solution as all calculations are terminated at this time.
 
<pre>
 
<pre>
 
do
 
do
Line 233: Line 233:
 
</pre>
 
</pre>
   
Shoot. Use <code>shoot_full</code> so focus and exposure are not modified between shots. It's also quicker than a <code>shoot</code> command.
+
Shoot. Use <code>shoot_full</code> so focus and exposure are not modified between shots. It's also quicker than a <code>shoot</code> command.
 
<pre>
 
<pre>
 
press "shoot_full"
 
press "shoot_full"

Latest revision as of 12:20, 13 November 2011

Bracketing and EV correction

Written for/on: Ixus 800 IS (SD 700) (Digic II)
Also works on: PowerShot S3
Required CHDK build: (unknown, built on AllBest #50)
85.178.114.198 11:19, 26 November 2008 (UTC)

This script adds bracketing and EV correction features. It is inspired by other bracketing scripts but does not depend on the camera menu layout and so should work with a large variety of camera models. It provides a menu for parameters settings and has been optimized for speed.

Documentation/Help (save as a small "Bracketing.txt" file to your /CHDK/SCRIPTS/ folder)

Parameters:
  a: number of images over/underexposed
  b: step size in 1/3 EV
  c: EV correction in 1/3 EV
Run script, menu appears:
  up, down   : select parameter
  left, right: change parameter value
  set        : shoot
  display    : exit

First, make focus by half pressing the shoot button, then run the script. A menu appears and let you modify the parameters' values (unfortunately they are not saved when the script ends, but initial parameters can be set via the CHDK script menu):

  • up key selects previous parameter
  • down key selects next parameter
  • left key decreases the value of the selected parameter
  • right key increases the value of the selected parameter
  • set takes pictures and comes back to the menu
  • display exits the script without taking pictures

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

This is written for Digic II processors, for Digic III change get_prop 205 p into get_prop 206 p (it appears twice). If you have the Digic IV (Canon G12 etc) this needs to be get_prop 210 and all set_prop commands changed from set_prop 25 and set_prop 26 to set_prop 107 and set_prop 207 respectively.

This script is written for AllBest build #50 but it shouldn't use special functions and so it may work with others. The CHDK forum has a topic for comments.

More comments on the code below.

@title Bracketing
@param a (Number images-1)/2   1..12
@default a 3
@param b Step size  (1/3 EV)   1..12
@default b 2
@param c Correction (1/3 EV) -12..12
@default c 0

get_prop 25 w
get_prop 26 x

let y=1

do
  let z=0

  do
    if a<1   then let a=1
    if a>12  then let a=12
    if b<1   then let b=1
    if b>12  then let b=12
    if c<-12 then let c=-12
    if c>12  then let c=12
    if y<1 then y=3
    if y>3 then y=1

    print ""
    if y=1 then print "Num : <" 2*a+1 ">"     else print "Num :  " 2*a+1
    if y=2 then print "Step: <" b/3,b%3 "/3>" else print "Step:  " b/3,b%3 "/3"
    if y=3 then print "Corr: <" c/3,c%3 "/3>" else print "Corr:  " c/3,c%3 "/3"
    print "[Set]=shoot [Disp]=exit"

    wait_click
    if is_key "up"   then let y=y-1
    if is_key "down" then let y=y+1
    if y=1 and is_key "left"  then let a=a-1
    if y=2 and is_key "left"  then let b=b-1
    if y=3 and is_key "left"  then let c=c-1
    if y=1 and is_key "right" then let a=a+1
    if y=2 and is_key "right" then let b=b+1
    if y=3 and is_key "right" then let c=c+1
    if is_key "set"     then z=1
    if is_key "display" then z=2
  until z>0
  if z=2 then goto "exit1"

  let d=c*32-a*b*32

  for s=1 to 2*a+1
    set_prop 25 d
    set_prop 26 d
    print "Shoot at",d/96,(d/32)%3 "/3"
    do
      get_prop 205 p
    until p=0
    press "shoot_full"
    do
      get_prop 205 p
    until p=1
    release "shoot_full"
    let d=d+b*32
  next s
 
  :exit1
until z=2

set_prop 25 w
set_prop 26 x

end

There is no remark to speed up the scripts so here are the comments:

Script title and parameters for CHDK script menu:

  • a: number of images over/underexposed, so 2×a+1 pictures are taken.
  • b: step size in ⅓ EV.
  • c: EV correction in ⅓ EV.
@title Bracketing
@param a (Number images-1)/2   1..12
@default a 3
@param b Step size  (1/3 EV)   1..12
@default b 2
@param c Correction (1/3 EV) -12..12
@default c 0

The script uses EV correction properties. Save initial EV corrections so they can be restored when script ends. Save both separately even if they should be equal.

get_prop 25 w
get_prop 26 x

Initialize menu line counter.

let y=1

Main loop.

do

Reset menu exit code:

  • 0: stay in menu (neither set nor display was pressed).
  • 1: shoot and come back to menu (set was pressed).
  • 2: don't shoot and exit (display was pressed).
  let z=0

Menu loop.

  do

Check parameters' values (maybe it could be more flexible as taking a -5⅓ EV picture is feasible):

  • a: at least 1 over/underexposed image, 12 maximum.
  • b: at least ⅓ EV step, 4 EV maximum, in ⅓ EV.
  • c: -4 to +4 EV correction, in ⅓ EV.
    if a<1   then let a=1
    if a>12  then let a=12
    if b<1   then let b=1
    if b>12  then let b=12
    if c<-12 then let c=-12
    if c>12  then let c=12

Check menu line:

  • last line is previous for first one.
  • first line is next for last one.
    if y<1 then y=3
    if y>3 then y=1

Print menu. As mini console is 5 row high, first line is blank so the last line from previous menu is not shown. Maybe something better could be done for EV printing (-1 -1/3 is not very nice). print arguments do not need to be separated by commas. A comma adds an extra space character between the arguments, otherwise arguments are concatenated. Thanks to Jucifer for this tip.

    print ""
    if y=1 then print "Num : <" 2*a+1 ">"     else print "Num :  " 2*a+1
    if y=2 then print "Step: <" b/3,b%3 "/3>" else print "Step:  " b/3,b%3 "/3"
    if y=3 then print "Corr: <" c/3,c%3 "/3>" else print "Corr:  " c/3,c%3 "/3"
    print "[Set]=shoot [Disp]=exit"

Wait for key press and process it:

  • up key selects previous parameter.
  • down key selects next parameter.
  • left key decreases the value of the selected parameter.
  • right key increases the value of the selected parameter.
  • set takes pictures and comes back to the menu (z=1 to exit menu loop).
  • display exits the script without taking pictures (z=2 to exit menu loop and jump to the end of main loop).
    wait_click
    if is_key "up"   then let y=y-1
    if is_key "down" then let y=y+1
    if y=1 and is_key "left"  then let a=a-1
    if y=2 and is_key "left"  then let b=b-1
    if y=3 and is_key "left"  then let c=c-1
    if y=1 and is_key "right" then let a=a+1
    if y=2 and is_key "right" then let b=b+1
    if y=3 and is_key "right" then let c=c+1
    if is_key "set"     then z=1
    if is_key "display" then z=2
  until z>0
  if z=2 then goto "exit1"

Calculate initial underexposed EV correction. ⅓ EV is 32 property steps.

  let d=c*32-a*b*32

Shoot loop. a underexposed, 1 correctly exposed and a overexposed pictures are 2×a+1.

  for s=1 to 2*a+1

Set EV correction. Using properties avoid having to depend on menu layout and clicks. It's also quicker.

    set_prop 25 d
    set_prop 26 d
    print "Shoot at",d/96,(d/32)%3,"/3"

Wait for the camera to be ready for next shoot (change 205 to 206 for Digic III processors). Also putting this just before shoot should be the quickest solution as all calculations are terminated at this time.

    do
      get_prop 205 p
    until p=0

Shoot. Use shoot_full so focus and exposure are not modified between shots. It's also quicker than a shoot command.

    press "shoot_full"

Wait for camera to be really shooting (change 205 to 206 for Digic III processors).

    do
      get_prop 205 p
    until p=1

Prepare for next shoot, release shoot button and add one bracketing step.

    release "shoot_full"
    let d=d+b*32
  next s

End of main loop, exit if display was selected from the menu.

  :exit1
until z=2

Restore initial EV correction values and exit.

set_prop 25 w
set_prop 26 x

end

--Nicolas bertolissio