Landscape Focus Bracketing Script - Completed and Working Scripts - CHDK Forum supplierdeeply

Landscape Focus Bracketing Script

  • 85 Replies
  • 2920 Views
Landscape Focus Bracketing Script
« on: 03 / January / 2019, 07:25:26 »
Advertisements
This script does one thing. Namely, takes the 'perfect' focus stack from near to far.

I've written about the script on my blog at: http://photography.grayheron.net/2019/01/landscape-focus-bracket-script-for-g7x.html

The above link provides the background.
Code: [Select]
--[[
@title Landscape Bracketing
Release 0.9 - Tested on a G7X
@chdk_version 1.5

@param c Script Delay (s)
    @default c 3
    @range   c 0 5

@param b Bookends?
    @default b 0
    @values  b Yes No

@param g Overlap?
    @default g 0
    @values  g None Some More
--]]

set_mf(1)
sleep(c*1000)
dof = get_dofinfo()
base_h = dof.hyp_dist
h = base_h -- used to ensure overlay or some or more

if g == 1 then
    h = h*5/4
elseif g == 2 then
    h = h*3/2
end

x = get_focus()
x_start = x
s=get_tv96()

function refocus(x)
local dis = 0
set_focus(x)
repeat
    dis = get_focus()
    sleep(100) -- seems to work on G7X, may need increasing on other cameras
until dis == get_focus()
end

if x_start < base_h then -- ok to bracket
    if b == 0 then -- create bookend
        set_tv96(960)
        shoot()
        set_tv96(s)
    end

    refocus(x_start) -- explicit refocus, just in case
    while  (x <= h/3) -- capture brackets less than at the hyperfocal
    do
        shoot()
        x = x*h/(h - 2*x) -- next focus position
        if x <= 0 then break end -- as now past h
        refocus(x)     
        dof = get_dofinfo()
    end

    refocus(base_h)
    shoot()

    refocus(2*base_h)
    shoot()

    if b == 0 then -- create bookend
        set_tv96(960)
        shoot()
        set_tv96(s)
    end
else
    print("...beyond H")
end

refocus(x_start)   

print("...done")

exit_alt()




Re: Landscape Focus Bracketing Script
« Reply #1 on: 05 / January / 2019, 04:23:23 »
I'm now publishing my Landscape Bracketing script at Rev 1.

You can download it from: https://gist.github.com/pigeonhill/10a43f5ba543bc758f1ce21d28981a89

The script seamlessly covers from near to far and gives the following user options:
  • Script Delay (sec). Which allows the camera to settle down.
  • Bookends? Which puts a dark image either side of the bracket set. Default is yes.
  • Overlap? Which means more brackets! Default is none.
  • Max number of brackets? Which can be 20. Default is 7.
  • Infinity focus quality. Which ensures the last/infinity image is at the required blur. Default is CoC/3.
  • Show bracket pos? Which prints the focus data to the console for review.
In addition the script prints to the console the number of non-bookend images taken and the infinity blur in microns.

As usual I welcome any feedback on the script and ideas for improvement.

Cheers

Garry
« Last Edit: 05 / January / 2019, 13:39:40 by pigeonhill »

Re: Landscape Focus Bracketing Script
« Reply #2 on: 06 / January / 2019, 10:09:53 »
Have tidied up a few things and added in a log file that looks like this for each bracketing sequence:
Quote
Sun Jan  6 15:52:21 2019

Image 3281 @ 218

Image 3282 @ 286

Image 3283 @ 418

Image 3284 @ 784

Image 3285 @ 1769

Image 3286 @ 5307

Took 6 brackets

Infinity blur 4um

*** FINISHED ***


The script keeps adding to a single log file (LOG_0001.txt), so you will need to delete when you don't need it anymore.

Latest rev can be downloaded from here: https://gist.github.com/pigeonhill/10a43f5ba543bc758f1ce21d28981a89

There are a few things I'm still not happy with, eg to create the log file it still prints to the console, ie I can't work out how to just print to a file.
Over all however, the scripts works pretty well and should be well received by those seeking near to infinity perfect focus bracketing.

As usual I welcome any feedback.

Cheers

Garry

Re: Landscape Focus Bracketing Script
« Reply #3 on: 06 / January / 2019, 14:59:18 »
to create the log file it still prints to the console, ie I can't work out how to just print to a file.
You can't use the print( ) statement if you just want to log to a file.

Take a look at the printf( ) and lprintf( ) functions in the ultimate.lua script for an example of more sophisticated logging.
Ported :   A1200    SD940   G10    Powershot N    G16


Re: Landscape Focus Bracketing Script
« Reply #4 on: 06 / January / 2019, 16:35:02 »
@waterwingz

Thanks for the pointer to the intervalometer script, I’ll have a good read.

I am using print() at the moment, after using print_screen, however, doesn’t it still print to the console?

*

Offline reyalp

  • ******
  • 11918
Re: Landscape Focus Bracketing Script
« Reply #5 on: 06 / January / 2019, 16:42:11 »
FWIW, I like to use CSV files for script logging. You can find framework for this in the drtest.lua in CHDK distribution, between
-- log module
and
-- end log module

This may well be more heavy weight than you want.

edit:
Some usage notes in https://chdk.setepontos.com/index.php?topic=13401.0
« Last Edit: 06 / January / 2019, 19:22:40 by reyalp »
Don't forget what the H stands for.

*

Offline reyalp

  • ******
  • 11918
Re: Landscape Focus Bracketing Script
« Reply #6 on: 06 / January / 2019, 16:43:08 »
I am using print() at the moment, after using print_screen, however, doesn’t it still print to the console?
Yes, if you want just write to a file, you should use lua IO http://www.lua.org/manual/5.1/manual.html#5.7
Don't forget what the H stands for.

Re: Landscape Focus Bracketing Script
« Reply #7 on: 06 / January / 2019, 17:15:16 »
I am using print() at the moment, after using print_screen, however, doesn’t it still print to the console?
Yes it does. That's why I suggested looking at the print functions in ultimate.lua.   Cut& paste them to your script. That's what I did, more or less, when I got them from reyalp.
Ported :   A1200    SD940   G10    Powershot N    G16


Re: Landscape Focus Bracketing Script
« Reply #8 on: 06 / January / 2019, 17:20:44 »
@waterwingz @reyalp

Many thanks to both of you for the insight.

Cheers

Garry

Re: Landscape Focus Bracketing Script
« Reply #9 on: 10 / January / 2019, 15:19:42 »
Not sure if anyone has tried this script, or it's worth me putting in on the CHDK scripts page; however, here is the latest version, which adds in exposure bracketing (+/- or -/-- or +/++ around 0Ev) and tidies things up.
The script can be downloaded from here: https://gist.github.com/pigeonhill/10a43f5ba543bc758f1ce21d28981a89
The unit of blur used in the script is the CHDK CoC for the camera.
Thus the overlap choices are none, ie each focus bracket just touches the previous one, or overlaps at 2CcC/3 or CoC/2.
The infinity blur final shot, ie the one taken beyond the hyperfocal, is taken at either CoC/2, CoC/3 or CoC/4.
The script creates a log of the focus positions by default.
As usual I welcome any feedback.

« Last Edit: 11 / January / 2019, 02:33:55 by pigeonhill »

 

Related Topics