Get Focus Bracketing Script ***NEW***

Started by garry23, April 16, 2019, 10:42:20 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


scrax

I'll try it, thanks for sharing.
I think it could be useful for some minerals macro shot that I had to do.
I'm using ML2.3 for photography with:
EOS 600DML | EOS 400Dplus | EOS 5D MLbeta5- EF 100mm f/2.8 USM Macro  - EF-S 17-85mm f4-5.6 IS USM - EF 70-200mm f/4 L USM - 580EXII - OsX, PS, LR, RawTherapee, LightZone -no video experience-

garry23

@scrax

It's not really designed for 'true' macro ;-)

But I welcome you testing it.

Cheers

Garry

garry23

Have just 'finalised' the script and published a 'user guide' at: http://photography.grayheron.net/2019/04/deep-focus-photography-user-guide-for.html

Have inserted a link on the first post as well.

I would welcome users trying it out on other cameras, other than a 5D3.

Plus of course any feedback to make the script better.

Cheers

Garry

scrax

Here we are, after reading your interesting blog post, installed script and first problem is Rebels don't have a rate button, so changed in cmera to SET, but then instead of overwriting your module i've saved it as another one and BUM
lua get crazy (I have aso the focus bar enabled) is like ML is fighting with console for using the screen...

Second round: only one script  :P

With only this script loaded after starting it I got b=666 and camer was set to 1/4000 f32 (for the dark frame). So I've set up camera for the nearest object that should be focused and started the script.

Scipt take one pic and then seem stuck... I was stuck all the time I was writing this and then I've tried to press halfshutter and it took another pic...
What's the problem?
Simple I've set canon review->Hold and in ML it goes to play mode so had to press halfshutter each time to let the script continue...

When the scene is ok I get b=45 on the 600D with 18-55 at 55mm

After some shot I got the error at line 71 lens.focus() only works in LiveView even if I'm in live view...

Will try more...
I'm using ML2.3 for photography with:
EOS 600DML | EOS 400Dplus | EOS 5D MLbeta5- EF 100mm f/2.8 USM Macro  - EF-S 17-85mm f4-5.6 IS USM - EF 70-200mm f/4 L USM - 580EXII - OsX, PS, LR, RawTherapee, LightZone -no video experience-

garry23

@scrax

I wouldn't use SET as it gets used a lot elsewhere.

Choose something else.

Cheers

Garry

garry23

@scrax

I will look at starting the script explicitly from its menu, i.e. no buttons.

scrax

Quote from: garry23 on April 17, 2019, 11:38:06 PM
@scrax

I wouldn't use SET as it gets used a lot elsewhere.

Choose something else.

Cheers

Garry

I've put set because was the faster to edit with the integrated editor  :P
but then I've used the pc to remove the duplicated script and set it to play  ;)

Also I suppose that this lens could have problem with focus, will try other lenses to compare...
I think the proble in the lens is that with 1 step focus the motor can't move focus, had to set to 2 in focus settings, but seems that the script don't change.
Is it changing 1 step at time?
I'm using ML2.3 for photography with:
EOS 600DML | EOS 400Dplus | EOS 5D MLbeta5- EF 100mm f/2.8 USM Macro  - EF-S 17-85mm f4-5.6 IS USM - EF 70-200mm f/4 L USM - 580EXII - OsX, PS, LR, RawTherapee, LightZone -no video experience-

garry23

@scrax

You said the bookend was f/32. Really. I can't see how.

A B of 666 says your aperature is too small, i.e. diffraction.

Try using at lower focall lengths, eg 18 and varying focus to see B change.

The lens.focus problem may be related to the script using the small step size to fine tune.

Thanks for your testing.

scrax

Quote from: garry23 on April 18, 2019, 12:06:51 AM
@scrax

You said the bookend was f/32. Really. I can't see how.
Will see if it happens again
Quote
A B of 666 says your aperature is too small, i.e. diffraction.
I found the lowest value at f/9 with the 55mm. I've started with a high f number to have more DOF (opss)
Quote
Try using at lower focall lengths, eg 18 and varying focus to see B change.
Yes it varies consistently, but I was tring it on a small rock and the 55mm was the best for framing

Quote
The lens.focus problem may be related to the script using the small step size to fine tune.
Totally agree I've managed to make it work by helpin the lens "by hands"

QuoteThanks for your testing.
Thanks you for sharing it, I'll try on landscape too.


For the macro is not ideal, as you know.
In the end I've used the usual focus stack in ML (also because it saves also a script for enfuse and it works so well)
I've tried to blend the images also with hugin but it after one hours setting it with like 30 pic it got stuck when rendering the merge image.

attached an example of the stacked image (bw) and the first one of the stack (color)
I'm using ML2.3 for photography with:
EOS 600DML | EOS 400Dplus | EOS 5D MLbeta5- EF 100mm f/2.8 USM Macro  - EF-S 17-85mm f4-5.6 IS USM - EF 70-200mm f/4 L USM - 580EXII - OsX, PS, LR, RawTherapee, LightZone -no video experience-

garry23

@scrax

Good, at least you are able to test.

I'm intrigued you get f/32, as I set APEX 9, ie f/22.

The lens.focus() failure was hinted at by @a1ex in his API test script, ie on some cameras the smallest step size may not work. On my 5D3 it does, but on your Rebel things look flaky. I'll look it to it, but I used the smallest step size get the closest convergence to the request focus distance. The small step size seems OK on my 5D3 (and I only write scripts for myself, but freely share for others to adapt  ;) )

BTW for macro I find the G7X (brought mine on eBay), with its min focus distance of 50mm, at a FL of about 9mm, a pretty good set up for semi-macro. See here for a version of the script I wrote over at CHDK: https://chdk.fandom.com/wiki/Landscape_Focus_Bracketing_:_perfect_near_to_far_focus_brackets

scrax

Quote from: garry23 on April 18, 2019, 07:27:55 AM
@scrax

Good, at least you are able to test.

I'm intrigued you get f/32, as I set APEX 9, ie f/22.

The lens.focus() failure was hinted at by @a1ex in his API test script, ie on some cameras the smallest step size may not work. On my 5D3 it does, but on your Rebel things look flaky. I'll look it to it, but I used the smallest step size get the closest convergence to the request focus distance. The small step size seems OK on my 5D3 (and I only write scripts for myself, but freely share for others to adapt  ;) )

BTW for macro I find the G7X (brought mine on eBay), with its min focus distance of 50mm, at a FL of about 9mm, a pretty good set up for semi-macro. See here for a version of the script I wrote over at CHDK: https://chdk.fandom.com/wiki/Landscape_Focus_Bracketing_:_perfect_near_to_far_focus_brackets
With compact camera I had a lot of fun years ago doing semi-macro but what I dislike is that now they are almost all missing the viewfinder...
Probably I'll get a ring to invert some old FL lenses (and then lose the auto focus staking)  :'(
I'm using ML2.3 for photography with:
EOS 600DML | EOS 400Dplus | EOS 5D MLbeta5- EF 100mm f/2.8 USM Macro  - EF-S 17-85mm f4-5.6 IS USM - EF 70-200mm f/4 L USM - 580EXII - OsX, PS, LR, RawTherapee, LightZone -no video experience-

garry23

@scrax

G7X anf G1X have rotating LCD: good enough for me and my auto bracketing script  ;)

garry23

For those of you that will have time off over Easter, sorry US friends, I've issued an update to the script that allows you to use it from M, Av or Tv modes.

Usual caveat from me: I wrote this for myself, for my 5D3 and have tested it with my 12-14 Sigma and my 24-105 4L.

I, of course, welcome feedback and even seeing some images ;-)

Cheers

Garry

garry23


garry23

I'm pleased to say (thanks @a1ex for your help) that I've updated my deep focus bracketing script, by simplifying it.

I will update the first post to reflect this and the script can be accessed via this post on my blog: http://photography.grayheron.net/2019/04/continuing-deep-focus-story.html

The script does a pretty good job of creating seamless focus brackets at any overlap blur (microns) that you wish; using the ML CoC as the control variable.

In addition, at each focus, the script will carry out exposure bracketing, using the ML Advanced Bracketing. But note, the script will/may fail if the Advanced Bracketing chooses to use Bulb mode.

As usual I welcome any feedback.

garry23

Here is the latest version of my auto focus stacking script. It complements my DoF Bar, which was written to help with manual focus stacking and infinity focusing.

In this latest release of the auto script, ie that requires an AF lens, you need to first tell the script what your lens attributes are. ie Max focal length and Max magnification: both easily obtainable.

Explicitly enter this info in the script. You can obtain your lens name by enabling the section of script at the end of the main code block.

The script has three powerful features.

First, it tells you how many brackets you will take from you current focus position, +/- one.

It also tells you the infinity defocus blur, the diffraction blur and the total blur (all in microns). Thus you can use the script to help you set infinity focus. The ML CoC is used to set the overlap blur. On a full frame camera a 20 micron setting is recommended.

Finally, it will automatically take the brackets for you: that is, from your current point of focus to around four times the hyperfocal, ie an infinity blur of the ML_CoC/4.

The script is a so-called Lua simple script, ie it has no menu: the script is run from the ML scripts menu. However, I have written a helper script that jumps you straight to that menu by pressing the RATE key, or any other key you decide to recode.

The scripts may be downloaded from the link on the first post: http://photography.grayheron.net/

The UI is colour coded to help you make focus decisions.

The blur feedback changes colour to indicate the focus state:

* RED = defocus (sic) infinity blurs more than the ML CoC, ie focusing less than the hyperfocal (H)
* Orange = you are between H and 2*H
* Green = you are between 2*H and 4*H
* Yellow = you are over focusing, ie you are beyond 4*H

For landscape and cityscape photographers, I believe the script represents one of the best ways to maximise your focus quality, ie through knowing the infinity blurs and automatically capturing focus brackets.

Of course you need an AF lens ;-)

Also, focus stacking is sensitive to movement, thus it works best if there is not much wind or you are doing long exposures.

The script works with Dual-ISO (as in the test shot below) and Advanced ML Bracketing (although if AML bracketing uses Bulb mode, the script will likely fail: sorry).

When the blur info is shown, you can change exposure and do an ETTR with SET. Pressing any other key will exit the script.

To run the script, simply do a long half shutter press until the last line of the UI feedback turns green, ie 2+ seconds.

Rather than drone on with details, as usual with my scripts, I suggest you try it out. The usual caveat applies, I wrote the script for my use, but I freely share it with the ML community.

Finally, I attach a few screen shots and a Dual-ISO, focus stacked test image I just took with my 24-105mm at 24mm. The script took 7 images, as I focused at the minimum focus distance of the lens, ie 450mm. I did a round trip to Helicon Focus and used method B, which I find works well.

As usual I welcome feedback and will always provide help.












garry23

Playing with the UI to make it more readable: https://gist.github.com/pigeonhill/d02e5d5a88516c67e929397d74af0142

Not sure if others have tried this script yet, however, it runs really well on my 5D3.

Set the ML CoC value to the overlap blur you wish to use (in microns).

Switch on the ML DoFs if you wish to see these (simple or diffraction aware).

The UI provides all the info you need to set focus for a single image, ie infinity defocus, diffraction and total blurs in microns, plus how many focus brackets will be taken from the current position, if the script is run, ie via long half shutter press.

garry23

As this version of the script requires you to put in lens info, I decided to simplify the calibration step. Hence you now need to put in the minimum focus distance of the lens and the lens charility, ie what way it moves, either 1 or -1.

For instance, the two lenses that I use exhibit negative charility. The lens info being:


lens_info =
{
    {name = "EF24-105mm f/4L IS USM", mag = 0.23, fl = 105, mfd = 450, dir = -1},
    {name = "12-24mm", mag = 0.17, fl = 24, mfd = 280, dir = -1},
}


To find out the lens name etc, simple switch on the following bit of code in the script:


-- turn on the following bit of code to get your lens name
        --[[ add two closed square brackets here ->
        local lens_ok = true
        direction = 1
        start_x = lens.focus_distance
        lens_ok = lens.focus(1,3,true) -- test lens chirality
        sleep(0.2)
        if lens.focus_distance < start_x then
            direction = -direction
        elseif lens.focus_distance == start_x and start_x < inf then
            direction = -direction
        end
        lens_ok = set_focus(start_x)
        display.print("Lens name:"..lens.name,50,200,FONT.SANS_32)
        display.print("Direction: "..tostring(direction),50,240,FONT.SANS_32)
        display.print("Press halfshutter to clear",50,280,FONT.SANS_32)
        key.wait(KEY.HALFSHUTTER)
        display.clear()
        --]]



You can download from here as usual: https://gist.github.com/pigeonhill/d02e5d5a88516c67e929397d74af0142

rudison

Thank you Garry for this script! It's very interesting for landscape focus stacking.

I've tried it with a Canon 650D + EF-S 10-18mm lens.

In the beginning I had some problems but I was able to solve them:

  • The filename was too long, Magic Lantern couldn't load the script. I had to change the filename (-> 8.3).
  • I activated the section for unknown lenses. But the check for a non existing lens was executed before, so this section was never active.
  • I don't need the 'bookend' exposures (it wears the shutter). The flag bookends = false solved it.

I will continue to test your focus bracketing script ...

garry23

@rudison

Many thanks for the feedback.

As I've said before, I write my scripts for myself, but freely share for others to adapt for their use.

Regarding the file name. Yes I now only use four characters  ;)

Good catch on the lens not recognised trap.  I'll fix that.

I personally believe the bookends add real value in post, but as you know you can easily switch them off.

Once again, thanks for testing and giving me feedback.

Cheers

Garry



garry23

@rudison

Have up issued the script: https://gist.github.com/pigeonhill/d02e5d5a88516c67e929397d74af0142

UI tweaked, eg bars show defocus and diffraction blurs as a % of total blur; plus colour background of the bars changes according to your infinity focus status.

Script automatically detects unregistered lens and provides required info for registration.

Usual caveat: works well for me on my 5D3  ;)

Cheers

Garry

rudison

Thanks a lot for the update!

I made a short test yesterday - seems to work fine. Also the new UI looks promising.
I will do more tests during the weekend.

How do you develop/debug your lua scripts?
Write code / remove SD card / copy to the SD card / insert card / test in camera: seems to be complicated. Is there an easier way?

garry23

@rudison

I'm not the best person to ask about the best way to develop a Lua scripts, as I still 'just' do via the camera method.

I know there are Lua development environments, but I've never got one working.

Maybe a kind person will pick up on this and say how they set up a Lua development environment, ie that checks error etc.

a1ex

... I'm doing the same.

There is a minor improvement if you have a development environment installed - when compiling the Lua module, it will also check the scripts for syntax errors. It would save like 10-20% of the card swaps (as most of the errors - at least for me - are on the logic side).

QEMU could be promising, but emulation is very limited at the time of writing (so it's only useful for very simple scripts, maybe for for testing menu options or for debugging the graphics side). As soon as you try to take a picture or enter LiveView, it will no longer work (or it will require heavy workarounds). Make it usable for offline Lua development is probably doable, but certainly not trivial.

Another way would be to mirror our library and have some dummy calls for the desktop PC. This one would be a bit easier, but a lot more boring (and I'd say more error-prone, because of code duplication - i.e. you will not be testing against the same code that runs on the camera).

Using a Wi-Fi SD card works reasonably well for minimizing the card swaps, as long as you don't mind the amount of fiddling required to get it to work, and occasional filesystem errors (as the connection will break in the middle of a file copying operation, sooner or later).