get measured luminosity cd/m2 and print to log - Script Writing - CHDK Forum

get measured luminosity cd/m2 and print to log

  • 9 Replies
  • 4534 Views
get measured luminosity cd/m2 and print to log
« on: 12 / August / 2012, 18:17:29 »
Advertisements
Hello,
I'm doing some night intervalometer star trails type photography. I'm using a version of  yass02.bas which is originally based on sunset4.bas by fbonomi and was modified by soulf2. I've modified it a little to log a bunch of information as it shoots. Right now I've got it recording the time and date, the set aperture, the set shutter speed, the set iso, the voltage of the battery and the Bv value. As far as I can tell the Bv value is the brightness value of the scene, but I think it's just calculated based on what the shutter/aperture/iso values are. What I'd really like to have in there is the actual measured luminosity of the scene. I know you can show the luminosity in cd/m2 as part of the miscellaneous values in the on screen display (OSD), is there a way to print that to the log file as well?
The relevant parts of the script right now are:
  print_screen 1
  print "Yet Another Sunset Script"
  p=1
  get_bv96 B
  get_av96 A
  get_vbatt R
  W=get_time 0
  L=get_time 1
  J=get_time 2
  I=get_time 3
  O=get_time 4
  M=get_time 5 
  set_sv96 Y
  set_tv96_direct X
  print "SHOOT ",J,L,W,O,I,M,p,X,Y,A,B,N,R
  p=p+1

Basically I'm suspicious that the get_bv96 line is the calculated brightness value of the exposure is going to be. Is there a way to get just get the straight measured scene luminosity recorded as well?

Thanks for any help!

Jono

*

Offline reyalp

  • ******
  • 14118
Re: get measured luminosity cd/m2 and print to log
« Reply #1 on: 12 / August / 2012, 18:39:36 »
Bv is measured luminosity, in APEX*96 units. However, it only updates on half press, so you need a loop like
Code: [Select]
press("shoot_half")
repeat
sleep(10)
until get_shooting() == true
meter_bv96=get_bv96()
...
(above is lua, ubasic will be similar)

A further complication is that the exposure related set_ functions need to be called outside of halfpress, so if you want to get the bv value, do some calculation and then shoot based on that calculation, the most straightforward way is to do one halfpress for metering, then another for the shot.

edit:
If you just want to log the bv, you can probably just log it after the shot. You could also use a press shoot_half, wait for get_shooting, log bv, press shoot_full etc.
« Last Edit: 12 / August / 2012, 18:41:27 by reyalp »
Don't forget what the H stands for.

Re: get measured luminosity cd/m2 and print to log
« Reply #2 on: 12 / August / 2012, 18:55:43 »
Thanks Reyalp.
I guess it's already doing that then. For some reason I thought Bv wasn't the measured luminosity.
The script as I've modified it is below. The parameters are set with pretty tight ranges right now based on the conditions I'm shooting in. For a full explanation see http://chdk.setepontos.com/index.php?topic=4920.0

Code: [Select]
@title yass02a
  rem Script to shoot time-lapse videos of sunsets
  rem based on sunste4.bas v. 4, Fbonomi apr 30th 2008
  rem v. yass01a, modified by Soulf2 dec 28th 2009
  rem v. yass02, modified by Soulf2 Mar 10th 2010
  rem v. yass02a, modified by jono1515 Aug 12 2012
  rem Released under GPL
  @param a Delay each photo(sec)
  @default a 1
  @param b Limit Tv
  @default b -680
  rem (-414=20 sec; -384=15 sec; -320=10 sec; -224=5 sec.)
  @param c Default Sv
  @default c 515
  rem (480=160)
  @param d Limit Sv
  @default d 515
  rem (776=1250 ISO; 960=5000)
  @param e Guess mode limit
  @default e -576
  @param f Slope in guess mode
  @default f 200
  @param q 0-4,6,8:L,M1,M2,M3,S,TS,W
  @default q 0
  @param g RAW 0=off 1=on
  @default g 0
  @param h Free Disk MB Shut down
  @default h 8
  @param u Focus 0=norm 1=mac 3=inf
  @default u 3
  @param v Img Quality 0=SF 1=F 2=N
  @default v 0
  print_screen 1
  print "Yet Another Sunset Script"
  i=h*1024
  set_prop 213 0
  set_raw g
  set_prop 143 2
  set_prop 218 q
  set_prop 145 3
  set_prop 216 0
  set_prop 5 0
  set_prop 6 u
  set_prop 57 v
  x=e
  get_tv96 T
  p=1
  press "shoot_half"
  release "shoot_half"
  :loop
  k=get_free_disk_space
  if k < i then shut_down
  get_bv96 B
  get_av96 A
  get_vbatt R
  W=get_time 0
  L=get_time 1
  J=get_time 2
  I=get_time 3
  O=get_time 4
  M=get_time 5
  T=B-A
  T=T+c
  if T>e then
   X=T
   Y=c
  else
   x=x-f
   if  x>b then
    X=x
    Y=c
   else
    X=b
    Y=c+b-x 
    if Y>d then
     Y=d
    endif 
   endif
  endif
  set_sv96 Y
  set_tv96_direct X
  shoot
  print "SHOOT ",J,L,W,O,I,M,p,X,Y,A,B,N,R
  p=p+1
  sleep a*1000
  goto "loop"

*

Offline reyalp

  • ******
  • 14118
Re: get measured luminosity cd/m2 and print to log
« Reply #3 on: 12 / August / 2012, 19:03:27 »
Code: [Select]
  press "shoot_half"
  release "shoot_half"
You should wait for get_shooting to become true, otherwise the camera may not have finished metering (=bv not updated)
Don't forget what the H stands for.


Re: get measured luminosity cd/m2 and print to log
« Reply #4 on: 12 / August / 2012, 20:58:24 »
I think you're right, based on the output in the log file, the first entry always has a 0 for Av and a 0 for Bv. But the entries after that have values, so I guess the Av and Bv for a given photo in the log file may actually be referring to the Av and Bv for the previous shot?
Unfortunately my attempts to incorporate get_shooting have so far crashed the script all together. I was trying to do something like
Code: [Select]
if get_shooting > 0
  k=get_free_disk_space
  if k < i then shut_down
  get_bv96 B
  get_av96 A
  get_vbatt R
  W=get_time 0
  L=get_time 1
  J=get_time 2
  I=get_time 3
  O=get_time 4
  M=get_time 5
  T=B-A
  T=T+c
  if T>e then
   X=T
   Y=c
  else
   x=x-f
   if  x>b then
    X=x
    Y=c
   else
    X=b
    Y=c+b-x 
    if Y>d then
     Y=d
    endif 
   endif
   else
   sleep 500
   endif
  endif
  set_sv96 Y
  set_tv96_direct X
  shoot
  print "SHOOT ",J,L,W,O,I,M,p,X,Y,A,B,N,R
  p=p+1
  sleep a*1000
  goto "loop"


I've got something wrong in my syntax or that if statement just doesn't work. I've got basically no programming experience so even the simplest of things is over my head unfortunately. In reality I'm just curious what measured luminosities I'm dealing with, I really don't care if I have the exact luminosity for a particular exposure, so I think the way it's working is fine for my needs.

Thanks for your help/advice!

Jono

*

Offline reyalp

  • ******
  • 14118
Re: get measured luminosity cd/m2 and print to log
« Reply #5 on: 12 / August / 2012, 21:17:34 »
You don't want just an if, it takes time for the camera to be ready.
You want something like this
Code: [Select]
press "shoot_half"
while get_shooting <> 1
sleep 100
wend
...
get_bv96 B
Don't forget what the H stands for.

Re: get measured luminosity cd/m2 and print to log
« Reply #6 on: 13 / August / 2012, 02:18:29 »
Thanks, I'll try using that and see what I can get.
Appreciate the help!

Jono

Re: get measured luminosity cd/m2 and print to log
« Reply #7 on: 13 / August / 2012, 21:41:14 »
Thanks Reyalp, I got that bit in and it seems to be recording the Bv value right off the bat now.

The main difference between this and the original yass02.bas script is the logging. The log file will record the following parameters in this order:

Hour;Minute;Second;Month;Day;Year;Shot #;Tv96;Sv96;Av96;Bv96;Voltage

I include the voltage so I can see a discharge profile for the batteries I'm using. Currently I'm using this script with an A570is hooked up to a 6v lantern battery through a home made voltage regulator. And for some completely unknown reason, the camera shuts off after about half an hour. Battery is still fully charged. Oh well... one thing at a time I guess. For now, the script works and logs everything I wanted it to.


The whole script is as follows for anyone who cares:
Code: [Select]
@title yass02a
  rem Script to shoot time-lapse videos of sunsets
  rem based on sunste4.bas v. 4, Fbonomi apr 30th 2008
  rem v. yass01a, modified by Soulf2 dec 28th 2009
  rem v. yass02, modified by Soulf2 Mar 10th 2010
  rem v. yass02a, modified by jono1515 Aug 13 2012
  rem Released under GPL
  @param a Delay each photo(sec)
  @default a 1
  @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 385
  rem (480=160)
  @param d Limit Sv
  @default d 385
  rem (776=1250 ISO; 960=5000)
  @param e Guess mode limit
  @default e -576
  @param f Slope in guess mode
  @default f 200
  @param q 0-4,6,8:L,M1,M2,M3,S,TS,W
  @default q 0
  @param g RAW 0=off 1=on
  @default g 0
  @param h Free Disk MB Shut down
  @default h 8
  @param u Focus 0=norm 1=mac 3=inf
  @default u 3
  @param v Img Quality 0=SF 1=F 2=N
  @default v 0
  print_screen 1
  print "Yet Another Sunset Script"
  i=h*1024
  set_prop 213 0
  set_raw g
  set_prop 143 2
  set_prop 218 q
  set_prop 145 3
  set_prop 216 0
  set_prop 5 0
  set_prop 6 u
  set_prop 57 v
  x=e
  get_tv96 T
  p=1
  press "shoot_half"
  release "shoot_half"
  :loop   press "shoot_half"
   while get_shooting <> 1
     sleep 100
   wend
  k=get_free_disk_space
  if k < i then shut_down
  get_bv96 B
  get_av96 A
  get_vbatt R
  W=get_time 0
  L=get_time 1
  J=get_time 2
  I=get_time 3
  O=get_time 4
  M=get_time 5
  T=B-A
  T=T+c
  if T>e then
   X=T
   Y=c
  else
   x=x-f
   if  x>b then
    X=x
    Y=c
   else
    X=b
    Y=c+b-x 
    if Y>d then
     Y=d
    endif 
   endif
  endif
  set_sv96 Y
  set_tv96_direct X
  shoot
  print "SHOOT ",J,L,W,O,I,M,p,X,Y,A,B,R
  p=p+1
  sleep a*500
  goto "loop"


*

Offline reyalp

  • ******
  • 14118
Re: get measured luminosity cd/m2 and print to log
« Reply #8 on: 13 / August / 2012, 23:20:47 »
I would suggest:
Code: [Select]
...
  get_tv96 T
  p=1
  :loop
   press "shoot_half"
   while get_shooting <> 1
     sleep 100
   wend
   release "shoot_half"
...
If you don't have the release after the wend, then the set_* command may apply to the shot after the one you intended.

As an aside, the initial  get_tv96 T doesn't seem to serve any purpose, and if it was used, it wouldn't have a current value in it, since it would be updated on halfpress.
Don't forget what the H stands for.

Re: get measured luminosity cd/m2 and print to log
« Reply #9 on: 13 / August / 2012, 23:33:53 »
Thanks,
I made those changes and put get_tv96 T underneath with all the other get statements. Now it should get updated with the current set value. I'm going to go set the camera up and let it run for a couple hours and see what it comes up with.

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal