Combined exposure bracketing and focus stacking script - Completed and Working Scripts - CHDK Forum

Combined exposure bracketing and focus stacking script

  • 7 Replies
  • 10959 Views
Combined exposure bracketing and focus stacking script
« on: 24 / May / 2012, 03:27:54 »
Advertisements
timefocus.bas / SHUTTER & FOCUS STACKING is a script that combines both exposure bracketing and depth-of-field (focus) bracketing. It's written for and tested on my Powershot S3IS, but should be easy to port to other models.

My S3 comes standard with both kinds of bracketing, but not at the same time, and the number of exposure shots and their range are limited.  This script allows anywhere from 1 to 9 exposure levels per focus distance, with steps from 2/3 stop to 3 full stops.  All exposure adjustments are done with the shutter speed; aperture remains where you set it.  You are not required to use an odd number of steps; if you use an even number your initial setting will be not be shot, but will be halfway between the two center exposures.

Focus distance stepping is entirely automatic, once you manually focus on the closest point and set the maximum depth of focus parameters (from 0 to 65.5 meters, in meters, cm, mm, feet, or inches, or any combination thereof).  In use the camera's DOF will reach infinity long before the focus setting reaches 65 meters.  The script will recognize that point and end gracefully.

You can drop the exposure bracketing by setting the exposure steps parameter to 1.  You can drop the focus stepping by setting the focus depth to 0 or any negative number.  You can even do both if you feel inclined to use an elaborate script to shoot a single frame.

I left in some rem statements and print commands for easier reading and revising.  A full explanation is in the text file TimeFocusNotes.rtf.

The script is over 2K in length and uses upper-case internal variables.  It won't run on old, old versions of CHDK.
« Last Edit: 24 / May / 2012, 03:33:33 by kidtree »
S3 IS with LensMate filter/hood adapter

Re: Combined exposure bracketing and focus stacking script
« Reply #1 on: 24 / May / 2012, 05:05:24 »
A useful script for CHDK users.

Did you know that this is a built-in feature of SDM, no script is required ?

See "Shots with Focus bracketing (continuous mode) and Tv override" here http://stereo.jpn.org/eng/sdm/tlapse2.htm


David

Re: Combined exposure bracketing and focus stacking script
« Reply #2 on: 24 / May / 2012, 12:36:36 »
Oops.  It figures.
I have SDM loaded on another SD card, but since I only have one camera I shoot stereos manually, if at all.  I keep plain vanilla CHDK loaded.  I'm constantly amazed by its power, with and without scripting.  A line from Douglas Adams keeps going through my head: when he's describing the Restaurant at the End of the Universe, he keeps repeating, "This, of course, is impossible."  I love it.
I wrote this because I'm intrigued by HDR and DOF stacking and thought it might be fun to combine the two, but CHDK didn't seem to offer that.  (In testing I accidentally found that a focus-stacking script works with Canon's native exposure bracketing.)  Eventually I remembered that Somebody could write a script to do what I wanted.  A few minutes later, I remembered I might be Somebody.
Whether it's useful or not, it was good practice, and I think I wrote good, modular code, with proper use of variable testing, subroutines, for/next and do/until loops, and a clean exit.
I'm frustrated by the outdated documentation, though.  I have a printed copy of DanielF's guide from last November, I think, and the get_tv command I relied on from there is already obsolete!  I was about to give up until I a found a link on this forum to the new cross-reference page.
Even that summary doesn't agree with how uBASIC scripts work in my camera.  The syntax get_tv96 N fails to load the value into N.  I rewrote that and all similar calls as N = get_tv96 or equivalent.
Somebody ought to update the documentation.  Again, I might be one of those Somebodies, if I find the time.
Thanks for all you've brought to CHDK.  I bought my S3 with my eyes wide-open, knowing I was accepting a lot of compromises over what some other cameras offered.  CHDK knocks a lot of those compromises off the table.
S3 IS with LensMate filter/hood adapter

Re: Combined exposure bracketing and focus stacking script
« Reply #3 on: 24 / May / 2012, 13:15:48 »
Whether it's useful or not, it was good practice

I am sure it is.

Probably for an outdoor subject in difficult lighting conditions and no movement whatsoever ...  hmmm.

Quote
I think I wrote good, modular code, with proper use of variable testing, subroutines, for/next and do/until loops, and a clean exit.

Wish I did, not enough time .. that is my excuse   :)


Re: Combined exposure bracketing and focus stacking script
« Reply #4 on: 25 / May / 2012, 11:23:57 »
Whether it's useful or not, it was good practice, and I think I wrote good, modular code, with proper use of variable testing, subroutines, for/next and do/until loops, and a clean exit.
Thamks for the posting kidtree.  I took a look at the code and its nicely structured and cleanly written.  Even better,  it comes with two pages of actual documentation !  That's something I've rarely seen posted by the self trained amateurs who kindly share their work here.

Looking at what you've done,  its clear you understand that over the life-cycle of any software project, taking the time to structure things well, use a clean coding style, and provide documentation actually saves you time.  Especially if there is any possibility that more than one person will want to work on the project and actually use your code.

After thought :  You've also discovered the pleasure of making your camera do what you want,  and not just what the manufacturer provides or what somebody else provide as a built-in function.  If you don't like how it works you can change it.  You may also find that doing structured programming in Lua is a lot nicer than using uBASIC.   Don't forget what the B in BASIC stands for.


« Last Edit: 25 / May / 2012, 11:53:07 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Combined exposure bracketing and focus stacking script
« Reply #5 on: 25 / May / 2012, 12:51:58 »
Thanks!  I've tinkered with C and C++, so Lua shouldn't be to hard to learn, but first I need a reason to program something, and time to do it.
I read in a bicycle maintenance book decades ago that there are two kinds of bike owners: those who ride their bikes, and those who fix them.  I was one of those guys who'd spend hours on the front lawn, tweaking spokes until the wheels were truer than on any bike in the showroom.
CHDK threatens to do the same thing to me.  I need to get out and ride and take pictures!
I did shoot a decent pano of an iris field yesterday, using my homemade cable release.  I love this stuff.
S3 IS with LensMate filter/hood adapter

Re: Combined exposure bracketing and focus stacking script
« Reply #6 on: 25 / May / 2012, 14:17:13 »
its clear you understand that over the life-cycle of any software project, taking the time to structure things well, use a clean coding style, and provide documentation actually saves you time.

Yes, I know, cannot turn back the clock and besides, I intend to start doing a lot more photography again .. just like the users  :)

Re: Combined exposure bracketing and focus stacking script
« Reply #7 on: 25 / May / 2012, 16:02:08 »
Thanks!  I've tinkered with C and C++, so Lua shouldn't be to hard to learn, but first I need a reason to program something, and time to do it.
I read in a bicycle maintenance book decades ago that there are two kinds of bike owners: those who ride their bikes, and those who fix them.  I was one of those guys who'd spend hours on the front lawn, tweaking spokes until the wheels were truer than on any bike in the showroom.
CHDK threatens to do the same thing to me.  I need to get out and ride and take pictures!
I did shoot a decent pano of an iris field yesterday, using my homemade cable release.  I love this stuff.
reyalp refers to it as shipwright's disease.

so if you are looking for something related to Lua that actually involves some fun photography to play with then I'd suggest the sunset16 scripts
Ported :   A1200    SD940   G10    Powershot N    G16


 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal