CarLapse - LUA Script for timelapse out of a driving car

  • 37 Replies
  • 18343 Views
  • Publish
    CarLapse - LUA Script for timelapse out of a driving car
    « on: 13 / November / 2008, 12:18:39 »
    Advertisements
    Hi folks,

    Based uppon the "Night-time time-lapse" script (which did unfortunalty not work on cameras not offering a dedicated 'M'-Mode) I designed a time-lapse skript which is especially designed to produce time-lapse movies out of a driving car. (no 'M'-Mode enabled camera is needed) For this purpose some requirements have to be met:

     a) fast intervall (about 1 frame/sec)
     b) new EV metering for each frame (sunlight & shadow change frequently on the road)
     c) keep shutterspeeds fast (auto increase ISO if needed)

    E'Viola... the script below meets all those requiements, since you can:

     1) Specify delay between frames
     2) Specify Default ISO
     3) Specify Highest Allowed ISO
     4) Specify if you want to enable AutoISO Shift

    EV metering and ISO-shift is done for each frame! To get maximum speed disable the picture review of your camera!
    Have fun...

    P.S.: 'fb-lib' is needed. You get it if you download the "Night-time time-lapse" script
    Code: [Select]
    --[[
    @title CarLapseV2
    -- Author: careyer
    @param a Frame delay (sec)
    @default a 0

    @param b Max. TV (1/sec)
    @default b 125

    @param c Default ISO (*100)
    @default c 1

    @param d Maximum ISO (*100)
    @default d 8

    @param e Loop X times (0=endless)
    @default e 0

    @param f AutoISO (0=No,1=Yes)
    @default f 1

    @param r Focus to Inf.(0=no, 1=yes)
    @default r 0

    @param s JPG Q:-1..2=off,best..norm
    @default s -1

    @param t JPG resol.(-1=off,see doc)
    @default t -1

    @param u Startup Delay (minutes)
    @default u 0
    ]]

    require "fb-lib"
    propcase=require("propcase")

    -- verbose=1 gives more printout during shoot
    verbose=0

    min_delay=check_range(a,0,10000)
    max_tv=sec_to_tv96(check_range(b,1,65))
    default_sv=ISO_to_sv96(check_range(c,0,21)*100)
    max_sv=ISO_to_sv96(check_range(d,0,21)*100)
    maxISO = d*100

    maxISO_96 = 419
    if maxISO == 100 then
      maxISO_96 = 419
    elseif maxISO == 200 then
      maxIS0_96 = 507
    elseif maxISO == 400 then
      maxISO_96 = 603
    elseif maxISO == 800 then
      maxISO_96 = 699
    elseif maxISO == 1600 then
      maxISO_96 = 795
    end

    -- select focus distance (user specified if parameter r<=0, infinity otherwise):
    if r>0 then subjdist=65535
      else subjdist=get_focus()
    end

    -- jpg quality -1=do not change, 0=super fine, 1=fine, 2=normal,
    jpg_quality=check_range(s, -1, 2)
    if jpg_quality>-1 then
      set_prop(propcase.QUALITY, jpg_quality)
    end

    -- jpg resolution -1=do not change, others are whatever they are in your camera:
    -- For a570is Digic III: 0,1,2,3,4,6,8 = L,M1,M2,M3,S,Postcard,W
    -- For s3is   Digic  II: 0,1,2,  4,  8 = L,M1,M2,   S,         W
    -- We can probably assume those numbers are always the same, but availability may vary.
    jpg_resolution=check_range(t, -1, 8)
    if jpg_resolution>-1 then
      set_prop(propcase.RESOLUTION, jpg_resolution)
    end

    startupdelay=check_range(u, 0, 65535)

    -- startup delay if requested
    if startupdelay>0 then
      for remaining=startupdelay,1,-1 do
        print("Sleeping ", remaining, " minutes")
        sleep(29980)
        sleep(29990)
      end
    end

    -- enable shot histogram
    shot_histo_enable(1)

    -- start counting frames
    count_frames=1

    -- store script start time and disk space at the beginning:
    starttick=get_tick_count()
    startdiskspace=get_free_disk_space()

    -- next_shoot keeps the time (in get_tick_count units) when next shot should be taken.
    -- initialise next_shoot to "shoot now"
    next_shoot=0

    -- force manual focus (does this work?)
    set_prop(propcase.FOCUS_MODE,1)
    -- disable IS (dunno if this works either)
    set_prop(propcase.IS_MODE,3)
    -- use widest available aperture (I'm assuming that cameras that don't have an aperture won't respond to this in any way)
    set_prop(propcase.USER_AV,get_prop(propcase.MIN_AV))
    -- disable flash
    set_prop(propcase.FLASH_MODE,2)


     
    -- main loop. the program loops forever unless you interrupt it
    loopcounter=0
    repeat
      loopcounter = loopcounter+1
      -- now wait for the time to do next shot
      repeat
        sleep(1)
        tick=get_tick_count() 
      until tick>=next_shoot   
     
      -- Shoot: Half press and wait until camera is ready
      press("shoot_half")
      repeat
        sleep(1)
      until get_shooting() == true
      -- get metered day exposure
      bv=get_bv96()
      av=get_av96()
      tv=get_tv96()

      -- Check if shutterspeed is slower than allowed value
      maxTvAllowed = ((1000/b)-1)*96

      shoot_sv = default_sv
      difference = 0
      differenceFactor = 0
      isoString = 100
      if tv<maxTvAllowed then
        difference = maxTvAllowed - tv
        differenceFactor = difference/96
        if differenceFactor == 1     then
          isoString = 200
        elseif differenceFactor == 2 then
          isoString = 400
        elseif differenceFactor == 3 then
          isoString = 800
        elseif differenceFactor >= 4 then
          isoString = 1600
        end
      else
       isoString = 100
      end

      -- make sure maxISO gets not exeeded
      calculatedISO = default_sv+(96*differenceFactor)
      if f==1 then
        if calculatedISO<=maxISO_96 then
          shoot_sv = calculatedISO
        else
          shoot_sv = maxISO_96
    isoString = maxISO
        end
      end

      -- sv for this shot,
      set_prop(propcase.SV,shoot_sv)
      -- focus to Inf and finally press and release shutter.
      set_focus(subjdist)
      press("shoot_full")
      release("shoot_full")
      release("shoot_half")
      -- wait for shooting to finish
      repeat
        sleep(1)
      until get_shooting() ~= true         

      -- print out remaining disk space estimates in terms of frames and time:
      print(count_frames .. " at ISO " .. isoString)
       
      count_frames=count_frames+1
     
      -- we are now ready to shoot, calculate the next shot time
      next_shoot=tick + min_delay*1000

      -- return to top, where we will wait to shoot

      if (e == loopcounter) then
        break
      end
    until 1==2

    « Last Edit: 13 / November / 2008, 12:30:36 by careyer »

  • Publish
    Re: CarLapse - LUA Script for timelapse out of a driving car
    « Reply #1 on: 16 / November / 2008, 15:45:23 »
    Hello folks...

    i realized that the auto-iso adjustment within CarLapseV2 did not work correctly. I fixed the problem by doing it in a more sophisticated and nicer way in CarLapseV3 now and I added some new features:

     - you may pause the script now with the "DISP" button and resume it with the "MENU" button.
       (keep the "DISP"-button pressed until script pauses). This feature is particulary nice when waiting e.g. at a traffic light
       Helps saving storage ;-)

     - You may specify a delay until the script starts. (in seconds)

    Here's the new code:

    Code: [Select]
    --[[
    @title CarLapseV3
    -- Author: careyer
    @param a Frame delay (sec)
    @default a 0

    @param b Max. TV (1/sec)
    @default b 125

    @param c Default ISO (*100)
    @default c 1

    @param d Maximum ISO (*100)
    @default d 16

    @param e Loop X times (0=endless)
    @default e 0

    @param f AutoISO (0=No,1=Yes)
    @default f 1

    @param r Focus to Inf.(0=no, 1=yes)
    @default r 1

    @param s JPG Q:-1..2=off,best..norm
    @default s -1

    @param t JPG resol.(-1=off,see doc)
    @default t -1

    @param u Startup Delay (minutes)
    @default u 0

    @param g Startup Delay (seconds)
    @default g 2

    ]]

    -- Converting thresholdTV to TV96 representation
    -- rounding to next faster shutterspeed if needed
    thresholdTV = b
    thresholdTV96 = 0

    if thresholdTV == 2 then
    thresholdTV96 = 96
    elseif thresholdTV == 3 then
      thresholdTV96 = 160
    elseif thresholdTV == 4 then
      thresholdTV96 = 192
    elseif thresholdTV == 5 then
      thresholdTV96 = 224
    elseif thresholdTV == 6 then
      thresholdTV96 = 256
    elseif thresholdTV >= 7 and thresholdTV <=8 then
      thresholdTV96 = 288
    elseif thresholdTV >= 9 and thresholdTV <=10 then
      thresholdTV96 = 320
    elseif thresholdTV >= 11 and thresholdTV <=13 then
      thresholdTV96 = 352
    elseif thresholdTV >= 14 and thresholdTV <=15 then
      thresholdTV96 = 384
    elseif thresholdTV >= 16 and thresholdTV <=20 then
      thresholdTV96 = 416
    elseif thresholdTV >= 21 and thresholdTV <=25 then
      thresholdTV96 = 448
    elseif thresholdTV >= 26 and thresholdTV <=30 then
      thresholdTV96 = 480
    elseif thresholdTV >= 31 and thresholdTV <=40 then
      thresholdTV96 = 512
    elseif thresholdTV >= 41 and thresholdTV <=50 then
      thresholdTV96 = 544
    elseif thresholdTV >= 51 and thresholdTV <=60 then
      thresholdTV96 = 576
    elseif thresholdTV >= 61 and thresholdTV <=80 then
      thresholdTV96 = 608
    elseif thresholdTV >= 81 and thresholdTV <=100 then
      thresholdTV96 = 640
    elseif thresholdTV >= 101 and thresholdTV <=125 then
      thresholdTV96 = 672
    elseif thresholdTV >= 126 and thresholdTV <=160 then
      thresholdTV96 = 704
    elseif thresholdTV >= 161 and thresholdTV <=200 then
      thresholdTV96 = 736
    elseif thresholdTV >= 201 and thresholdTV <=250 then
      thresholdTV96 = 768
    elseif thresholdTV >= 251 and thresholdTV <=320 then
      thresholdTV96 = 800
    elseif thresholdTV >= 321 and thresholdTV <=400 then
      thresholdTV96 = 832
    elseif thresholdTV >= 401 and thresholdTV <=500 then
      thresholdTV96 = 864
    elseif thresholdTV >= 501 and thresholdTV <=640 then
      thresholdTV96 = 896
    elseif thresholdTV >= 641 and thresholdTV <=800 then
      thresholdTV96 = 928
    elseif thresholdTV >= 801 and thresholdTV <=1000 then
      thresholdTV96 = 960
    elseif thresholdTV >= 1001 and thresholdTV <=1250 then
      thresholdTV96 = 992
    elseif thresholdTV >= 1251 and thresholdTV <=1600 then
      thresholdTV96 = 1021
    elseif thresholdTV >= 1601 and thresholdTV <=2000 then
      thresholdTV96 = 1053
    end
     
    require "fb-lib"
    propcase=require("propcase")

    -- verbose=1 gives more printout during shoot
    verbose=0

    min_delay=check_range(a,0,10000)
    max_tv=sec_to_tv96(check_range(b,1,65))
    default_sv=ISO_to_sv96(check_range(c,0,21)*100)
    max_sv=ISO_to_sv96(check_range(d,0,21)*100)
    maxISO = d*100

    -- select focus distance (user specified if parameter r<=0, infinity otherwise):
    if r>0 then subjdist=65535
      else subjdist=get_focus()
    end



    -- jpg quality -1=do not change, 0=super fine, 1=fine, 2=normal,
    jpg_quality=check_range(s, -1, 2)
    if jpg_quality>-1 then
      set_prop(propcase.QUALITY, jpg_quality)
    end

    -- jpg resolution -1=do not change, others are whatever they are in your camera:
    -- For a570is Digic III: 0,1,2,3,4,6,8 = L,M1,M2,M3,S,Postcard,W
    -- For s3is   Digic  II: 0,1,2,  4,  8 = L,M1,M2,   S,         W
    -- We can probably assume those numbers are always the same, but availability may vary.
    jpg_resolution=check_range(t, -1, 8)
    if jpg_resolution>-1 then
      set_prop(propcase.RESOLUTION, jpg_resolution)
    end

    startupdelay=check_range(u, 0, 65535)
    startupdelaySec = g

    -- startup delay if requested
    if startupdelay>0 then
      for remaining=startupdelay,1,-1 do
        print("Sleeping ", remaining, " minutes")
        sleep(29980)
        sleep(29990)
      end
    end

    if startupdelaySec>0 then
      for remaining=startupdelaySec,1,-1 do
        print("Sleeping ", remaining, " seconds")
        sleep(1000)   
      end
    end




    -- enable shot histogram
    shot_histo_enable(1)

    -- start counting frames
    count_frames=1

    -- store script start time and disk space at the beginning:
    starttick=get_tick_count()
    startdiskspace=get_free_disk_space()

    -- next_shoot keeps the time (in get_tick_count units) when next shot should be taken.
    -- initialise next_shoot to "shoot now"
    next_shoot=0
     
    -- force manual focus (does this work?)
    set_prop(propcase.FOCUS_MODE,1)
    -- disable IS (dunno if this works either)
    set_prop(propcase.IS_MODE,3)
    -- use widest available aperture (I'm assuming that cameras that don't have an aperture won't respond to this in any way)
    set_prop(propcase.USER_AV,get_prop(propcase.MIN_AV))
    -- disable flash
    set_prop(propcase.FLASH_MODE,2)

     
    -- main loop. the program loops forever unless you interrupt it
    loopcounter=0
    repeat 
      wait_click(100)
      if is_pressed "display" then
        print("Paused by user")
        repeat
        wait_click(100)
        until is_pressed "menu"
        print("Continued by user")
      end
     
      loopcounter = loopcounter+1
      -- now wait for the time to do next shot
      repeat
        sleep(1)
        tick=get_tick_count() 
      until tick>=next_shoot   
     
      -- Reset ISO to default value (ISO 100)
      sv96ISO = 419
      set_sv96(sv96ISO)
     
      -- Measuring TV at default ISO
      press("shoot_half")
      repeat
        sleep(1)
      until get_shooting() == true
      -- get metered day exposure
      bv=get_bv96()
      av=get_av96()
      tv=get_tv96()
      set_focus(subjdist)
      release("shoot_half") 

      -- Check if TV slower than allowed value and raise ISO if needed 
      shoot_sv = default_sv
      difference = 0
      differenceFactor = 0
      sv96ISO = 419
      isoString = 100
     
      difference = thresholdTV96 - tv
      differenceFactor    = difference/96
      differenceRemainder = difference-(differenceFactor*96)
       
      -- Raising ISO and adjusting TV if needed
      while difference>0 and isoString<maxISO do
        difference = difference-96
        isoString = isoString*2
        sv96ISO = sv96ISO+96
        tv=tv+96
      end
     
      -- correcting TV value to match closest TV96 value
      count = 0
      while tv>32 do
       count = count+1
       tv=tv-32
      end
      tvremainder = tv
      if tvremainder >=16 then
      tv = (count*32)+32
      else
        tv = count*32
      end
     

      -- set ISO and TV for next shot,
      set_sv96(sv96ISO)
      set_tv96(tv)   
       
      press("shoot_half")
      repeat
        sleep(1)
      until get_shooting() == true
      set_focus(subjdist)
       
      press("shoot_full")
      release("shoot_full")
      release("shoot_half")
      -- wait for shooting to finish
      repeat
        sleep(1)
      until get_shooting() ~= true
     
           

      -- print out remaining disk space estimates in terms of frames and time:
      print(count_frames .." ISO " .. isoString )
       
      count_frames=count_frames+1
     
      -- we are now ready to shoot, calculate the next shot time
      next_shoot=tick + min_delay*1000

      -- return to top, where we will wait to shoot

      if (e == loopcounter) then
        break
      end
    until 1==2



    BTW:
    I'm desperatly searching for a way to disable the auto-focus so that the camera does not focus on each "half-press" command. Focusing on each picture may damage the focusing system on long timelapse sessions. Even if you set your camera to infinity-focus you will hear that it makes those typical focusing sounds coming from the lens.

    On my IXUS 70 i noticed the following:
    If I force the camera to MF-Mode by "set_prop(propcase.FOCUS_MODE,1)" and setting "set_focus(65535)" it will do
    those sounds on each pic... means it refocuses to infinity for each picture. .. BUT... when I stop the script and turn my camera to review Mode and back to photo Mode and run the script again... it will do no focusing any more... meaning that you can't hear anything from the lens. It just triggers the picture.

    Is there a way to force the camera showing this behavior right from the start without the dirty trick to change to review mode and back again to photomode?

    Any help is welcome!
    Cheers

    careyer

    *

    Offline fvdk

    • ***
    • 144
    • Ixus 70 1.01b / 1.02a & Powershot A590is 1.01b
      • My Flickr photo page
  • Publish
    Re: CarLapse - LUA Script for timelapse out of a driving car
    « Reply #2 on: 16 / November / 2008, 19:26:39 »
    Maybe a dumb question, but why not use the AFL (Auto Focus Lock) of the camera ?
    This is a standard function on the IXUS 70 model.
    I don't have the camera at hand but i think it is "half press + left"

    Frans

    *

    Offline fe50

    • ******
    • 3033
    • IXUS50 & 860, SX10 Star WARs-Star RAWs
      • fe50
  • Publish
    Re: CarLapse - LUA Script for timelapse out of a driving car
    « Reply #3 on: 16 / November / 2008, 19:37:48 »
    Maybe a dumb question, but why not use the AFL (Auto Focus Lock) of the camera ?
    This is a standard function on the IXUS 70 model.
    I don't have the camera at hand but i think it is "half press + left"

    Yep, see also Disable focusing......


  • Publish
    Re: CarLapse - LUA Script for timelapse out of a driving car
    « Reply #4 on: 16 / November / 2008, 23:57:42 »
    Thanks guys! Setting the AFL in CarLapseV4 now! - Script working nice and fast now :-)

    Code: [Select]
    --[[
    @title CarLapseV4
    -- Author: careyer
    @param a Frame delay (sec)
    @default a 0

    @param b Max. TV (1/sec)
    @default b 125

    @param c Default ISO (*100)
    @default c 1

    @param d Maximum ISO (*100)
    @default d 16

    @param e Loop X times (0=endless)
    @default e 0

    @param f AutoISO (0=No,1=Yes)
    @default f 1

    @param r Focus to Inf.(0=no, 1=yes)
    @default r 1

    @param s JPG Q:-1..2=off,best..norm
    @default s -1

    @param t JPG resol.(-1=off,see doc)
    @default t -1

    @param u Startup Delay (minutes)
    @default u 0

    @param g Startup Delay (seconds)
    @default g 2

    ]]

    -- Converting thresholdTV to TV96 representation
    -- rounding to next faster shutterspeed if needed
    thresholdTV = b
    thresholdTV96 = 0

    if thresholdTV == 2 then
    thresholdTV96 = 96
    elseif thresholdTV == 3 then
      thresholdTV96 = 160
    elseif thresholdTV == 4 then
      thresholdTV96 = 192
    elseif thresholdTV == 5 then
      thresholdTV96 = 224
    elseif thresholdTV == 6 then
      thresholdTV96 = 256
    elseif thresholdTV >= 7 and thresholdTV <=8 then
      thresholdTV96 = 288
    elseif thresholdTV >= 9 and thresholdTV <=10 then
      thresholdTV96 = 320
    elseif thresholdTV >= 11 and thresholdTV <=13 then
      thresholdTV96 = 352
    elseif thresholdTV >= 14 and thresholdTV <=15 then
      thresholdTV96 = 384
    elseif thresholdTV >= 16 and thresholdTV <=20 then
      thresholdTV96 = 416
    elseif thresholdTV >= 21 and thresholdTV <=25 then
      thresholdTV96 = 448
    elseif thresholdTV >= 26 and thresholdTV <=30 then
      thresholdTV96 = 480
    elseif thresholdTV >= 31 and thresholdTV <=40 then
      thresholdTV96 = 512
    elseif thresholdTV >= 41 and thresholdTV <=50 then
      thresholdTV96 = 544
    elseif thresholdTV >= 51 and thresholdTV <=60 then
      thresholdTV96 = 576
    elseif thresholdTV >= 61 and thresholdTV <=80 then
      thresholdTV96 = 608
    elseif thresholdTV >= 81 and thresholdTV <=100 then
      thresholdTV96 = 640
    elseif thresholdTV >= 101 and thresholdTV <=125 then
      thresholdTV96 = 672
    elseif thresholdTV >= 126 and thresholdTV <=160 then
      thresholdTV96 = 704
    elseif thresholdTV >= 161 and thresholdTV <=200 then
      thresholdTV96 = 736
    elseif thresholdTV >= 201 and thresholdTV <=250 then
      thresholdTV96 = 768
    elseif thresholdTV >= 251 and thresholdTV <=320 then
      thresholdTV96 = 800
    elseif thresholdTV >= 321 and thresholdTV <=400 then
      thresholdTV96 = 832
    elseif thresholdTV >= 401 and thresholdTV <=500 then
      thresholdTV96 = 864
    elseif thresholdTV >= 501 and thresholdTV <=640 then
      thresholdTV96 = 896
    elseif thresholdTV >= 641 and thresholdTV <=800 then
      thresholdTV96 = 928
    elseif thresholdTV >= 801 and thresholdTV <=1000 then
      thresholdTV96 = 960
    elseif thresholdTV >= 1001 and thresholdTV <=1250 then
      thresholdTV96 = 992
    elseif thresholdTV >= 1251 and thresholdTV <=1600 then
      thresholdTV96 = 1021
    elseif thresholdTV >= 1601 and thresholdTV <=2000 then
      thresholdTV96 = 1053
    end
     
    require "fb-lib"
    propcase=require("propcase")

    -- verbose=1 gives more printout during shoot
    verbose=0

    min_delay=check_range(a,0,10000)
    max_tv=sec_to_tv96(check_range(b,1,65))
    default_sv=ISO_to_sv96(check_range(c,0,21)*100)
    max_sv=ISO_to_sv96(check_range(d,0,21)*100)
    maxISO = d*100

    -- select focus distance (user specified if parameter r<=0, infinity otherwise):
    if r>0 then subjdist=65535
      else subjdist=get_focus()
    end



    -- jpg quality -1=do not change, 0=super fine, 1=fine, 2=normal,
    jpg_quality=check_range(s, -1, 2)
    if jpg_quality>-1 then
      set_prop(propcase.QUALITY, jpg_quality)
    end

    -- jpg resolution -1=do not change, others are whatever they are in your camera:
    -- For a570is Digic III: 0,1,2,3,4,6,8 = L,M1,M2,M3,S,Postcard,W
    -- For s3is   Digic  II: 0,1,2,  4,  8 = L,M1,M2,   S,         W
    -- We can probably assume those numbers are always the same, but availability may vary.
    jpg_resolution=check_range(t, -1, 8)
    if jpg_resolution>-1 then
      set_prop(propcase.RESOLUTION, jpg_resolution)
    end

    startupdelay=check_range(u, 0, 65535)
    startupdelaySec = g

    -- startup delay if requested
    if startupdelay>0 then
      for remaining=startupdelay,1,-1 do
        print("Sleeping ", remaining, " minutes")
        sleep(29980)
        sleep(29990)
      end
    end

    if startupdelaySec>0 then
      for remaining=startupdelaySec,1,-1 do
        print("Sleeping ", remaining, " seconds")
        sleep(1000)   
      end
    end




    -- enable shot histogram
    shot_histo_enable(1)

    -- start counting frames
    count_frames=1

    -- store script start time and disk space at the beginning:
    starttick=get_tick_count()
    startdiskspace=get_free_disk_space()

    -- next_shoot keeps the time (in get_tick_count units) when next shot should be taken.
    -- initialise next_shoot to "shoot now"
    next_shoot=0
     
    -- force manual focus (does this work?)
    set_prop(propcase.FOCUS_MODE,1)
    -- disable IS (dunno if this works either)
    set_prop(propcase.IS_MODE,3)
    -- use widest available aperture (I'm assuming that cameras that don't have an aperture won't respond to this in any way)
    set_prop(propcase.USER_AV,get_prop(propcase.MIN_AV))
    -- disable flash
    set_prop(propcase.FLASH_MODE,2)


    -- initializing Focus: setting Focus-Lock
    press("shoot_half")
    repeat
     sleep(1)
    until get_shooting() == true
    set_focus(subjdist)
    sleep(1000)
    press("left")
    sleep(100)
    release("left")
    release("shoot_half")


    -- main loop. the program loops forever unless you interrupt it
    loopcounter=0
    repeat 
      wait_click(100)
      if is_pressed "display" then
        print("Paused by user")
        repeat
        wait_click(100)
        until is_pressed "menu"
        print("Continued by user")
      end
     
      loopcounter = loopcounter+1
      -- now wait for the time to do next shot
      repeat
        sleep(1)
        tick=get_tick_count() 
      until tick>=next_shoot   
     
      -- Reset ISO to default value (ISO 100)
      sv96ISO = 419
      set_sv96(sv96ISO)
     
      -- Measuring TV at default ISO
      press("shoot_half")
      repeat
        sleep(1)
      until get_shooting() == true
      -- get metered day exposure
      bv=get_bv96()
      av=get_av96()
      tv=get_tv96()
      release("shoot_half") 

      -- Check if TV slower than allowed value and raise ISO if needed 
      shoot_sv = default_sv
      difference = 0
      differenceFactor = 0
      sv96ISO = 419
      isoString = 100
     
      difference = thresholdTV96 - tv
      differenceFactor    = difference/96
      differenceRemainder = difference-(differenceFactor*96)
       
      -- Raising ISO and adjusting TV if needed
      while difference>0 and isoString<maxISO do
        difference = difference-96
        isoString = isoString*2
        sv96ISO = sv96ISO+96
        tv=tv+96
      end
     
      -- correcting TV value to match closest TV96 value
      count = 0
      while tv>32 do
       count = count+1
       tv=tv-32
      end
      tvremainder = tv
      if tvremainder >=16 then
      tv = (count*32)+32
      else
        tv = count*32
      end
     

      -- set ISO and TV for next shot,
      set_sv96(sv96ISO)
      set_tv96(tv)   
       
      press("shoot_half")
      repeat
        sleep(1)
      until get_shooting() == true
      set_focus(subjdist)
       
      press("shoot_full")
      release("shoot_full")
      release("shoot_half")
      -- wait for shooting to finish
      repeat
        sleep(1)
      until get_shooting() ~= true
     
           

      -- print out remaining disk space estimates in terms of frames and time:
      print(count_frames .." ISO " .. isoString )
       
      count_frames=count_frames+1
     
      -- we are now ready to shoot, calculate the next shot time
      next_shoot=tick + min_delay*1000

      -- return to top, where we will wait to shoot

      if (e == loopcounter) then
        break
      end
    until 1==2



  • Publish
    Re: CarLapse - LUA Script for timelapse out of a driving car
    « Reply #5 on: 20 / November / 2008, 18:01:10 »
    Hello again,

    I've improved the script a bit further. In CarLapseV4 I introduced the possibility to PAUSE and RESUME the shooting by button-presses. That's a nice feature when you are waiting at red traffic lights or get into a traffic jam. CarLapseV5 now uses "Motion Detection" to automatically realize if you are in movement with your car or not... If you are not (e.g. when you are waiting at traffic lights) it will PAUSE and RESUME shooting instantly when you start driving again. :-)

    Here's the script :-)

    Code: [Select]
    --[[
    @title CarLapseV5
    -- Author: careyer
    @param a Frame delay (sec)
    @default a 0

    @param b Max. TV (1/sec)
    @default b 125

    @param c Default ISO (*100)
    @default c 1

    @param d Maximum ISO (*100)
    @default d 16

    @param e Loop X times (0=endless)
    @default e 0

    @param f AutoISO (0=No,1=Yes)
    @default f 1

    @param h Pause on MD (0=No,1=Yes)
    @default h 1

    @param p Check every X frame
    @default p 10

    @param i MD colums      (def: 6)
    @default i 6

    @param j MD rows        (def: 4)
    @default j 4

    @param k MD first colum (def: 3)
    @default k 3

    @param l MD last  colum (def: 4)
    @default l 4

    @param m MD first row   (def: 2)
    @default m 2

    @param n MD last row    (def: 3)
    @default n 3

    @param r Focus to Inf.(0=no, 1=yes)
    @default r 1

    @param s JPG Q:-1..2=off,best..norm
    @default s -1

    @param t JPG resol.(-1=off,see doc)
    @default t -1

    @param g Startup Delay (seconds)
    @default g 2

    @param u Startup Delay (minutes)
    @default u 0


    ]]


    -- Converting thresholdTV to TV96 representation
    -- rounding to next faster shutterspeed if needed
    thresholdTV = b
    thresholdTV96 = 0

    if thresholdTV == 2 then
    thresholdTV96 = 96
    elseif thresholdTV == 3 then
      thresholdTV96 = 160
    elseif thresholdTV == 4 then
      thresholdTV96 = 192
    elseif thresholdTV == 5 then
      thresholdTV96 = 224
    elseif thresholdTV == 6 then
      thresholdTV96 = 256
    elseif thresholdTV >= 7 and thresholdTV <=8 then
      thresholdTV96 = 288
    elseif thresholdTV >= 9 and thresholdTV <=10 then
      thresholdTV96 = 320
    elseif thresholdTV >= 11 and thresholdTV <=13 then
      thresholdTV96 = 352
    elseif thresholdTV >= 14 and thresholdTV <=15 then
      thresholdTV96 = 384
    elseif thresholdTV >= 16 and thresholdTV <=20 then
      thresholdTV96 = 416
    elseif thresholdTV >= 21 and thresholdTV <=25 then
      thresholdTV96 = 448
    elseif thresholdTV >= 26 and thresholdTV <=30 then
      thresholdTV96 = 480
    elseif thresholdTV >= 31 and thresholdTV <=40 then
      thresholdTV96 = 512
    elseif thresholdTV >= 41 and thresholdTV <=50 then
      thresholdTV96 = 544
    elseif thresholdTV >= 51 and thresholdTV <=60 then
      thresholdTV96 = 576
    elseif thresholdTV >= 61 and thresholdTV <=80 then
      thresholdTV96 = 608
    elseif thresholdTV >= 81 and thresholdTV <=100 then
      thresholdTV96 = 640
    elseif thresholdTV >= 101 and thresholdTV <=125 then
      thresholdTV96 = 672
    elseif thresholdTV >= 126 and thresholdTV <=160 then
      thresholdTV96 = 704
    elseif thresholdTV >= 161 and thresholdTV <=200 then
      thresholdTV96 = 736
    elseif thresholdTV >= 201 and thresholdTV <=250 then
      thresholdTV96 = 768
    elseif thresholdTV >= 251 and thresholdTV <=320 then
      thresholdTV96 = 800
    elseif thresholdTV >= 321 and thresholdTV <=400 then
      thresholdTV96 = 832
    elseif thresholdTV >= 401 and thresholdTV <=500 then
      thresholdTV96 = 864
    elseif thresholdTV >= 501 and thresholdTV <=640 then
      thresholdTV96 = 896
    elseif thresholdTV >= 641 and thresholdTV <=800 then
      thresholdTV96 = 928
    elseif thresholdTV >= 801 and thresholdTV <=1000 then
      thresholdTV96 = 960
    elseif thresholdTV >= 1001 and thresholdTV <=1250 then
      thresholdTV96 = 992
    elseif thresholdTV >= 1251 and thresholdTV <=1600 then
      thresholdTV96 = 1021
    elseif thresholdTV >= 1601 and thresholdTV <=2000 then
      thresholdTV96 = 1053
    end
     
    require "fb-lib"
    propcase=require("propcase")

    -- verbose=1 gives more printout during shoot
    verbose=0

    min_delay=check_range(a,0,10000)
    max_tv=sec_to_tv96(check_range(b,1,65))
    default_sv=ISO_to_sv96(check_range(c,0,21)*100)
    max_sv=ISO_to_sv96(check_range(d,0,21)*100)
    maxISO = d*100

    -- select focus distance (user specified if parameter r<=0, infinity otherwise):
    if r>0 then subjdist=65535
      else subjdist=get_focus()
    end



    -- jpg quality -1=do not change, 0=super fine, 1=fine, 2=normal,
    jpg_quality=check_range(s, -1, 2)
    if jpg_quality>-1 then
      set_prop(propcase.QUALITY, jpg_quality)
    end

    -- jpg resolution -1=do not change, others are whatever they are in your camera:
    -- For a570is Digic III: 0,1,2,3,4,6,8 = L,M1,M2,M3,S,Postcard,W
    -- For s3is   Digic  II: 0,1,2,  4,  8 = L,M1,M2,   S,         W
    -- We can probably assume those numbers are always the same, but availability may vary.
    jpg_resolution=check_range(t, -1, 8)
    if jpg_resolution>-1 then
      set_prop(propcase.RESOLUTION, jpg_resolution)
    end

    startupdelay=check_range(u, 0, 65535)
    startupdelaySec = g

    -- startup delay if requested
    if startupdelay>0 then
      for remaining=startupdelay,1,-1 do
        print("Sleeping ", remaining, " minutes")
        sleep(29980)
        sleep(29990)
      end
    end

    if startupdelaySec>0 then
      for remaining=startupdelaySec,1,-1 do
        print("Sleeping ", remaining, " seconds")
        sleep(1000)   
      end
    end




    -- enable shot histogram
    shot_histo_enable(1)

    -- start counting frames
    count_frames=1

    -- store script start time and disk space at the beginning:
    starttick=get_tick_count()
    startdiskspace=get_free_disk_space()

    -- next_shoot keeps the time (in get_tick_count units) when next shot should be taken.
    -- initialise next_shoot to "shoot now"
    next_shoot=0
     
    -- force manual focus (does this work?)
    set_prop(propcase.FOCUS_MODE,1)
    -- disable IS (dunno if this works either)
    set_prop(propcase.IS_MODE,3)
    -- use widest available aperture (I'm assuming that cameras that don't have an aperture won't respond to this in any way)
    set_prop(propcase.USER_AV,get_prop(propcase.MIN_AV))
    -- disable flash
    set_prop(propcase.FLASH_MODE,2)


    -- initializing Focus: setting Focus-Lock
    press("shoot_half")
    repeat
     sleep(1)
    until get_shooting() == true
    set_focus(subjdist)
    sleep(1000)
    press("left")
    sleep(100)
    release("left")
    release("shoot_half")


    -- main loop. the program loops forever unless you interrupt it
    loopcounter=0
    mdcounter=0
    repeat
      mdcounter=mdcounter+1 
      wait_click(100)
      if is_pressed "display" then
        print("Paused by user")
        repeat
        wait_click(100)
        until is_pressed "menu"
        print("Continued by user")
      end
     
      loopcounter = loopcounter+1
      -- now wait for the time to do next shot
      repeat
        sleep(1)
        tick=get_tick_count() 
      until tick>=next_shoot   
     
      -- Reset ISO to default value (ISO 100)
      sv96ISO = 419
      set_sv96(sv96ISO)
     
      -- Measuring TV at default ISO
      press("shoot_half")
      repeat
        sleep(1)
      until get_shooting() == true
      -- get metered day exposure
      bv=get_bv96()
      av=get_av96()
      tv=get_tv96()
      t = 0
      -- Detect Motion ---
      if h>0 and mdcounter==p then
    repeat
    sleep(1)
    t = md_detect_motion(i, j, 1, 40, 15, 5, 1, t, 1, k, m, l, n, 0, 6, 0)
    until t>0
    mdcounter=0
      end
      release("shoot_half") 

      -- Check if TV slower than allowed value and raise ISO if needed 
      shoot_sv = default_sv
      difference = 0
      differenceFactor = 0
      sv96ISO = 419
      isoString = 100
     
      difference = thresholdTV96 - tv
      differenceFactor    = difference/96
      differenceRemainder = difference-(differenceFactor*96)
       
      -- Raising ISO and adjusting TV if needed
      while difference>0 and isoString<maxISO do
        difference = difference-96
        isoString = isoString*2
        sv96ISO = sv96ISO+96
        tv=tv+96
      end
     
      -- correcting TV value to match closest TV96 value
      count = 0
      while tv>32 do
       count = count+1
       tv=tv-32
      end
      tvremainder = tv
      if tvremainder >=16 then
      tv = (count*32)+32
      else
        tv = count*32
      end
     

      -- set ISO and TV for next shot,
      set_sv96(sv96ISO)
      set_tv96(tv)   
       
      press("shoot_half")
      repeat
        sleep(1)
      until get_shooting() == true
      set_focus(subjdist)
       
      press("shoot_full")
      release("shoot_full")
      release("shoot_half")
      -- wait for shooting to finish
      repeat
        sleep(1)
      until get_shooting() ~= true
     
           

      -- print out remaining disk space estimates in terms of frames and time:
      print(count_frames .." ISO " .. isoString )
       
      count_frames=count_frames+1
     
      -- we are now ready to shoot, calculate the next shot time
      next_shoot=tick + min_delay*1000

      -- return to top, where we will wait to shoot

      if (e == loopcounter) then
        break
      end
    until 1==2


    BTW: You can of course configure in what time interval the script will check if you are still in movement. To keep the intervalls short you should not check on every frame.

    Cheers!

  • Publish
    Re: CarLapse - LUA Script for timelapse out of a driving car
    « Reply #6 on: 24 / December / 2008, 13:25:45 »
    careyer
    I've trying to run your script, but I get an error
    *STARTED*
    :132. module 'fb-lib' notfound: oono field package .preload ['fb-lib]
    press shutter to close

    I've been trying to download the night-time night-lapse to get the fb-lib from it, but I can't find it anywhere.
    please can you give some advice.
    thanks for your time and happy holidays.


  • Publish
    Re: CarLapse - LUA Script for timelapse out of a driving car
    « Reply #7 on: 24 / December / 2008, 14:01:08 »
    careyer
    never mind I figured it out. I found the Fb-lib and placed it on the lua folder and started to work. i have 3 hours drive to my mother in law. I will test it . thank you for the script.


  • Publish
    Re: CarLapse - LUA Script for timelapse out of a driving car
    « Reply #8 on: 24 / December / 2008, 14:01:52 »
    if somebody has the same problem go here to download the fb-lib.
    Night-time time-lapse


    *

    Offline whim

    • ******
    • 2013
    • A495/590/620/630 ixus70/115/220/230/300/870 S95
  • Publish
    Re: CarLapse - LUA Script for timelapse out of a driving car
    « Reply #9 on: 24 / December / 2008, 14:02:16 »
    LOL had just D/L it for a shot at CarLapse

    see attach.

    cheers,

    wim

     

    Related Topics