Bracketing and EV correction script (one more) - Script Writing - CHDK Forum supplierdeeply

Bracketing and EV correction script (one more)

  • 36 Replies
  • 22752 Views
Bracketing and EV correction script (one more)
« on: 14 / April / 2008, 12:15:23 »
Advertisements
Hi,

I've just discovered CHDK yesterday in the early morning (01:00 am). It's amazing. So I tried scripts I found on the wiki pages. I'm interested in bracketing scripts for HDR. But unfortunately they didn't work on my old Ixus 800 IS (SD 700) for various reasons and mainly because different menu layout means different click sequences. I also think "sleep" commands make things very long and not very nice. And EV correction was also a missing feature for me. So I started modifying them and finally wrote the following script.
This script does not depend on menus so it should work for a large variety of cameras (even if I can only test it on my Ixus 800 IS). It's written for Allbest build #50 but I think I haven't use special functions so it may work with others. Please test it and comment. I tried to make it as quick as I could so there are neither "sleep" nor "rem" commands.
This is written for a Digic II processors, so for Digic III you have to change "get_prop 205 p" into "get_prop 206 p" (it appears twice).

There are 3 parameters :
  • a : number of image over/under exposed so 2*a+1 images are shot
  • b : step size in 1/3 EV
  • c : EV correction en 1/3 EV
When you run the script a menu appears and you can modify the parameters' values (unfortunately they are not saved when the script ends, maybe some one knows how I could save them) with "up", "down" (to select a parameter) and "left", "right" (to change the value of the selected parameter). Then press "set" to take pictures or "disp" to exit the script. By the way, you have to make focus before running the script by half pressing the shoot button.

More comments on the script below.

Code: [Select]
@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 "rem" to speed up the scripts so here are the comments:

Script title and parameters for CHDK script menu :
Code: [Select]
@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

Save initial EV correction:
Code: [Select]
get_prop 25 w
get_prop 26 x

Menu line counter:
Code: [Select]
let y=1

Main loop:
Code: [Select]
do

Menu exit code
  • 0: stay in menu
  • 1: shoot and come back to menu
  • 2: don't shoot and exit
Code: [Select]
  let z=0

Menu loop:
Code: [Select]
  do

Check parameters values (maybe we could be more flexible as I managed to take a -5 1/3 EV picture):
Code: [Select]
    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:
Code: [Select]
    if y<1 then y=3
    if y>3 then y=1

Print menu. 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). Does some one knows if we could remove the extra space character between print arguments?
Code: [Select]
    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:
Code: [Select]
    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:
Code: [Select]
  let d=c*32-a*b*32

Shoot loop:
Code: [Select]
  for s=1 to 2*a+1

Set EV correction. Using properties avoid having to depend on menu layout and clicks, and it's also really quicker.
Code: [Select]
    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). Also putting this just before shoot should be the quickest solution as all calculations are terminated at this time.
Code: [Select]
    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.
Code: [Select]
    press "shoot_full"

Wait for camera to be really shooting (change 205 to 206 for Digic III):
Code: [Select]
    do
      get_prop 205 p
    until p=1

Prepare for next shoot:
Code: [Select]
    release "shoot_full"
    let d=d+b*32
  next s

End of main loop, exit if "disp" was selected in the menu:
Code: [Select]
  :exit1
until z=2

Restore initial EV correction values and exit:
Code: [Select]
set_prop 25 w
set_prop 26 x

end

Thanks for reading ! Comments welcome.


Nicolas bertolissio

*

Offline Jucifer

  • *****
  • 251
  • [A710IS]
Re: Bracketing and EV correction script (one more)
« Reply #1 on: 14 / April / 2008, 13:19:57 »
Does some one knows if we could remove the extra space character between print arguments?

try removing the commas after the closing quotation marks in print statements

Re: Bracketing and EV correction script (one more)
« Reply #2 on: 14 / April / 2008, 16:28:03 »
Does some one knows if we could remove the extra space character between print arguments?

try removing the commas after the closing quotation marks in print statements

Indeed, it works. Thanks a lot.

*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: Bracketing and EV correction script (one more)
« Reply #3 on: 14 / April / 2008, 17:06:10 »
brilliant work, thanks for the huge amount of comments supplied. you may also add it to the wiki, if not already done :)


Re: Bracketing and EV correction script (one more)
« Reply #4 on: 14 / April / 2008, 18:07:39 »
brilliant work, thanks for the huge amount of comments supplied. you may also add it to the wiki, if not already done :)
Thanks for your support. I'd just like to give something back from this fantastic tool CHDK is. I think comments are mandatory so newbies (like me) can understand and contribute. I'll create a wiki page tomorrow, now it's time to go to bed here.

Re: Bracketing and EV correction script (one more)
« Reply #5 on: 15 / April / 2008, 06:22:54 »
New wiki page is here: http://chdk.wikia.com/wiki/UBASIC/Scripts:_Bracketing_and_EV_correction
I improved the print layout thanks to Jucifer tip.

Re: Bracketing and EV correction script (one more)
« Reply #6 on: 15 / April / 2008, 09:07:15 »
Deleted
« Last Edit: 22 / April / 2008, 17:52:34 by Barney Fife »
[acseven/admin commented out: please refrain from more direct offensive language to any user. FW complaints to me] I felt it imperative to withdraw my TOTAL participation. Nobody has my permission, nor the right, to reinstate MY posts. Make-do with my quoted text in others' replies only. Bye

Re: Bracketing and EV correction script (one more)
« Reply #7 on: 28 / May / 2008, 17:08:05 »
Thankyou for your script Nicolas, I'm using it on my TX1 (DigicIII).
Could it be possible to tell the script to automatically focus (and keep the focus distance for all the shots) instead of manual focusing before starting the script?


Re: Bracketing and EV correction script (one more)
« Reply #8 on: 29 / May / 2008, 02:40:54 »
Nice work on the script and well documented, but I'm having a bit of an issue with it on my SD1000 (DigicIII) with allbest #50.

i changed the property numbers as noted on the wiki entry. My problem is that the script misses some shots in the middle, and for some reason raw shooting is enabled after the script is finished.  Where did you find the information about the property numbers being different on digicIII's? Does using property numbers have an advantage over using the set_ev commands?

Thanks


Re: Bracketing and EV correction script (one more)
« Reply #9 on: 09 / June / 2008, 02:55:26 »
Hello,

First of all I would like to thank you for the great post.
I am new to CHDK, scripting and bracketing, but I am trying to learn.
I have tried to use your script on my SD800 and it works perfectly for negative EV correction, but somehow it seems to have problems for the positive one (I never get the overexposed pictures).
Am I doing anything wrong?
Or could there be a problem in the line let d=d+b*32  (as I said I am very new to scripting, but this was the only thing that perplexed me)
The only modification I did was to add a line set_prop 16 2 not to have the flash going an messing up the shoots.

Cheers,

Clemente

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal