-
Notifications
You must be signed in to change notification settings - Fork 0
/
camera.py
75 lines (61 loc) · 2.38 KB
/
camera.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import time
simulate = False
SharpCap = None
def init_sharpcap(s):
global SharpCap, simulate
SharpCap = s
if SharpCap == None:
simulate = True
print('[camera simulator] SharpCap not found; camera simulation enabled')
return
SharpCap.SelectedCamera.Controls.ColourSpace.Value = 'RAW16'
SharpCap.SelectedCamera.Controls.Gain.Automatic = False
SharpCap.SelectedCamera.Controls.Gain.Value = 0
SharpCap.SelectedCamera.Controls.Exposure.Automatic = False
def set_roi(widthXheight):
if simulate:
print(f'[camera simulator] Set ROI to {widthXheight}')
return
if SharpCap.SelectedCamera == None:
print('CAMERA DISCONNECTED')
return
SharpCap.SelectedCamera.Controls.Resolution.Value = widthXheight
def set_pan(pan):
if simulate:
print(f'[camera simulator] Set Pan to {pan}')
return
if SharpCap.SelectedCamera == None:
print('CAMERA DISCONNECTED')
return
SharpCap.SelectedCamera.Controls.Pan.Value = pan
def capture_single_frame_to(filename, exposure_ms):
if simulate:
print(f'[camera simulator] Capturing single frame, exposure={exposure_ms:0.3f}ms, to={filename}')
time.sleep(0.3)
return
if SharpCap.SelectedCamera == None:
print('CAMERA DISCONNECTED')
return
SharpCap.SelectedCamera.Controls.OutputFormat.Value = 'FITS file (*.fits)'
SharpCap.SelectedCamera.Controls.Exposure.Value = exposure_ms/1000
SharpCap.SelectedCamera.CaptureSingleFrameTo(filename)
def start_video_capture(exposure_ms):
if simulate:
print(f'[camera simulator] Starting video capture, exposure={exposure_ms:0.3f}')
return
if SharpCap.SelectedCamera == None:
print('CAMERA DISCONNECTED')
return
SharpCap.SelectedCamera.Controls.OutputFormat.Value = 'FITS file (*.fits)'
SharpCap.SelectedCamera.Controls.Exposure.Value = exposure_ms/1000
SharpCap.SelectedCamera.CaptureConfig.CaptureLimitType = SharpCap.SelectedCamera.CaptureConfig.CaptureLimitType.Unlimited
SharpCap.SelectedCamera.PrepareToCapture()
SharpCap.SelectedCamera.RunCapture()
def stop_video_capture():
if simulate:
print(f'[camera simulator] Stopping video capture')
return
if SharpCap.SelectedCamera == None:
print('CAMERA DISCONNECTED')
return
SharpCap.SelectedCamera.StopCapture()