Timelapse with variable shutter speed - page 11 - Completed and Working Scripts - CHDK Forum

Timelapse with variable shutter speed

  • 151 Replies
  • 93926 Views
*

Offline fbonomi

  • ****
  • 469
  • A570IS SD1100/Ixus80
    • Francesco Bonomi
Re: Timelapse with variable shutter speed
« Reply #100 on: 25 / May / 2008, 03:04:59 »
Advertisements
This is the script I used:

Code: [Select]
@title Sunset12
rem Script to shoot time-lapse videos of sunsets
rem v. 12, Fbonomi may 22nd 2008
rem Released under GPL
rem incorporates feedback from previous shot: if more than 10% of pixels
rem are in the 100-800 range, decrease exposure
rem also, if the median of the frame is above 250, the exposure
rem is decreased faster

@param a Delay (sec)
@default a 5

@param b Limit Tv
@default b -414
rem (-414=20 sec; -384=15 sec; -320=10 sec; -224=5 sec.)

@param c Default Sv
@default c 480
rem (480=160)

@param d Limit Sv
@default d 776
rem (776=1250 ISO; 960=5000)

@param e Guess mode limit
@default e -200

@param f Slope in guess mode
@default f 5


print_screen 1

print "Sunset Time Lapse"

rem initialize guess mode value
x=e

rem get start Tv
get_tv96 N


rem picture counter
p=1

rem initialize delay start time to a long time ago
k= 0 - (a*2000)

rem exposure factors of previous shot
h=0
j=300

rem mark "FIFO BUFFER EMPTY"
Z=-1

:loop

rem measure luminance and aperture
press "shoot_half"
sleep 500
release "shoot_half"
get_bv96 B
get_av96 A
rem release "shoot_half"

print "Measured: ",B ,A

rem resulting Tv would be:
N=B-A
N=N+c

print "Calculated T: ", N

rem check Tv Values

rem per vedere se siamo ai limiti del sensore,
rem invece di controllare N, sarebbe meglio controllare B

if N>e then
 rem normal mode, shoot with calculated Tv and default Sc
 M=N
 L=c
 print "Mode: Standard"
else
 rem Guess mode, every shot will be 5/96th steps longer
 x=x-f

 rem but if last exposure was over-exposed, don't decrease,
 rem and instead increase at twice the speed
 if h>10 then
  x=x+f+f
  print "Compensating ", h, x
 endif

 rem If image is highly over-exposed, then step up the speed of decreasing the exposure
 rem j is the percentage of pixels that were in the 0-250 range (set below)
 rem If less than 50% of pixels are in that range, the median of the histogram
 rem is above 250: this means the image is very overexposed
 rem (probably because luminance was rising very fast).
 rem We therefore have to decrease exposure much faster!
 if j < 50 then
  x=x+(f*5)
  print "Over-compensating ", j, x
 endif

 rem x has now the desired exposure, we will now attempt
 rem to smooth its value (mobile average over 10 shots)
 rem the last 10 values of x are stored in a FIFO buffer
 rem made by variables Q to Z

 rem The first time we are here, the FIFO buffer will be empty
 rem let's initialize it
 if Z=-1 then
  Q=x
  R=x
  S=x
  T=x
  U=x
  V=x
  W=x
  X=x
  Y=x
  Z=x
 endif

 rem feed the buffer
 Z=Y
 Y=X
 X=W
 W=V
 V=U
 U=T
 T=S
 S=R
 R=Q
 Q=x

 rem calculate the average of values stored in FIFO buffer
 P=   Q+Q+Q+Q+Q
 P=P +R+R+R+R
 P=P +S+S+S
 P=P +T+T
 P=P +U

 P=P/15

 print "Smoothed ",x, " ", P

 rem P now contains a smoothed value of what was in x

 rem avoid overcompensating (guess mode climbing over guess mode limit)
 if P>e then
  P=e
 endif

 
 if P>b then
  print "Mode: Guess ", P ,b
  rem we are in dark, but exposure is not too long
  rem normal mode, shoot with guessed Tv and default Sc
  M=P
  L=c
 else
  print "Mode: Guess with High ISO", P ,b

  rem we are in very dark area, we want to avoid too long exposures
  rem shoot with maximum allowed time (b) and
  rem adjust Sv accordingly

  M=b
  L=c+b-P
 
  rem BUT check we don't go in too high ISO!
  if L>d then
   L=d
  endif
 
 
 endif
 
endif


rem wait until a*1000 ticks have occurred since
rem the beginning of previous shot


w=k+(a*1000)
print "wait: start ",k, w
do

until get_tick_count>=w

k=get_tick_count
print "wait: done", k

rem remember when we started the shoot sequence
rem (so next time we can measure the elapsed time)



rem we can now shoot
sleep 100
set_sv96 L
sleep 100
set_tv96_direct M
sleep 100
shoot
sleep 100
rem let's read histogram of the shot that was just taken
exp_get_info 100 800 h
rem h contains the percentage of pixels that are between 100/1024 and 800/1024

exp_get_info 0 250 j
rem j contains the percentage of pixels that are between 0/1024 and 250/1024

print "SHOOT ",p,M,L,h,j

p=p+1

goto "loop"

This script requires my build (see above and ask for binaries for your cameras).

I probably won't be developing it in this form any more, for better results I think I will switch to Jucifer build (that includes the shot_histogram routines) and maybe (MAYBE) to LUA instead of uBasic..
« Last Edit: 25 / May / 2008, 03:24:34 by fbonomi »

Re: Timelapse with variable shutter speed
« Reply #101 on: 26 / May / 2008, 22:47:00 »
Hey,

I just tried the timelapse script with my SD 700 IS and well it worked, but I'm not getting the results I want.  This evening, I left my camera out with the script running for 2 hours or so, and when I stopped the script, the images looked like the sun was just starting to set, but it was actually 9:30 PM.

Video:here (7.3 MB XVid)
Youtube: YouTube - Timelapse Test (Good enough to get my point across)

I'm guessing I have to manually configure the guess mode value, the TV limit, or the guess mode slope.  I'm not exactly sure how to modify these values to get the effect that I want (just a simple sunset).

Thanks in advance.
« Last Edit: 26 / May / 2008, 23:56:49 by wonginator1221 »

*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: Timelapse with variable shutter speed
« Reply #102 on: 28 / May / 2008, 14:34:38 »
ola fbonomi, i just had a hard time integrating your code changes into a fresh export of the official trunk. are the listed changes in post 79 complete? i suspect you changed something else, and i guess i should be finding this out myself, anyhow here's the error:

Quote
========== D:\DATEN\BLUB\CHDK-SHELL-V132\TRUNK406\BIN\LOGS\ERR-S3IS-100A.TXT ==========

tokenizer.c:176: error: `TOKENIZER_EXP_GET_INFO' undeclared here (not in a function)
tokenizer.c:176: error: initializer element is not constant
tokenizer.c:176: error: (near initialization for `keywords[103].token')
tokenizer.c:176: error: initializer element is not constant
tokenizer.c:176: error: (near initialization for `keywords[103]')
tokenizer.c:179: error: initializer element is not constant
tokenizer.c:179: error: (near initialization for `keywords[104]')
tokenizer.c:181: error: initializer element is not constant
tokenizer.c:181: error: (near initialization for `keywords[105]')
D:\Daten\blub\chdk-shell-v132\gcc\bin\gmake[2]: *** [tokenizer.o] Error 1
D:\Daten\blub\chdk-shell-v132\gcc\bin\gmake[1]: *** [all-recursive] Error 1
gmake: *** [all-recursive] Error 1

or can you supply a build for the s3is? and please provide your code changes in a diff, as i dont know for example when you have made two changes in one file, which lines you refer to in the second change - the linenumber BEFORE the file gets changed the first time, or after? with a diff that can easily be created using svn things would be better (plus you can better track your changes made to the trunk).
really wanted to test this out, as i came home and saw that there was a beautiful sunset coming along. too late now, tomorrow evening i will have the chance, hopefully.

regards, PhoX

edit: maybe i did something wrong when i added your changes to the code, been a long time since i last compiled chdk ;)

*

Offline fbonomi

  • ****
  • 469
  • A570IS SD1100/Ixus80
    • Francesco Bonomi
Re: Timelapse with variable shutter speed
« Reply #103 on: 28 / May / 2008, 15:08:14 »
sorry Phyrephox,

sorry, I forgot the changes in tokenizer.h...

Yes, the diff would be the right way, but i made a mess with the sources and diff fails miserably...

As soon as I have time I will re-apply my changes to a fresh trunk, and publish the diff

Anyway, here are the binary for s3is. Because of the aforementioned mess, the build number is unreliable, and I have put a "FRX" suffix to the version name to distinguish it from the normal one (I keep my verson on a separate card)

EDIT:
almost forgot: if you are only interested in sunset (not sunrise), you can use this version:
Timelapse with variable shutter speed
that does not require the custom build




« Last Edit: 28 / May / 2008, 15:22:01 by fbonomi »


*

Offline fbonomi

  • ****
  • 469
  • A570IS SD1100/Ixus80
    • Francesco Bonomi
Re: Timelapse with variable shutter speed
« Reply #104 on: 28 / May / 2008, 15:21:02 »
the images looked like the sun was just starting to set, but it was actually 9:30 PM.

That's quite normal, that's what it's supposed to happen.....

A "normal" sunset movie starts with light and ends with dark (just after sunset)

This script tries to compensate this, exposing longer and longer, so the twilight becomes almost as normal day... There are changes in hue, but very little in luminosity. The script goes on and on increasng exposure, up to the point that in the full night you can see stars.

If you look at this movie: Sunset Time-Lapse 12

You will notice that at 21" in the movie a small light  appears on the hills. That's a far away house, and you see the light because it's actually quite dark.

At 28" the sky (when it's not covered by clouds) is still blue but you start seeing stars... It' actually dark enough to see stars, but the camera exposes enough to make the sky blue.

So, what you were seeing is normal, you should just have left it run longer.

*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: Timelapse with variable shutter speed
« Reply #105 on: 28 / May / 2008, 15:28:10 »
thanks, will try that tomorrow. didnt know that you dont need the special build for sunset. will try special build anyway ;)

*

Offline fbonomi

  • ****
  • 469
  • A570IS SD1100/Ixus80
    • Francesco Bonomi
Re: Timelapse with variable shutter speed
« Reply #106 on: 28 / May / 2008, 15:49:44 »
Yes, there is one version of the script (the one I linked) that works with standard build but does not handle correctly increasing luminosity (sunrise :-)

*

Offline lukg

  • ***
  • 162
  • Eos 450D+18-55is+55-250is & Powershot S5is - 1.01a
Re: Timelapse with variable shutter speed
« Reply #107 on: 23 / June / 2008, 11:00:20 »
This is a great script! A quick question, which program should I use to make the video? (I use Sony Vegas but I was searching for something more quick...virtualdub can do this?)


*

Offline fbonomi

  • ****
  • 469
  • A570IS SD1100/Ixus80
    • Francesco Bonomi
Re: Timelapse with variable shutter speed
« Reply #108 on: 23 / June / 2008, 11:05:57 »
I am using Premiere, but Virtualdub is fine for this.

see here:
DIY.Housing for Ixus.
for the exact steps to follw

*

Offline mx3

  • ****
  • 372
Re: Timelapse with variable shutter speed
« Reply #109 on: 23 / June / 2008, 11:11:43 »
which program should I use to make the video?
Photolapse - I can't say anything about speed because I did not use other programs

virtualdub can do this?
It seems it can. somewhere Grand posted howto on it. (something like open first jpg and it will guess and load other frames)
I tried it but have not managed to specify videocodek
skype: max_dtc. ICQ: 125985663, email: win.drivers(at)gmail, eVB decompiler

 

Related Topics