CHDK Wiki
(Initial documentation for shoot hooks)
(No difference)

Revision as of 03:48, 19 May 2014

Introduction

CHDK 1.3 adds "hooks" which allow Lua scripts pause the shooting process when certain point are reached.

CHDK 1.3 is the unstable development branch, so this interface is subject to change. Please use the development thread http://chdk.setepontos.com/index.php?topic=11081.msg108530#msg108530 for feedback and bug reports.

Available hooks

There are currently 3 hooks defined (in order of execution)

hook_preshoot

Executes in shooting_expo_param_override, after CHDK overrides are applied. Can be used to adjust exposure settings after the camera has calculated it's own values. This hook only executes once per half press cycle, so if shooting in continuous mode, it will only be reached once before the continuous burst starts.

hook_shutter

Executes very shortly before the shutter would open, in wait_until_remote_button_is_released (prior to the actual remote check). Can used to control the start of the exposure, to synchronize with an external process or to make continuous mode shoot at a specific interval.

Adjusting exposure, focus and zoom parameters here is not recommended. Exposure parameters will generally not take effect for the current shot. Zoom or focus may work, but the camera would not normally expect them to be manipulated at this point.

hook_raw

Executes in raw_process, after shot_histogram has built the raw histogram and DNG exif has been captured, but before any raw or DNG file has been written. It can be used to adjust the exposure for a following shot in continuous mode. In the future, the ability to directly read and write the raw buffer will be added.

Hook functions

Each of the hook is available in Lua as a table which contains a standard set of functions:

hook.set(timeout)

Enables the hook, so it will block the shooting process for up to timeout milliseconds. 0 disables the hook. Hooks are cleared when a script ends. They are not cleared between shots.

hook.is_ready()

returns true when the shooting process is in the hook, if the hook as been set.

hook.continue()

Allows the shooting process to continue from the hook point.

hook.count()

Returns a count of how many times the hook has been reached for this script. This allows you to tell if a particular point has been reached without actually blocking the process.

Known issues

Setting ISO in hook_preshoot may not work correctly on some cameras (those that require shooting_expo_iso_override in the capt_seq code)

A few ports may call shooting_expo_param_override more than once. On these ports, hook_preshoot will also be called more than once per shot.

A few ports may be missing wait_until_remote_button_is_released. On these ports, hook_shutter will not be reached.

There is no simple way to tell if a hook timed out.

Lua code may wait indefinitely for a hook that never becomes ready (for example, if shooting failed to start), unless it implements it's own timeout.