Detecting Night/Day with CHDK - Script Writing - CHDK Forum  

Detecting Night/Day with CHDK

  • 7 Replies
  • 4161 Views
Detecting Night/Day with CHDK
« on: 08 / September / 2010, 02:03:10 »
Advertisements
Hi,

I was playing with various scripts trying to create a script that will take photos at a specified interval but will also automatically detect  sunrise and sunset and will not take pictures at night.

I have a script that will run from eg. 6am to 6pm but as you know sunrise and sun set changes. I would prefer that the camera was able to "detect" when its dark and when its gets light again.

 For my application I will be leaving the camera running non-stop. It send images to the PC after each shot so I will not run out of space on the camera.

Any help would be much appreciated.

BTW Thank you to all that put the CHDK project together.

Peter

*

Online reyalp

  • ******
  • 13438
Re: Detecting Night/Day with CHDK
« Reply #1 on: 08 / September / 2010, 02:19:07 »
You should be able to use Bv propcase value. It might not be accurate enough to measure night time exposures, but should be fine to detect whether it is night.

See http://chdk.wikia.com/wiki/Propertycase and http://dougkerr.net/Pumpkin/#APEX
Don't forget what the H stands for.

Re: Detecting Night/Day with CHDK
« Reply #2 on: 08 / September / 2010, 18:57:30 »
I'll take a look at Bv but I think it is only available on Digic 3+ I am using Canon A550.

... just tried it, Canon A550 does not have the Bv value.

I also tried to test for Ev - with low light the Ev should be higher but no matter what light I test it in i get Ev=480 .. hmm BTW I use get_prop 25 after taking a picture to see what value it is.
« Last Edit: 08 / September / 2010, 20:45:41 by crashtest »

Re: Detecting Night/Day with CHDK
« Reply #3 on: 08 / September / 2010, 21:19:12 »
If it would be okay to interrupt your stream of pictures with a throwaway test shot every once in a while, you could probably take a quick shot at a high iso and a predefined exposure length and see how bright it is with get_histo_range.

Just an idea.


*

Offline mx3

  • ****
  • 372
Re: Detecting Night/Day with CHDK
« Reply #4 on: 09 / September / 2010, 03:53:45 »
you can use motion detection to get average luminosity on LCD.
use one cell.
set threshold to big value ( 127 or 255) so it will not actually trigger.
set timeout to 2-4 seconds.
after timeout expired get average luminosity of cell.
skype: max_dtc. ICQ: 125985663, email: win.drivers(at)gmail, eVB decompiler

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Detecting Night/Day with CHDK
« Reply #5 on: 09 / September / 2010, 16:23:58 »
I'll take a look at Bv but I think it is only available on Digic 3+ I am using Canon A550.

... just tried it, Canon A550 does not have the Bv value.

Really?

trunk-926/CHDK/LUALIB/GEN> grep -i bv *.lua
propset1.lua:  BV=71,
propset2.lua:  BV=34,
propset3.lua:  BV=34,

I don't quite remember exactly when the camera updates the bv propcase, but it probably only does it during autoexposure, and it could even reset it after a shot, meaning you'd have to read it during half-shoot after a shoot-state wait loop to let autoexposure finish.

...And other than bv propcase or MD, we have the shot histogram function used by the night time/sunset timelapse scripts which is able to provide exposure values at night when it's very dark, because it uses the RAW data from your previous shot. But you shouldn't be needing that as you are avoiding night time shooting completely and the LCD live view image (used by both autoexposure BV and MD)

*

Offline fbonomi

  • ****
  • 469
  • A570IS SD1100/Ixus80
    • Francesco Bonomi
Re: Detecting Night/Day with CHDK
« Reply #6 on: 21 / September / 2010, 18:19:25 »
These snippets might help

this function is a wrapper for get_bv96 that reads the current scene luminosity

Code: [Select]
-- read curent bv from scene
function read_bv96()
 press("shoot_half")
 while get_prop(115)==0 do
  sleep(100)
 end
 bv=get_bv96()
 release("shoot_half")
 return bv
end

basically, this function half-presses the shutter button, waits for the the camera to have finished metering, reads the bv96 value, and releases the button.

in your case, the "get_prop(115)" should be replaced by a different value (maybe 67).

or, if you can't find the right value, just wait long enough:
Code: [Select]
press("shoot_half")
 sleep(1000)
 bv=get_bv96()
 release("shoot_half")

this is an example function that calls read_bv96():
Code: [Select]
function wait_for_light()
 repeat
  sleep(5000)
  print("Waiting for start...")
  t=read_bv96()
 until t>0
end

the idea here is different form yours: in my application I place a cover on the camera lens and I want the script to wait until I remove the cover (reading the BV of the scene until it feels there's enough light)

you probably just need to do something along these lines:
Code: [Select]
if  read_bv() > 0 then
 -- do day stuff
else
 -- do night stuff
end

I hope this is enough to get you started!

Re: Detecting Night/Day with CHDK
« Reply #7 on: 01 / October / 2010, 03:21:03 »
I'm looking for something similar to run a time-lapse sequence for my new house build using an A480 over 8 months!  Trying to save battery life, so don't want to take photos in the dark. Would be interested in how you stopped the photos being taken between 6pm and 9am as I think this would be good enough for me and may keep things simple!  I was thinking of adding 2 parameters to my script for the time band in the day that pictures should be taken.  Any tips greatfully received. I will also try this night/day detection as it sounds great - if works on the A480 that is!


 

Related Topics