Some basic questions about writing scripts for CHDK - Script Writing - CHDK Forum  

Some basic questions about writing scripts for CHDK

  • 6 Replies
  • 6428 Views
Some basic questions about writing scripts for CHDK
« on: 10 / December / 2009, 04:05:18 »
Advertisements
Hi everybody,

I have played with CHDK a couple of times, basically I was most interested in the RAW writing feature that it adds to my trusty PowerShot S5IS. As I switched to a Four-Thirds SLR recently, the S5IS didn't get any more play time.

This might change though as I come across some situations where the image quality of the S5IS is good enough for what I have in mind and I would need to be able to script exposures.

Looking at the sparse documentation available I still have a couple of questions.

  • When a script makes exposures with the shoot method, how are ISO, aperture and shutter speed set? Can I put the camera in Av mode (Tv mode), set an aperture (exposure time) and then start the script and whenever the shoot method is called in the script it will use the aperture that I set?
  • How does the camera define the focus when the shoot method is called in a script? When calling the shoot method from a loop, will the focus be exactly the same each time the method is called?
  • Can I calculate exposure values (EV) with different metering? Say, I want to create a EV bracketing series of six pictures by "spot" measuring the darkest and brightest spot in a scene. Taking the brightest spot I want to bracket with constant aperture by EV 3.5, taking the darkest spot, I want to bracket by EV 1.5. Would that be possible?
  • When writing LUA scripts on my Mac, how do I have to save the scripts? Which encoding and line feeds should I choose?

I have even more questions but I probably can figure them out myself, so I resign to bothering you with those only at this time! :P

regards,

polarapfel

*

Offline fe50

  • ******
  • 3152
  • IXUS50 & 860, SX10 Star WARs-Star RAWs
    • fe50
Re: Some basic questions about writing scripts for CHDK
« Reply #1 on: 10 / December / 2009, 12:08:26 »
When a script makes exposures with the shoot method, how are ISO, aperture and shutter speed set? Can I put the camera in Av mode (Tv mode), set an aperture (exposure time) and then start the script and whenever the shoot method is called in the script it will use the aperture that I set?
Yes
The shoot command emulates a shutter half-press + full press - sequence, with the settings you've choosen from the Canon menus.
When CHDK overrides are active (e.g. a fix Tv value), those overrides will always overwrite the Canon settings.

Quote
How does the camera define the focus when the shoot method is called in a script? When calling the shoot method from a loop, will the focus be exactly the same each time the method is called?
See above - focusing is done by the shoot command by emulating half-pressing the shutter button

Quote
Can I calculate exposure values (EV) with different metering? Say, I want to create a EV bracketing series of six pictures by "spot" measuring the darkest and brightest spot in a scene. Taking the brightest spot I want to bracket with constant aperture by EV 3.5, taking the darkest spot, I want to bracket by EV 1.5. Would that be possible?
You can set the exposure in a script, you can also read the values choosen by the Canon firmware, and you can easiely do a Av or Tv bracketing series without a script - read more here:
--> http://chdk.wikia.com/wiki/UBASIC/TutorialScratchpad#Camera_Operation_Commands
--> http://chdk.wikia.com/wiki/CHDK_User_Manual#Bracketing_in_continuous_mode

Quote
When writing LUA scripts on my Mac, how do I have to save the scripts? Which encoding and line feeds should I choose?
Line feeds doesn't matter, CHDK can use LF (unix style) or CR+LF (windows style); make sure the scripts are ANSI coded, UNICODE is not supported.
You could also read the Mac FAQ, especially Still having trouble ?.

PS: maybe the german CHDK manual could be helpful, available in an advanced version in pdf format from the german CHDK forum...

Focus Memory
« Reply #2 on: 12 / December / 2009, 09:25:12 »
See above - focusing is done by the shoot command by emulating half-pressing the shutter button

Thanks for the answers. I have one more question regarding the focus. Say I want to store the focus in a variable like this:

Code: (lua) [Select]
x = 0
press( "shoot_half" )
get_focus( x )
release( "shoot_half" )

So, can I do this in subsequent shots to use the same focus for every shot?

Code: (lua) [Select]
press( "shoot_half" )
set_focus( x )
press( "shoot_full" )

Is setting a focus possible while the "shoot_half" is still pressed? The thing I want to establish is to use the exposure time the camera computes from a set aperture in Av mode by pressing "shoot_half" but use the focus from the before the first shot.

Is this possible like this?

Thanks,

polarapfel

*

Offline reyalp

  • ******
  • 14121
Re: Some basic questions about writing scripts for CHDK
« Reply #3 on: 12 / December / 2009, 19:38:56 »
Thanks for the answers. I have one more question regarding the focus. Say I want to store the focus in a variable like this:

Code: (lua) [Select]
x = 0
press( "shoot_half" )
get_focus( x )
release( "shoot_half" )
Note, in lua you need to use
x=get_focus()

If you are relying on camera AF, you need to wait for the focusing to complete before getting the value. To do this, use a loop like
Code: [Select]
press("shoot_half")
repeat
sleep(10)
until get_shooting() == true
... get your values here

get_shooting() will become true when all the canon AF and AE functions have done their job. If you go on to press shoot_full, it will only go false again once the exposure is pretty much finished.

Some general comments on getting and setting these kinds of values from script:

If you use the set_XX96 functions (and also the focus functions AFAIK), you must call them before starting the half press. If you want to set these values during the half press you have to set the propcase values directly, if the particular feature is controllable by propcases (and getting it at exactly the right stage in the shooting process may be tricky.)

Note that there may be some variation in behavior depending on whether the camera is in a mode that allows manually setting of the particular value (e.g. M, Tv, Av etc. canon modes)

For what you describe with focus, you may want to use canons own AF lock feature, as described in the canon manual, but using emulated button presses.
Don't forget what the H stands for.


Re: Some basic questions about writing scripts for CHDK
« Reply #4 on: 14 / December / 2009, 10:02:45 »
Hi there,

For what you describe with focus, you may want to use canons own AF lock feature, as described in the canon manual, but using emulated button presses.

This is probably very good advice. I looked up the AF Lock feature in Canon's S5 IS manual and it states this:

  • Press the shutter button halfway and press the MF button.
  • Re-aim the camera to compose the shot as desired and shoot.
  • To release the AF Lock: Press the MF button.
  • The AF lock is convenient because you can let go of the shutter button to compose the image. Moreover, the AF lock is still effective after the picture is taken, allowing you to capture a second image with the same focus.

So, in the LUA script, i would do this:

Code: (lua) [Select]
-- get the focus and lock it (works only on S models, see S5 manual AF Lock for example)
press( "shoot_half" )
click( "mf" )
release( "shoot_half")
-- subsequent shots should now be made with this lens focus

-- ... taking a lot of shots here like this
press( "shoot_half" )
press( "shoot_full" )

-- release the AF Lock
click( "mf" )

I don't have my S5 IS at hand right now but I will try on the weekend. I wonder whether pressing shoot_half button after locking the focus will work. My guess is that it will use the focus from the lock and set the exposure time matching the set aperture in Av mode. Right?

cheers and thanks,

polarapfel

Re: Some basic questions about writing scripts for CHDK
« Reply #5 on: 14 / December / 2009, 13:14:56 »
I think CHDK implements its own aflock - in Basic it would be set_aflock(1) to lock the focus, and set_aflock(0) to release it.  So you would just do the half-press, wait a bit for it to finish focusing, and then set_aflock(1).  And I believe it stays locked through shoots and shoot_fulls until you release it with the (0).   This may work even for cameras that don't have a manual focus button.

*

Offline reyalp

  • ******
  • 14121
Re: Some basic questions about writing scripts for CHDK
« Reply #6 on: 14 / December / 2009, 15:20:13 »
Code: [Select]
-- get the focus and lock it (works only on S models, see S5 manual AF Lock for example)
press( "shoot_half" )
click( "mf" )
release( "shoot_half")
-- subsequent shots should now be made with this lens focus
The key won't be called "mf", I'm not sure which key it is on the S5. As peabody says, you should also be able to use the set_aflock function.

You may also find that AF lock is lost if the camera display turns off for power save.
« Last Edit: 14 / December / 2009, 15:22:05 by reyalp »
Don't forget what the H stands for.

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal