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

Timelapse with variable shutter speed

  • 151 Replies
  • 93874 Views
*

Offline fbonomi

  • ****
  • 469
  • A570IS SD1100/Ixus80
    • Francesco Bonomi
Re: Timelapse with variable shutter speed
« Reply #20 on: 23 / April / 2008, 17:07:23 »
Advertisements
I was doing some logging of BV changing in time with the program above, and I found out something interesting.

The following is a graph of BV taken with over 800 samples tonight from 19:15 up to 21:30, covering the full sunset.

You can see the luminance decreasing gracefully down to -200, then you hit the sensitivity of the CCD.

To put it briefly, while you may be able to shoot in those very dark conditions, you won't be able to reliably calculate expositions  beforehand.


*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Timelapse with variable shutter speed
« Reply #21 on: 23 / April / 2008, 17:31:26 »
How about calculating exposure from a test shot?

This would of course require new functionality in CHDK, but the idea would be to shoot first, then calculate exposure from the resulting RAW image in RAM, delete this test shot JPEG (or prevent it from being written entirely if possible), adjust exposure and do the final shot (or if still off, iterate until a desired exposure has been achieved).


*

Offline fbonomi

  • ****
  • 469
  • A570IS SD1100/Ixus80
    • Francesco Bonomi
Re: Timelapse with variable shutter speed
« Reply #22 on: 23 / April / 2008, 17:45:19 »
Yes, this is certainly an option.

But shooting (for example) a 60-seconds shot just to measure luminance would make my shots too far away in time. (This is already a problem, when the exposure grows!)

In this case, I am helped by the fact that I am shooting a series of shots that are rather close-up in time.

I could therefore:

Activate preview mode
Take shot N of my sequence
Being shot with a long exposure, I will have on the LCD a image much brighter than "live preview"
Measure "luminance" of preview
See difference with image N-1
Extrapolate this difference to adjust exposure for image N+1

etc.

But for the moment I might take a simpler approach: if I  am shooting a sunset, after the Bv goes below -200 go in a sort of "guess mode" and simply assume that Bv is decreasing at a certain, constant rate...

After all, I don't want scientific results, I just want a nice timelapse. This would mean that at a certain time in the night (something like 21:00) there is a sort of slow "fade in" bringing the sky to the maximum brightness possible.

Of cource, this would NOT work for a dawn :-)

*

Offline wontolla

  • ****
  • 413
  • S3 & G9 & A720
Re: Timelapse with variable shutter speed
« Reply #23 on: 23 / April / 2008, 18:04:55 »
Nice! From 1000 to -200 we couldn't ask for a smoother curve.

Another suggestion: What if you increase ISO when reaching the -200 problematic area?

That way, the camera could be able to still calculate exposure accurately and also you can keep a fast shutter speed. With the drawback of noise of course, but if you plan to upload your time lapses (high compression and low resolution) noise could be no problem.

But the extrapolation thing sounds good. Even without that calculation, you can "hard code" a slope around 45 degrees in your graph.

I'll try to run your test script tomorrow. I was planning today but had to stay late at work.


*

Offline fbonomi

  • ****
  • 469
  • A570IS SD1100/Ixus80
    • Francesco Bonomi
Re: Timelapse with variable shutter speed
« Reply #24 on: 23 / April / 2008, 18:22:27 »
Another suggestion: What if you increase ISO when reaching the -200 problematic area?

Well, I am not strong in this area, but let me try to explain what I think I grasped :-)

We are here speaking of Bv, i.e. of luminance.

This is completely independent of ISO, this is just saying "how much light is coming in?"

This is the "luminance" value (BV): the camera feels how much light is coming to the CCD and measures it.

If we see steps in the graph is because we are here meeting the physical sensitivity limits of the CCD

This is the start of the data flow: beginning with this value, the camera starts to virtually emulate the exposure in a film camera.

To change sensitivity in a film camera, one would replace the film with one with a different ISO.

In a digital, we can't change CCD and them we emulate ISO, by decreasing the numbers read from the CCD

THEY CAN ONLY BE DECREASED, NOT INCREASED: the CCD sensitivity stays the same, and if the light is less, the CCD just doesn't "feel" it!

With ISO, we have Sv. Then, we look at the selected aperture (Av), i.e. "how much will the iris close when we shoot?"

We are now able to apply the APEX formula

Av+Tv = Bv+Sv

we have Bv, Sv and Av, and then we can transorm this into:

Tv = Bv+Sv-Av

Bingo! we are able to calculate Tv, that gives us the correct exposure time...
« Last Edit: 24 / April / 2008, 03:54:48 by fbonomi »

*

Offline fbonomi

  • ****
  • 469
  • A570IS SD1100/Ixus80
    • Francesco Bonomi
Re: Timelapse with variable shutter speed
« Reply #25 on: 25 / April / 2008, 03:49:00 »
Ok, first results. 930 frames, from 19:17 to 23:54, with expositions ranging from 1/2000 to 60", ISO 200, shot with A570 IS

Shot opposite to the sun, so no purple colors. At the beginning, (a few seconds in the movie), you can see a strong light in the hills, it's the sun reflecting in a large window of a house!

You can see the results here:

Sunset time-Lapse n. 4

If at all possible, look at the VERY large (22MB) original file here:

Sunset time-Lapse n. 4

Where you can see a few stars (practically invisible inthe flash version).

Again, good news and bad news.

The good news is that the thing seems to work, and once the problems are sorted the results might be impressive.

Also, in a clear sunset the light curve is very smooth, so a less sofisticated algorithm might be enough. It's all another matter if you have pathes of clouds, the sun appearing and disappearing between the clouds makes it very difficoult to compromise between a "smooth" curve and a faithful one.

This was shot opposite to the sun, if you shoot towards the sun the curve will become much harsher (don't shoot directly to the sun!)

The bad news:

1) BY MISTALE I left the script running with a debugging value (minimum step = Tv 16) so you can still see "bump" il luminosity (they are the steps in the Tv graph below). You can se these "flashes" in the movie, and as the Tv curve gets steeper and steeper, you can see the flashese get faster and faster) See the graph below. When Bv gets under -200, the step becomes 5 Tv (the script goes in "guess mode", see below) and you see that the steps alost disappear. That's why, in the last seconds of the film, the fade-in is much smoother

2) The exposition gets longer and longer. So, with a delay of 3 seconds between each shot (like in this case) you have the following:

At the beginning the movie shoots for 1/2000, then waits for 3".
At the end it shoots for 60 seconds, hangs about 30 seconds for image post-processing, then waits another 3 seconds

So, at the beginning we have a shot every 3 seconds, at the end we have a shot every 93 seconds. (the numbers aren't real, but you get the point)

This means that the playback time is greatly compressed in the "night" portion. The firs half of the movie gets about 850 frames, the second half gets about 80 frames.

The middle part, whee the sky gets progressively darker and darker, is boring in the movie because the sky gets darker, the camera exposes more and it seems nothing is changing :-)

I should have started with a larger delay to start with, but the problem stays.
Probably the solution would be to increase exposure time up to a certain point (let's say 15 seconds) and then start increasing Sv, not Tv (increasing ISO, not lengthening shutter time)

3) Stars almost completely disappear when compressing the movie. They are wonderful in the uncompressed fom, but that's 1.4 Gb :-)
Some post-processing (or compressing) trick must be studied, but probably this problem is less severe with other subjects (e.g. the lights of a town)

4) the script goes in "guess mode" when Tv < -200 (see post above) so the script in its current form is good for sunsets but not for sunrising. Will have to wake up early to get a Bv curve for a sunrising. I guess for all practical purposes it's lke having a sunset reversed, but I want to see the Bv curve in the very dark portion, to see how the large "steps" below -200 appear and try to cope with them

Ok, I will give it another try tonight and then release the script (it's yet in a very unpolished form, with no parameters etc.)

Thanks to the ones that gave me their parameters, they have helped a lot!
« Last Edit: 25 / April / 2008, 03:55:51 by fbonomi »

*

Offline dkeggins

  • *
  • 5
  • s5is
Re: Timelapse with variable shutter speed
« Reply #26 on: 25 / April / 2008, 23:25:28 »
fbonomi

   First, thanks for the script and look foward to any improvments.  I am new at this (not photography) but scripts to perform with.  I have the S5IS and I had to make one modification to the script to make it work.  I had to change the 'press "shoot_half"' lines to shoot_full.   With it set to shoot half, it would only take the first frame.  It would continue the log from that point on but wouldn't actually take any pictures. Again, thanks and I hope to learn more on the scripts and make some of my own.

*

Offline fbonomi

  • ****
  • 469
  • A570IS SD1100/Ixus80
    • Francesco Bonomi
Re: Timelapse with variable shutter speed
« Reply #27 on: 26 / April / 2008, 02:48:58 »
the script was only supposed to take one shot every 60 measurements: measure every 10 seconds, shoot every 10 minutes.

This because I was just using the script to collect data, not actually shooting, and I needed the shots just to get some clue of what was happennig in the meanwhile.

the press "shoot_half" is there just to (supposedly) help the camera in measuring.
the place where the script actually shoots is this:

Code: [Select]
if (p%60=0) then shoot
which means: if p (the measurement counter) is divisible by 60 then shoot.

so the script will shoot at measurement 0, measurement 60, measurement 120 and so on.

if you want it tio shoot alway, just replace the whole line with just:

Code: [Select]
if (p%60=0) then shoot
but mind you, this script does not yet adjust exposure... it's just meant to collect data!


*

Offline fbonomi

  • ****
  • 469
  • A570IS SD1100/Ixus80
    • Francesco Bonomi
Re: Timelapse with variable shutter speed
« Reply #28 on: 26 / April / 2008, 09:46:16 »
for the daring ones....

a first, untested version of the script. It's UNTESTED, I will try it tonight, if I succeed.

The idea is:
1) forget (for the moment) the smoothing. That will be added later
2) the script starts in standard mode: ISO 100, Tv calculated
3) when it gets too dark and (we risk getting bad measurements from the CCD) we go in guess mode: the Tv is increased of 5 every shot.
4) this goes on up to a Tv equivalent to about 20 seconds: when exposure would get even darker, we go in "guess mode with high ISO": this means we keep exposure fixed to 20 seconds and then we start increasing ISO instead.
5) this goes on up to about ISO 800, after this the camera keeps shooting with the same parameters.

Please note that there are some odd behaviours in the get/set_tv96/sv96 commands, so if you try the script by hand and make VERY fast changes (like going from outdoor to indoor ) you might get one or two overexposed frames.

All this said, here is the script. give it a try, if you want to!

EDIT: the code below is buggy... will have to study better
Code: [Select]
@title Sunset Time Lapse

print_screen 1

print "Sunset Time Lapse"


rem minimum Tv (-414=20 sec)
M=-414

rem minimum Sv (-776=800 ISO)
N=776


rem Guess mode limit
G=-200

rem initialize guess mode value
x=G

rem get start Tv
get_tv96 T

rem get default Sv
rem get_sv96 S
S=5*96-1
print "Default Sv: ",S

rem picture counter
p=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:
T=B-A
T=T+S

print "Calculated T: ", T

rem check Tv Values

if T<-200 then
 rem normal mode, shoot with calculated Tv and default Sc
 X=T
 Y=S
 print "Mode: Standard"
else
 rem Guess mode, every shot will be 5/96th steps longer
 x=x-5
 

 if  x>M then
  rem we are in dark, but exposure is not too long
  rem normal mode, shoot with guessed Tv and default Sc
  X=T
  Y=S
  print "Mode: Guess"
 else
  rem we are in very dark area, we want to avoid too long exposures
  rem shoot with maximum allowed time (M) and
  rem adjust Sv accordingly

  X=M
  Y=S+M-x
 
  rem BUT check we don't go in too high ISO!
  if Y>N then
   Y=N
  endif
 
  print "Mode: Guess with High ISO"
 endif
 
endif


rem we can now shoot
set_tv96_direct X
set_sv96 Y
print "SHOOT ",p,X,Y
shoot

p=p+1

sleep 2000

goto "loop"
« Last Edit: 27 / April / 2008, 05:04:52 by fbonomi »

*

Offline fbonomi

  • ****
  • 469
  • A570IS SD1100/Ixus80
    • Francesco Bonomi
Re: Timelapse with variable shutter speed
« Reply #29 on: 26 / April / 2008, 17:22:31 »
It turns out that the script is calculating properly exposure and sensitivity but the shots are not taken with the specified Tv settings (some have the correct exposure, but a lot have 1/1250).

Below is the graph, derived from its logs, of the script's calculations (black is Tv, pink is Sv).

990 shots, you see the gradual change in Tv (unsmoothed, so there are some ripples), then (at the very right) Tv gets to -200 and the script goes in guess mode (slope is now much more uniform.
At -414 Tv starts decreasing and Sv increases.

The problem is, the script was trying to set Tv, but not always this has happened, especially at long exposures


 

Related Topics