Author Topic: [DONE] Focus bracketing: last finishing touches please  (Read 14615 times)

Marsu42

  • Contributor
  • Hero Member
  • *****
  • Posts: 1557
  • 66d + flashes
[DONE] Focus bracketing: last finishing touches please
« on: March 04, 2013, 09:12:39 AM »
I was out the last couple of days shooting focus stacks and was very surprised (and yes, sad) to see focus bracketing gone. It's not only the fact that I added the code myself as my contribution to ml, but there actually was some reason for doing so - please let me elaborate:

* Focus bracketing is important when doing shots with large aperture and small dof: On the dslr lv screen (even less in the vf) you cannot see *exactly* what is in focus, focus peaking also just gives a hint. To make sure to hit the correct spot, the possibility to shoot a little behind and in front of the current focus is essential.

* Focus bracketing is important to save time: When doing available light stacks outside, the current/old approach (manually focus, then step through follow focus & focus peaking) is very slow, thus costing valuable time that might break the shot and eating a lot of battery power. It is much more feasible to quickly & roughly set the starting point, then let ml shoot a little in the "wrong" distance for safety, then shoot a pre-set number of frames - and if overshooting a lot or reaching max. focusing distance stop the stack (i.e. ml stops or I turn the camera off). This is my experience from real life shooting during the last years.

* Focus bracketing is convenient: With cameras w/o a swivel screen you might have to cower in awkward positions to see the lv screen, while focus braceting allows you just to pre-set the values. When doing outside stacks in the snow or dirt you will recognize this is an advantage.

Suggestion for (re-)implemenation:

1. Add two menu items "frames in front" and "frames behind" (values 0-99) and, if set, let ml shoot with these when starting the stack. If a "traditional" follow focus distance is set use this over the manually set values until it's reset.

2. The caveat when I coded it was that different lenses move need pos. or neg. focusing values to move "closer", so I had to add a "direction" normal/reverse menu item since I couldn't figure out a way to tell plus I had to name "in front" and "behind" as neutral "A" and "B".

3. Add a way to stop the currently running focus stack other than turning the camera off (I didn't add this then, but it'd be nice to have).

... if there is a way to script this through picoc with setting the appropriate values (bracket a, b, direction) and read the values currently set in the focusing options and/or set them in a picoc option it'd be an alternative, though I wouldn't know how to do it in picoc atm and picoc still has bugs on my 60d.

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 12564
Re: Focus bracketing, again :-\
« Reply #1 on: March 04, 2013, 10:20:21 AM »
Yeah, a lot of people say ML is so complex that it's almost unusable, and when I try to simplify it, there's always somebody wanting the old functionality back...

I've never used this feature and had some trouble understanding the code, that's why I've disabled it.

Walter Schulz

  • Contributor
  • Hero Member
  • *****
  • Posts: 8492
Re: Focus bracketing, again :-\
« Reply #2 on: March 04, 2013, 11:08:24 AM »
Well, if you ever had the "pleasure" to run 2:1 magnify macro shots where focus stacking is essential and your only equipment is a non-motorized macro rail and no ML inside the camera ...
I can show you, if you like or better: *Force* you to do that, because you won't like it! <eg>

Seeing ML doing the job still gives me a deep, deep grin. This is an essential time saver and does wonders to your peace of mind. Especially if you ever had to redo some 30+ shots manually because you messed up a single one.

Don't kill this feature or I will kill myself! Well, kidding. But it will cost me some money for a commercial solution and there are transport issues involved.

Ciao, Walter

Marsu42

  • Contributor
  • Hero Member
  • *****
  • Posts: 1557
  • 66d + flashes
Re: Focus bracketing, again :-\
« Reply #3 on: March 04, 2013, 12:02:57 PM »
I've never used this feature and had some trouble understanding the code, that's why I've disabled it.

Well, I guess as the main dev it's your prerogative to throw out functionality you don't like or use (and I'm sorry you didn't like my code either, I was really trying, and you gave no negative feedback when merging, and it's not like it was much of a bloat). If wanting to "slim" (or dumb) down ml, there is also always the possibility to do a poll or thread and let actual people consider what features they use or think are superfluous.

But it seems I'm not the only one thinking that bracketing is very useful, and I just wrote in lengths what usage scenarios there are - focus stacking (and dumb bracketing) is one of the killer features of ml, nothing else enables you to do that other than a tethered laptop you don't want to carry around outside. Did I at least succeed now in conveying why I think focus bracketing should be done by ml?

Edit: Originally, that wasn't even my idea but a request from photogs shooting with thin dof in the canonrumors forum - other than ml focus bracketing there is no quick and bullet-proof way to have the correct focus with large aperture lenses.

g3gg0

  • Developer
  • Hero Member
  • *****
  • Posts: 3183
Re: Focus bracketing, again :-\
« Reply #4 on: March 04, 2013, 12:55:29 PM »
yeah, its for sure useful. but i have to agree to alex that it is hard to understand.
so i never used it really :)

maybe we should rework it from scratch, keeping focus on use case oriented programming?

some use case i would assume how it has to work:
- place camera and object
- focus camera in front of/behind object (manually / per button)
- focus camera behind/in front of object (manually / per button)
- set number of images i want to shoot
- start shooting

are there limitations?
- can the focus position be read every time? (no, just on some lenses, right?)
-> focus positions must be set via buttons, not manually by turning focus ring (?)

Help us with datasheets - Help us with register dumps
magic lantern: 1Magic9991E1eWbGvrsx186GovYCXFbppY, server expenses: paypal@g3gg0.de
ONLY donate for things we have done, not for things you expect!

Marsu42

  • Contributor
  • Hero Member
  • *****
  • Posts: 1557
  • 66d + flashes
Re: Focus bracketing, again :-\
« Reply #5 on: March 04, 2013, 01:30:23 PM »
set number of images i want to shoot

You don't want that :-) but the difficult variable to determine is the step size to let one sharp dof zone to be linked with another - and that's atm trial and error since it's dependent on aperture, object distance and focal length. The best way would of course be to calculate the required step size by ml, there was a discussion about it but it's not that easy.

focus positions must be set via buttons, not manually by turning focus ring (?)

That's the main problem - the focusing distance has to be set via lv and follow focus. Of course the easiest method would be to 2x manually focus and just press shoot - but unfortunately it seems that's impossible.

Generally the current way isn't that bad once you discover how it works (took me ages), the only problems are that setting the end focus via focus peaking is not that precise and that stepping through follow focus costs time while the sun moves, the next cloud appears and your light is gone :-\

Maybe part of the confusion comes from the two different usage scenarios - either

a) shoot with small dof like f1.2 so you never really know where the focus pane really is @100% crop until looking at a large screen - so shooting a bracket in front / behind is important

b) fast, dumb bracketing when you roughly know the couple of shots a stack will take or want to stop the stack manually - in this case the "bracket" to the start is a safety margin in case the starting focus wasn't spot-on. And believe me, I often nearly bit into my camera when I discovered I was missing 1-2 shots at the starting end.

Marsu42

  • Contributor
  • Hero Member
  • *****
  • Posts: 1557
  • 66d + flashes
Re: Focus bracketing, again :-\
« Reply #6 on: March 04, 2013, 01:36:48 PM »
Btw: That's the kind of shots I'm doing, this one is from yesterday when I was cursing at having to set the # of shots through follow focus w/o any safety margin at the start while the sun went away :-p ...

.. and generally maybe I shouldn't want focus bracketing included in ml anyway since I'd be the only one to use it in my private build, that's being altruistic for you :-o

A little larger size here: http://img829.imageshack.us/img829/1600/flo130228132544d1105364.jpg


a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 12564
Re: Focus bracketing, again :-\
« Reply #7 on: March 04, 2013, 01:49:54 PM »
Just reworked it like this:



Looks better or it's even more confusing?

Marsu42

  • Contributor
  • Hero Member
  • *****
  • Posts: 1557
  • 66d + flashes
Re: Focus bracketing, again :-\
« Reply #8 on: March 04, 2013, 02:05:42 PM »
Looks better or it's even more confusing?

Ha, I thought a lot about how to put focus stacking/bracketing/rack in the ui w/o confusing people, but found no solution ... truth is, it's a valuable, but advanced feature.

Your solution is easy for bracketing, but rather complicated for "old-school" stacking: You have to zero the range in one place to start fresh, go to lv, mf to start, follow focus to end, go into ml stacking, "copy rack focus range", then go up and start "run focus stack". The nice thing about your approach is that we can modify # of pics after copying, so yes, put it in trunk and we can try it!

One thing though: "in front" and "behind" doesn't work like that, for example my 70-300L and 100L focus in different directions when giving a + or - focus command - that's why I named them A/B and added a "direction" option. Or have you figured out a way how to determine where "front/behind" is (that'd be great)?

Plus: If you are at it please just add the 10/2s timer from this request, believe me, it does make sense and doesn't add any more complexity to the ui: http://www.magiclantern.fm/forum/index.php?topic=4746.0

Greg

  • Contributor
  • Hero Member
  • *****
  • Posts: 607
Re: Focus bracketing, again :-\
« Reply #9 on: March 04, 2013, 02:06:47 PM »
My menu looks like this:


Currently I test if it works well.

Each time after the focus stacking focus is to "Focus: soft limit reached"
Later, focus is switched by the amount of DFI

How to measure the value of DFI:
Focus on an object, follow focus for as long as I do not get the "Focus: soft limit reached"
I read Focus End Point and assign DFI.

Marsu42

  • Contributor
  • Hero Member
  • *****
  • Posts: 1557
  • 66d + flashes
Re: Focus bracketing, again :-\
« Reply #10 on: March 04, 2013, 02:27:36 PM »
How to measure the value of DFI:
Focus on an object, follow focus for as long as I do not get the "Focus: soft limit reached"
I read Focus End Point and assign DFI.

I don't get it (is it just me?): What's dfi in full words, and I take it it's a method to set step size automatically by object distance & aperture (dof) for a given lens, and it actually works? I'd really like to try that - and I take it if you switch dfi off the manual step size is used?

Greg

  • Contributor
  • Hero Member
  • *****
  • Posts: 607
Re: Focus bracketing, again :-\
« Reply #11 on: March 04, 2013, 02:34:41 PM »
This function is designed to return focus always in the same place.
When doing a panorama of focus stacking is necessary.

focus.c
Code: [Select]
// Restore to the starting focus position
    if (focus_moved_total) {
        NotifyBox(1000, "Reversing %d steps...", ABS(focus_moved_total)); msleep(500);
        focus_stack_ensure_preconditions();
if (distance_from_i)
{
int lens_helpvalue = lens_focus_stepsize;
lens_focus_stepsize = 3;
msleep(100);
LensFocus(-6); // "Focus: soft limit reached"
msleep(300);
lens_focus_stepsize = lens_helpvalue;
msleep(100);
LensFocus(-1);
msleep(200);
LensFocus(distance_from_i_value);
msleep(1000);
}
else
{
LensFocus(-focus_moved_total);
}
        NotifyBoxHide();
    }

Marsu42

  • Contributor
  • Hero Member
  • *****
  • Posts: 1557
  • 66d + flashes
Re: Focus bracketing, again :-\
« Reply #12 on: March 04, 2013, 02:40:45 PM »
This function is designed to return focus always in the same place.
When doing a panorama of focus stacking is necessary.

Holy cow, I just looked at your link and this looks terrific - though it probably is even less self-explanatory than focus bracketing, so a little "how to" recipe would be in order. But I'd really see this merged to I can try it :-)

Marsu42

  • Contributor
  • Hero Member
  • *****
  • Posts: 1557
  • 66d + flashes
Re: Focus bracketing, again :-\
« Reply #13 on: March 04, 2013, 08:19:13 PM »
Just reworked it like this

Ok, I just tried latest trunk for a couple of stacks and here is the report. Generally I like this solution, and after the wretched PLAY/SNAP option is gone it surely is simpler to code :-o

* vital change: both num. of frames should not be limited to 9, but go to 99 for complete freedom (though 50 is the largest stack size I think makes sense, but you never know...)

* bug: the shooting mode doesn't reset to self-timer (10/2) sec after the stack, please save this value & restore. Plus a short notice "Delaying n seconds" would be nice for people who don't know the self timer mode is honored and just see nothing happening after starting the stack.

* very dear feature request: please add a way to soft-stop the stack while it's running so that ml keeps the current settings & reverts to the starting position (!). Pressing SET might be feasible, or maybe shutter, or bang the camera against your head - anything really as long as it works :-o

* bug?: Imho focus stacking should also use mirror lockup when it's set to "self timer" because that's basically what it is. Atm stacking doesn't seem to use mlu at all no matter what is set in the "Mirror lockup" menu, but I just only gave it a quick try.

1%

  • Developer
  • Hero Member
  • *****
  • Posts: 5936
  • 600D/6D/50D/EOSM/7D
Re: Focus bracketing, again :-\
« Reply #14 on: March 04, 2013, 08:30:16 PM »
Menu cancels intervalometer ... does it not cancel this?

Marsu42

  • Contributor
  • Hero Member
  • *****
  • Posts: 1557
  • 66d + flashes
Re: Focus bracketing, again :-\
« Reply #15 on: March 04, 2013, 08:35:32 PM »
Menu cancels intervalometer ... does it not cancel this?

Yes, it indeed cancels it (I never tried, thanks for the information) - but it returns a "focus stack failed" error, while a soft-stop should reverse to the starting position just as ml does after regularly stopping the stack.

The rationale is that you can also soft-stop the stack if something unexpected happening (streak of light, bee sitting on the flower, ...) and then quickly start a second run.

Greg

  • Contributor
  • Hero Member
  • *****
  • Posts: 607
Re: Focus bracketing, again :-\
« Reply #16 on: March 21, 2013, 09:50:59 PM »
Just reworked it like this:



Looks better or it's even more confusing?
It works well, but I miss take a pic.
I think that could be detected half shutter, then you can use the radio trigger.

Betelgeuza

  • Freshman
  • **
  • Posts: 66
Re: Focus bracketing, again :-\
« Reply #17 on: March 22, 2013, 07:03:30 PM »
Just reworked it like this:



Looks better or it's even more confusing?

i dont thing its confusing..its eazy to see what is for what.. i like this feature

Marsu42

  • Contributor
  • Hero Member
  • *****
  • Posts: 1557
  • 66d + flashes
Re: Focus bracketing, again :-\
« Reply #18 on: March 23, 2013, 10:45:14 PM »
It works well, but I miss take a pic.

Having worked with the code, "take a pic" is horrible because it forces ml to take a picture (no way to intercept full shutter) and you have to prevent taking the same pic twice when doing focus bracketing, creating much code complexity. I'm happy it's gone :-)

i dont thing its confusing..its eazy to see what is for what.. i like this feature

As a ml veteran, I (of course) also don't think it's confusing - but on the other hand I could also do without it, cutting away one more menu item: Whenever I change the focus range with follow focus, I *want* it to be copied to bracketing. It's nice to be able to modify the range afterwards, but I never to rack focus (video) and stacking (stills) at the same time, so this menu item imho is superfluous...

Greg

  • Contributor
  • Hero Member
  • *****
  • Posts: 607
Re: [DONE] Focus bracketing: last finishing touches please
« Reply #19 on: March 24, 2013, 01:18:00 AM »
We can use HALFSHUTTER_PRESSED.
Code: [Select]
if(HALFSHUTTER_PRESSED)
{
//focus stack function start
}

ed.jenner

  • New to the forum
  • *
  • Posts: 33
Re: Focus bracketing, again :-\
« Reply #20 on: April 10, 2013, 06:11:00 AM »
Whenever I change the focus range with follow focus, I *want* it to be copied to bracketing. It's nice to be able to modify the range afterwards, but I never to rack focus (video) and stacking (stills) at the same time, so this menu item imho is superfluous...

Yes, me too, usually.  It is one extra step, but also allows you to return to the previous bracket is you mess something up while trying to set the rack focus.  It's another thing to remember to do which could be confusing (it took me all of 90 seconds to figure out), but i think I like it.  I make lots of mistakes! 

I also like the fact I can take a shot without starting the focus stacking too - I can take blank frames easily between focus stacks.  I must admit I didn't appreciate all the reasons for the new re-working, but just went in there after installing a recent nightly and it seemed pretty logical to me.  Definitely less frustrating than the 'old' method.  I have not used it for focus bracketing myself, I'm more likely to try it now though.

I guess for me focus stacking isn't a 'quick' procedure (setting up the shot ect..) so having to copy the rack focus settings and going to 'start focus stack' to actually start the stack are very reasonable.  Probably saved me time over the course of doing a bunch of macro shots.

Greg

  • Contributor
  • Hero Member
  • *****
  • Posts: 607
Re: [DONE] Focus bracketing: last finishing touches please
« Reply #21 on: April 10, 2013, 02:03:02 PM »
Focus stacking can be accelerated, simply decrease the msleep.
Example - focus.c
Code: [Select]
- 201    while (lens_info.job_state) msleep(100);
+201    while (lens_info.job_state) msleep(2);

-238     msleep(300);
+238    msleep(20);

-298     msleep(300);
+298    msleep(20);

-315    NotifyBox(1000, "Focusing %d steps...", ABS(real_steps)); msleep(500);
+315    NotifyBox(1000, "Focusing %d steps...", ABS(real_steps)); msleep(200);


Can it be changed so the camera does not have to wait on saving to the memory card?
Code: [Select]
201    while (lens_info.job_state) msleep (100);

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 12564
Re: [DONE] Focus bracketing: last finishing touches please
« Reply #22 on: April 10, 2013, 08:06:55 PM »
I've found it very sensitive to timing - issuing focus commands too early can lockup the camera or give focus errors.

Greg

  • Contributor
  • Hero Member
  • *****
  • Posts: 607
Re: [DONE] Focus bracketing: last finishing touches please
« Reply #23 on: April 10, 2013, 08:37:18 PM »
Yes, we have to find a stable value.

kaoshotbeatz

  • New to the forum
  • *
  • Posts: 5
Re: [DONE] Focus bracketing: last finishing touches please
« Reply #24 on: April 13, 2013, 02:10:15 AM »
Alex people are just picky ive use mostly evey nightly build up to march 2nd on my 5dmk2 and the 60d but got a 5dmk3 now sold the 60d and havent used the 5d2 much use the alpha 3 of mk3 wish it had auto boot id love to be a tester its still under warranty