What are the 'best' ways of doing two things? - General Discussion and Assistance - CHDK Forum supplierdeeply

What are the 'best' ways of doing two things?

  • 4 Replies
  • 325 Views
What are the 'best' ways of doing two things?
« on: 08 / April / 2019, 04:15:27 »
Advertisements
I've recently enjoyed revisiting CHDK, after initially looking at it many years ago, and then moving into EOS world, and of course Magic Lantern.

Having just purchased a second hand G7X and G1X, I'm really enjoying myself with CHDK Lua.

But...life is not always easy  :haha

Two things continue to confuse me, as I don't think I can get to the bottom of things.

First, is changing exposure between images and thus adopting the best approach, eg use 'just' shoot, or use some of @reyalp quick shooting code, ie with hooks.

I think in my latest script (https://chdk.fandom.com/wiki/Landscape_Focus_Bracketing_:_perfect_near_to_far_focus_brackets) I've adopted a reasonably robust approach to shooting and changing exposure. But I would be interested in what others think.

Secondly, is changing focus and (sic) knowing when to continue with the script because focus has been set.

My current approach is based on delays, eg sleep(500), but this seems 'dodgy' to me  :(

So my question is: what is the 'best practice' that others have adopted for exposure and focus control, and, of course, doing both together.

That is, 'only' progressing in the script if exposure and focus are indeed set, and hence their values can be safely accessed by Lua.

BTW I appreciate that this may be a dead topic and hence I would understand if there were no responses  ;) 

Re: What are the 'best' ways of doing two things?
« Reply #1 on: 08 / April / 2019, 06:40:14 »
As an example of my thinking, here is a test function that refocuses and test how close you are to the request refocus: note in this case xx > x.

Code: [Select]
function refocus(xx)
    local test = 0
    local old = get_focus()
    set_focus(xx)
    repeat
        sleep(10)
        test = get_focus()
        test = 100*(test-old)/(xx-old)
    until (test >= 90) -- ie close enough
end

So the question is? Do I need this 'complexity', or will a simple set_focus(xx) do it?

Re: What are the 'best' ways of doing two things?
« Reply #2 on: 08 / April / 2019, 07:58:04 »
OK: more testing to satisfy/educate myself.

Here is my test function to refocus:

Code: [Select]
function refocus(xx)
    dof = get_dofinfo() -- update info
    local temp = dof.focus
    set_focus(xx)
    dof = get_dofinfo() -- update info
    print(temp.."/"..dof.focus)
end

In the above the focus position in dof is updated instantly and thus appears to me to be reliable to be used without sleep calls.


Or am I missing something  ;)

*

Offline reyalp

  • ******
  • 12109
Re: What are the 'best' ways of doing two things?
« Reply #3 on: 08 / April / 2019, 13:29:47 »
First, is changing exposure between images and thus adopting the best approach, eg use 'just' shoot, or use some of @reyalp quick shooting code, ie with hooks.
"Best" depends on your needs. If you need a full half press cycle every shot (because you want Canon AF, AE etc or need to change something that can only be done outside of half press), or speed isn't critical and you don't need to do anything while shooting is happening, then shoot() is a good choice.

If speed is important to you, or you want analyze the raw image data, or control shooting in continuous bursts, then the key press + hook approach is what you need.


OK: more testing to satisfy/educate myself.

Here is my test function to refocus:

Code: [Select]
function refocus(xx)
    dof = get_dofinfo() -- update info
    local temp = dof.focus
    set_focus(xx)
    dof = get_dofinfo() -- update info
    print(temp.."/"..dof.focus)
end

In the above the focus position in dof is updated instantly and thus appears to me to be reliable to be used without sleep calls.


Or am I missing something  ;)
This is weird. I noticed the refocus() function in your script before, and it doesn't seem like it should be needed, but I haven't got around to playing with it myself.

Regarding the quoted code, get_focus() and dof_info.focus should return the same value:

get_focus calls shooting_get_subject_distance
Code: [Select]
int shooting_get_subject_distance()
{
  shooting_update_dof_values();
  return camera_info.dof_values.subject_distance;
}
get_dof_info does
Code: [Select]
  shooting_update_dof_values();
...
  SET_INT_FIELD("focus", camera_info.dof_values.subject_distance);

Focus override in general has a lot of quirks and cameras specific issues.

It's normal for set_focus() to not set exactly the requested value, and for multiple calls to set_focus with the same value not to result in the same get_focus() value being returned. The distance values are also not necessarily well calibrated, so e.g. on my g7x setting something well short of "infinity" may give better focus for astrophotography.

Another thing to note is that if Canon firmware is in autofocus, mode, then the set_focus value isn't applied until half press.

If not in Canon AF,  set_focus() is supposed to block until the focus change is complete, but it's possible this isn't true on all cameras.
Don't forget what the H stands for.


Re: What are the 'best' ways of doing two things?
« Reply #4 on: 08 / April / 2019, 14:00:39 »
@reyalp

As usual many thanks for your time responding.

In my case I will always be in M mode and MF. I believe this will help with stability.

Thus, ‘all’ I’m seeking to do is calculate the new focus position, move, take some exposures and repeat.

I’ll carry on educating myself, but I’m convinced the current version of my script is pretty stable.

Cheers

Garry

 

Related Topics