AllSky Capture Script

Discussions on extending SharpCap using the built in Python scripting functionality
Post Reply
User avatar
admin
Site Admin
Posts: 5210
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

AllSky Capture Script

Post by admin » Fri Mar 06, 2020 6:54 pm

I've been working on getting an all sky camera up and running and getting it to record automatically in SharpCap over the last few days. There are some improvements in the very latest version of SharpCap (3.2.6248) which will help AllSky users, including WMV output for much smaller output video files and better reporting of the actual exposure in auto exposure mode for Altair cameras.

To get the actual captures running, I've used the python scripting - here is the current version of my script

Code: Select all

import datetime
import time

SharpCap.SelectedCamera = SharpCap.Cameras.Find(lambda x: x.DeviceName == "ALTAIR290C3(USB2.0)")
SharpCap.SelectedCamera.LoadCaptureProfile('allsky (ALTAIR290C3(USB2.0))')

from SharpCap.UI import CaptureLimitType
SharpCap.SelectedCamera.CaptureConfig.CaptureLimitType = CaptureLimitType.Unlimited

def hour():
	return datetime.datetime.now().hour
	
def exposurems():
	return SharpCap.SelectedCamera.Controls.Exposure.ExposureMs



while True:

	print "waiting for 15:00"
	
	while (hour() < 15):
		time.sleep(1)
		
	print "after 15:00, waiting for >10ms exposure"
	
	count = 0
	
	while (hour() >= 15) | (hour() < 3):
		time.sleep(1)
		if (exposurems() > 10):
			count=count+1
		else:
			count=0
		if (count > 60):
			print "starting capture at " + str(datetime.datetime.now()) + " exposure is " + str(exposurems()) + "ms" 
			SharpCap.SelectedCamera.PrepareToCapture()
			SharpCap.SelectedCamera.RunCapture()
			break
			
	print "waiting until morning"
	
	while (hour()>15) | (hour() < 4):
		time.sleep(1)
			
	print "waiting for <10ms exposure at " + str(datetime.datetime.now())
			
	count = 0
	while (hour() < 9):
		if (exposurems() < 10):
			count=count+1
		else:
			count = 0;
		if (count > 60):
			break;
		time.sleep(1)
	
	print "stopping capture at " + str(datetime.datetime.now()) + " exposure is " + str(exposurems()) + "ms" 
	
	if (SharpCap.SelectedCamera.Capturing):
		SharpCap.SelectedCamera.StopCapture()
	
The script works by monitoring the current exposure of the camera (the camera is put in auto exposure mode) – when the exposure rises above 10 ms for at least 60 continuous seconds after 3 PM, the capturing will start. When the exposure drops again below 10 ms in the morning (again for 60 continuous seconds) the capture is stopped. During the day I find that the camera tends to sit at minimum exposure of 0.24 ms even when overcast – 10 ms seems to correspond with a twilight sky just before stars become visible.

I still have some issues where the auto exposure sometimes become stuck or doesn't report the exposure time correctly, but in general things are working.

Here are the capture settings that I'm currently using

Code: Select all

Output Format=WMV file (Lossy Compression, *.wmv)
Capture Area=1920x1080
Binning=1x1
Pan=0
Tilt=0
Colour Space=RGB24
Temperature=28
Black Level=3
Flip=None
USB Speed=1
Auto Gain with Auto Exposure=Up to 1600
Auto Exp Target=75
Frame Rate Limit=1 every 15 seconds
Analogue Gain=228
Exposure=0.244(Auto)
Timestamp Frames=On
Hue=0
Saturation=128
Contrast=0
Brightness=0
Gamma=100
Extra Controls=On (Slower)
Negative=Off
Colour Tint=713
Colour Temp=5838
Banding Threshold=35
Banding Suppression=0
Apply Flat=None
Subtract Dark=None
#Black Point
Display Black Point=0
#MidTone Point
Display MidTone Point=0.5
#White Point
Display White Point=1
The key points here are having the exposure set to automatic, auto gain enabled with auto exposure up to a maximum of 1600 gain and and RGB colour space which we would normally avoid, but it does enable the WMV output. I have also tweaked the colour settings to give a reasonably neutral colour balance.

Hope this is useful, Robin

Post Reply