Meteor Intervalometer with Dark Frame Management
Talk0this wiki
This script was written to allow management of the dark frame subtraction process when taking pictures of the night sky. Currently all CHDK camera will take a "dark frame" image to subtract thermal noise whenever they take a shot more than a few seconds in duration. This dark frame takes as much time as the original exposure, so that if you are shooting for 30 seconds, there will be 30 seconds of dead time between each shot while the camera takes and process a dark frame. This script disables dark frame subtraction but manually takes a dark frame by forcing the shutter closed every so often (user defined). You can then use that dark frame to subtract out thermal noise in your PC.
forum thread > http://chdk.setepontos.com/index.php?topic=8833.msg92195#msg92195
--[[ @title Dark Frame Shooter for Meteors 2010/11/16 original script by fudgey 2012/10/18 modified by waterwingz to shoot continuously and record dark frame periocally @param n Number of Shots @default n 1000 @param r Raw On/Off (1=On/0=Off) @default r 1 @param s Shots per Dark Frame @default s 50 @param t exposure in seconds (0=auto) @default t 25 --]] propcase=require("propcase") -- Register shutter control event procs depending on os and define functions -- openshutter() and closeshutter() to control mechanical shutter. function init() set_console_layout(5, 0, 40, 14) -- check for native call interface: if (type(call_event_proc) ~= "function" ) then error("your CHDK does not support native calls") end local bi=get_buildinfo() if bi.os=="vxworks" then closeproc="CloseMShutter" openproc="OpenMShutter" if (call_event_proc("InitializeAdjustmentFunction") == -1) then error("InitAdjFunc failed") end elseif bi.os=="dryos" then closeproc="CloseMechaShutter" openproc="OpenMechaShutter" if (call_event_proc("Mecha.Create") == -1) then error("Mecha.Create failed") end else error("Unknown OS:" .. bi.os) end -- close mechanical shutter function closeshutter() if (call_event_proc(closeproc) == -1) then print("closeshutter failed") end end -- open mechanical shutter function openshutter() if (call_event_proc(openproc) == -1) then print("openshutter failed") end end -- switch to record mode if necessary if ( get_mode() == false ) then print("switching to record mode") sleep(1000) set_record(1) while ( get_mode() == false) do sleep(100) end end -- test for still photo rec mode: rec,vid=get_mode() if rec ~= true then error("Not in REC mode") elseif vid == true then error("Video not supported") end -- make sure we are in P mode capmode=require("capmode") if ( capmode.get_name() ~= "P") then error("Not in Program mode!") end -- check that flash is disabled if ( get_flash_mode() ~= 2) then error("Flash not disabled!") end -- nasty hack to turn seconds into tv96 values tv96set=0 if (t>=10) then tv96set=-320 end if (t>=15) then tv96set=-384 end if (t>=20) then tv96set=-416 end if (t>=25) then tv96set=-448 end if (t>=30) then tv96set=-480 end end -- init() -- store current exposure params (to be called during half shoot, after autoexposure has finished) function get_exposure_params() if( t>=10 ) then set_prop(propcase.TV,tv96set) -- exposure time end tv96=get_prop(propcase.TV) -- exposure time sv96=get_prop(propcase.SV) -- ISO if get_nd_present() ~= 1 then -- aperture if camera has iris --av96=get_av96() av96=get_prop(propcase.AV) print("remembering tv=",tv96,"sv=",sv96,"av=",av96) else print("remembering tv=",tv96,"sv=",sv96) end end -- set previously saved exposure params (to be called during half shoot, after autoexposure has finished) function set_exposure_params() --set_tv96_direct(tv96) -- exposure time --set_sv96(sv96) -- ISO set_prop(propcase.TV,tv96) -- exposure time set_prop(propcase.SV,sv96) -- ISO if get_nd_present() ~= 1 then -- aperture if camera has iris --set_av96_direct(av96) set_prop(propcase.AV,av96) print("overriding tv=",tv96,"sv=",sv96,"av=",av96) else print("overriding tv=",tv96,"sv=",sv96) end end --[[ Exposure parameter controlled shoot: if argument dark==false, function stores Tv, Av, Sv from this shot and shoots a real photo. If dark==true, function overrides camera exposure parameters to match previously stored ones and shoots a dark frame. Obviously one must always call this function with false before it can be called with true. --]] function expcontrol_shoot(dark) -- half shoot and wait for autoexposure (if disabled, it'll finish real fast) press("shoot_half") repeat sleep(1) until get_shooting() == true if dark == true then -- if dark frame set_exposure_params() -- set overrides closeshutter() -- close shutter sleep(1) -- wait for shutter to close (don't know if this is required) end -- take the photo press("shoot_full") sleep(1) if dark ~= true then -- normal photo, store exposure params get_exposure_params() end release("shoot_full") sleep(1) release("shoot_half") repeat sleep(1) until get_shooting() ~= true end -- restore user raw mode and dark frame reduction settings: function restore() set_raw(rawmode) set_raw_nr(dfrmode) end -- store user raw mode and dark frame reduction settings rawmode=get_raw() dfrmode=get_raw_nr() -- script starts here init() set_raw(r) -- enable RAW or DNG set_raw_nr(1) -- disable Canon's dark frame reduction j=s for i=1,n do print("shooting RAW+JPG", i, "of",n) expcontrol_shoot(false) -- shoot a photo, store its exposure params if j >= s then j=0 print("shooting a dark frame") expcontrol_shoot(true) -- shoot dark frame using stored exposure parameters else j=j+1 end end print("shooting final dark frame") expcontrol_shoot(true) restore() print("done")