Wikia

CHDK Wiki

Changes: Meteor Intervalometer with Dark Frame Management

Edit

Back to page

m (sleep(1) is not useable)
(added srsa_4c's fix for early DryOS cameras to the script)
 
(4 intermediate revisions by one user not shown)
Line 1: Line 1:
 
This script was designed to enable management of the "dark frame" subtraction process when taking pictures of the night sky. Currently all CHDK cameras take a dark frame image to subtract thermal noise whenever a shot of more than a few seconds in duration is taken. This dark frame takes as much time as the original exposure, so that for every shot of 30 s duration, there will be 30 s of dead time in between while the camera takes and processes a dark frame. This script generally disables the dark frame process but allows a dark frame to be taken very now and then by forcing the shutter to be closed (as determined by the user). This dark frame cam be used to subtract out thermal noise when processing images on a PC.
 
This script was designed to enable management of the "dark frame" subtraction process when taking pictures of the night sky. Currently all CHDK cameras take a dark frame image to subtract thermal noise whenever a shot of more than a few seconds in duration is taken. This dark frame takes as much time as the original exposure, so that for every shot of 30 s duration, there will be 30 s of dead time in between while the camera takes and processes a dark frame. This script generally disables the dark frame process but allows a dark frame to be taken very now and then by forcing the shutter to be closed (as determined by the user). This dark frame cam be used to subtract out thermal noise when processing images on a PC.
   
  +
{{notice |Running this script requires Lua native calls to be enabled. Use the '''CHDK Miscellaneous Stuff''' -> '''Enable Lua Native Calls? [ * ]''' menu item. }}
  +
{{notice |An updated version of this script is available here : [https://app.box.com/s/9t0b45z3ugamkz08s0gk meteor2.lua]}}
 
<span style="font-size:13px;line-height:21px;">'''Pro Tip ''':  from </span>[https://www.facebook.com/alex.varakin.1 Alex Varakin]<span id=".reactRoot[952170].[2]{comment10152967240100037_10152969169055037}.[1:0].[4:0:1].[3:1].[4:0:1].[1:1].[1:0].[1]" style="color:rgb(51,51,51);font-family:'lucidagrande',tahoma,verdana,arial,sans-serif;font-size:11px;line-height:14px;">  on [https://www.facebook.com/groups/CHDK.Users/ FaceBook CHDK Users Page]   I</span><span data-ft="{"tn":"K"}" id=".reactRoot[952170].[2]{comment10152967240100037_10152969169055037}.[1:0].[4:0:1].[3:1].[4:0:1].[1:1].[1:0].[1:0:2]" style="color:rgb(51,51,51);font-family:'lucidagrande',tahoma,verdana,arial,sans-serif;font-size:11px;line-height:14px;">deally, you want to take at least 5 darks and then combine them using median. If you combine them using just average, then you need to take at least 10 darks</span>
 
<span style="font-size:13px;line-height:21px;">'''Pro Tip ''':  from </span>[https://www.facebook.com/alex.varakin.1 Alex Varakin]<span id=".reactRoot[952170].[2]{comment10152967240100037_10152969169055037}.[1:0].[4:0:1].[3:1].[4:0:1].[1:1].[1:0].[1]" style="color:rgb(51,51,51);font-family:'lucidagrande',tahoma,verdana,arial,sans-serif;font-size:11px;line-height:14px;">  on [https://www.facebook.com/groups/CHDK.Users/ FaceBook CHDK Users Page]   I</span><span data-ft="{"tn":"K"}" id=".reactRoot[952170].[2]{comment10152967240100037_10152969169055037}.[1:0].[4:0:1].[3:1].[4:0:1].[1:1].[1:0].[1:0:2]" style="color:rgb(51,51,51);font-family:'lucidagrande',tahoma,verdana,arial,sans-serif;font-size:11px;line-height:14px;">deally, you want to take at least 5 darks and then combine them using median. If you combine them using just average, then you need to take at least 10 darks</span>
   
<span style="font-size:13px;line-height:21px;">forum thread >  </span>http://chdk.setepontos.com/index.php?topic=8833.msg92195#msg92195<span style="font-size:13px;line-height:21px;"> </span><span style="font-size:13px;line-height:21px;"> </span><syntaxhighlight lang="lua">
+
<span style="font-size:13px;line-height:21px;">forum thread >  </span>http://chdk.setepontos.com/index.php?topic=8833.msg92195#msg92195<span style="font-size:13px;line-height:21px;"> </span><span style="font-size:13px;line-height:21px;"> </span>
  +
  +
'''Note:''' save this file as ''meteor.lua''
  +
<syntaxhighlight lang="lua">
 
--[[
 
--[[
 
@title Dark Frame Shooter for Meteors
 
@title Dark Frame Shooter for Meteors
 
2010/11/16 original script by fudgey
 
2010/11/16 original script by fudgey
 
2012/10/18 modified by waterwingz to shoot continuously and record dark frame periocally
 
2012/10/18 modified by waterwingz to shoot continuously and record dark frame periocally
  +
2013/08/28 update to extend shutter speed range from 30 seconds out to 60 seconds
  +
2013/12/23 update to support early DryOS cameras
   
 
@param n Number of Shots
 
@param n Number of Shots
Line 44: Line 48:
 
openproc="OpenMechaShutter"
 
openproc="OpenMechaShutter"
 
if (call_event_proc("Mecha.Create") == -1) then
 
if (call_event_proc("Mecha.Create") == -1) then
error("Mecha.Create failed")
+
if (call_event_proc("MechaRegisterEventProcedure") == -1) then
  +
error("Mecha.Create failed")
  +
end
 
end
 
end
 
else
 
else
Line 100: Line 104:
 
if (t>=25) then tv96set=-448 end
 
if (t>=25) then tv96set=-448 end
 
if (t>=30) then tv96set=-480 end
 
if (t>=30) then tv96set=-480 end
  +
if (t>=40) then tv96set=-512 end
  +
if (t>=50) then tv96set=-544 end
  +
  if (t>=60) then tv96set=-576 end
   
 
end -- init()
 
end -- init()

Latest revision as of 01:46, April 19, 2014

This script was designed to enable management of the "dark frame" subtraction process when taking pictures of the night sky. Currently all CHDK cameras take a dark frame image to subtract thermal noise whenever a shot of more than a few seconds in duration is taken. This dark frame takes as much time as the original exposure, so that for every shot of 30 s duration, there will be 30 s of dead time in between while the camera takes and processes a dark frame. This script generally disables the dark frame process but allows a dark frame to be taken very now and then by forcing the shutter to be closed (as determined by the user). This dark frame cam be used to subtract out thermal noise when processing images on a PC.

Notice

Running this script requires Lua native calls to be enabled. Use the CHDK Miscellaneous Stuff -> Enable Lua Native Calls? [ * ] menu item.

Notice

An updated version of this script is available here : meteor2.lua

Pro Tip :  from Alex Varakin  on FaceBook CHDK Users Page   Ideally, you want to take at least 5 darks and then combine them using median. If you combine them using just average, then you need to take at least 10 darks

forum thread >  http://chdk.setepontos.com/index.php?topic=8833.msg92195#msg92195

Note: save this file as meteor.lua

--[[
@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
2013/08/28 update to extend shutter speed range from 30 seconds out to 60 seconds
2013/12/23 update to support early DryOS cameras
 
@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
      if (call_event_proc("MechaRegisterEventProcedure") == -1) then
        error("Mecha.Create failed")
      end
    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
  if (t>=40) then tv96set=-512 end
  if (t>=50) then tv96set=-544 end
  if (t>=60) then tv96set=-576 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(10)
  until get_shooting() == true
 
  if dark == true then -- if dark frame    
    set_exposure_params() -- set overrides
    closeshutter() -- close shutter
    sleep(10) -- wait for shutter to close (don't know if this is required)
  end
 
  -- take the photo
  press("shoot_full")
  sleep(10)
 
  if dark ~= true then -- normal photo, store exposure params
    get_exposure_params()
  end
 
  release("shoot_full")
  sleep(10)
  release("shoot_half")
  repeat
    sleep(10)
  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")

Around Wikia's network

Random Wiki