Using a standard Raspberry Pi camera 24hr elapsed time video can be generated. Basically, images are captured to a USB memory stick then the excellent Windows PC based ImagesToVideo program from www.cze.cz reads the memory stick data to form a video.
In addition, individual images can be uploaded using WinSCP so interesting results flagged by the skymeter program can be investigated by examining the matching images. All this using a laptop from the comfort of an armchair !
To form a video the USB stick has to be retrieved, prefereable around the switchover times so as not to loose too many images from the next sequence. After reinserting the memory stick, the Pi is rebooted and if the auto start time is missed the relevant startup program can be intiated remotely using Putty.
Various cameras fields were tried. The fisheye (90deg x 104deg) gave good results but need to be mounted pointing upward with implications for weather protection. Tests using a sheet of glass to keep the rain off led to problems of dirt and internal reflections. So the standard camera (40deg x 55deg) has been settled on as it has a narrower FOV and can be mounted under a protective roof overhang. It points due south and captures the ecliptic and having a bit of foreground imagary produces more interesting videos anyway. It is supported by a simple bracket as shown and powered off a mains USB adaptor. The Pi 3 is used which has integral WiFi.
The Python software is straightforward and is reproduced below. It is invoked with three command line parameters:-
- number of takes required
- interval in seconds between takes
- exposure time in uSec
To select different paramters for day and night, the crontab facility is used:-
0 6 * * * ./daystartup.sh
0 20 * * * ./nightstartup.sh
@reboot ./mystartup.sh &
############ daystartup.sh ##############
sudo killall python
python allsky.py 2400 20 500
############ nightstartup #############
sudo killall python
python allsky.py 2400 1 6000000
########### mystartup.sh ##############
sudo mount /dev/sda1 /media/usb2 -o uid=pi,gid=pi
Each day/night startup kills the previous version of allsky.py then starts it again using different command line values. A new directory is created by allsky.py at the start of each image sequence and images are automatically numbered in sequence.
The mystartup.sh is invoked after power-up and mounts the USB stick on directory /media/usb2. The media directory is the one two levels back from the /home/pi directory, it is NOT the media directory visible at the /home/pi level.
Note that the night time 6Sec exposure actually results in an image take time of about 25Secs so a delay of 1Sec is appropriate, giving about two exposures a minute.
##################### allsky.py ################################
# Using a Raspberry Pi camera to generate elapsed time video
# using ImagesToVideo from www.cze.cz
#
# Geo Meadows
# 22Mar2017 - first issue
#
##############################################################
from timeit import default_timer as timer
from time import sleep
import os
import picamera
import picamera.array
import subprocess
import time
from fractions import Fraction
import numpy as np
import sys
import argparse
def takeStills(exp,n,ival):
with picamera.PiCamera() as camera:
camera.resolution = (1296,972) #mode 4
if (exp > 1000000):
camera.framerate=Fraction(1, 6)
camera.exposure_mode = 'off'
camera.shutter_speed = exp
print "Exp time = {:.6f} Secs".format(float(exp)/1000000)
camera.iso = 400
camera.start_preview()
sleep(1)
for i, filename in enumerate(camera.capture_continuous('{counter:04d}.jpeg')):
# camera.annotate_background = picamera.Color('black')
camera.annotate_text = dt.datetime.now().strftime('%y-%m-%d %H:%M.%S')
print('Captured image %s' % filename)
sleep(ival)
if i == n-1:
break
camera.stop_preview()
def cleanAndExit():
print "Ended!"
sys.exit()
################# Main ###################
parser = argparse.ArgumentParser()
parser.add_argument("takes", type=int)
parser.add_argument("delay", type=int)
parser.add_argument("exptime", type=int)
args = parser.parse_args()
print args.takes, ' takes'
print args.delay, ' Secs delay'
print args.exptime, ' uS exp time'
takes = args.takes
delay = args.delay
exptime = args.exptime
today=time.strftime("%d%b-%H.%M-")
print "Starting %d frames -%s " % (takes, today)
os.chdir('/media/usb2/')
if not os.path.exists(today):
os.makedirs(today)
os.chdir(today)
try:
takeStills(exptime,takes,delay)
except (KeyboardInterrupt, SystemExit):
cleanAndExit()
cleanAndExit()
In addition, individual images can be uploaded using WinSCP so interesting results flagged by the skymeter program can be investigated by examining the matching images. All this using a laptop from the comfort of an armchair !
To form a video the USB stick has to be retrieved, prefereable around the switchover times so as not to loose too many images from the next sequence. After reinserting the memory stick, the Pi is rebooted and if the auto start time is missed the relevant startup program can be intiated remotely using Putty.
Various cameras fields were tried. The fisheye (90deg x 104deg) gave good results but need to be mounted pointing upward with implications for weather protection. Tests using a sheet of glass to keep the rain off led to problems of dirt and internal reflections. So the standard camera (40deg x 55deg) has been settled on as it has a narrower FOV and can be mounted under a protective roof overhang. It points due south and captures the ecliptic and having a bit of foreground imagary produces more interesting videos anyway. It is supported by a simple bracket as shown and powered off a mains USB adaptor. The Pi 3 is used which has integral WiFi.
The Python software is straightforward and is reproduced below. It is invoked with three command line parameters:-
- number of takes required
- interval in seconds between takes
- exposure time in uSec
To select different paramters for day and night, the crontab facility is used:-
0 6 * * * ./daystartup.sh
0 20 * * * ./nightstartup.sh
@reboot ./mystartup.sh &
############ daystartup.sh ##############
sudo killall python
python allsky.py 2400 20 500
############ nightstartup #############
sudo killall python
python allsky.py 2400 1 6000000
########### mystartup.sh ##############
sudo mount /dev/sda1 /media/usb2 -o uid=pi,gid=pi
Each day/night startup kills the previous version of allsky.py then starts it again using different command line values. A new directory is created by allsky.py at the start of each image sequence and images are automatically numbered in sequence.
The mystartup.sh is invoked after power-up and mounts the USB stick on directory /media/usb2. The media directory is the one two levels back from the /home/pi directory, it is NOT the media directory visible at the /home/pi level.
Note that the night time 6Sec exposure actually results in an image take time of about 25Secs so a delay of 1Sec is appropriate, giving about two exposures a minute.
##################### allsky.py ################################
# Using a Raspberry Pi camera to generate elapsed time video
# using ImagesToVideo from www.cze.cz
#
# Geo Meadows
# 22Mar2017 - first issue
#
##############################################################
from timeit import default_timer as timer
from time import sleep
import os
import picamera
import picamera.array
import subprocess
import time
from fractions import Fraction
import numpy as np
import sys
import argparse
def takeStills(exp,n,ival):
with picamera.PiCamera() as camera:
camera.resolution = (1296,972) #mode 4
if (exp > 1000000):
camera.framerate=Fraction(1, 6)
camera.exposure_mode = 'off'
camera.shutter_speed = exp
print "Exp time = {:.6f} Secs".format(float(exp)/1000000)
camera.iso = 400
camera.start_preview()
sleep(1)
for i, filename in enumerate(camera.capture_continuous('{counter:04d}.jpeg')):
# camera.annotate_background = picamera.Color('black')
camera.annotate_text = dt.datetime.now().strftime('%y-%m-%d %H:%M.%S')
print('Captured image %s' % filename)
sleep(ival)
if i == n-1:
break
camera.stop_preview()
def cleanAndExit():
print "Ended!"
sys.exit()
################# Main ###################
parser = argparse.ArgumentParser()
parser.add_argument("takes", type=int)
parser.add_argument("delay", type=int)
parser.add_argument("exptime", type=int)
args = parser.parse_args()
print args.takes, ' takes'
print args.delay, ' Secs delay'
print args.exptime, ' uS exp time'
takes = args.takes
delay = args.delay
exptime = args.exptime
today=time.strftime("%d%b-%H.%M-")
print "Starting %d frames -%s " % (takes, today)
os.chdir('/media/usb2/')
if not os.path.exists(today):
os.makedirs(today)
os.chdir(today)
try:
takeStills(exptime,takes,delay)
except (KeyboardInterrupt, SystemExit):
cleanAndExit()
cleanAndExit()