forked from CubeSatAtMSU/Wildfire-Image-Processing-Code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImagingCode3.py
More file actions
78 lines (56 loc) · 1.87 KB
/
Copy pathImagingCode3.py
File metadata and controls
78 lines (56 loc) · 1.87 KB
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
76
77
### AUTOMATIC FILTER SWITCHING FOR DESIGNATED IMAGE BURST QUANTITY
# Camera Libraries
import os
import time
from picamera2 import Picamera2, Preview
# Servo Libraries
from gpiozero import AngularServo
from gpiozero.pins.pigpio import PiGPIOFactory
# Declare Variables, Switch Directory, and Start Smooth Servo Movement
count = 0
os.chdir('/home/cubesat/Desktop/Sample')
os.system("sudo pigpiod")
time.sleep(2)
# Initialize Servo Settings
factory = PiGPIOFactory()
servo = AngularServo(18, min_angle=0, max_angle=180, min_pulse_width=0.0005, max_pulse_width=0.0025, pin_factory=factory)
# Initialize Picam and Picam Settings
picam2 = Picamera2()
picam2.start_preview(Preview.QTGL)
controls = {"ExposureTime": 500, "AnalogueGain": 1.0, "ColourGains": (0.0,0.0), "Saturation": 0.0, "AeEnable": 0}
preview_config = picam2.create_preview_configuration(controls=controls)
capture_config = picam2.create_still_configuration(raw={}, display=None)
picam2.configure(preview_config)
picam2.start()
time.sleep(1)
# Acquire User Input
name = str(input('Name the Image(s):\n'))
pic_num = 1 + int(input('How many pictures?:\n'))
resp = str(input("Press Enter to take a picture:\n"))
picam2.switch_mode(capture_config)
# Image Loop (Option to Run Once or More Than Once)
while resp == '':
angle = 0
for i in range(1, 4):
filt = '_760'
if i == 2:
filt = '_770'
if i == 3:
filt = '_780'
pic_name = name + filt
print('servo move\n')
servo.angle = angle
print('servo stop\n')
time.sleep(0.5)
for k in range(1,pic_num):
print(f'pic {k}\n')
picam2.capture_file(pic_name + f"_{k + count}.jpg")
angle = angle + 45
servo.angle = 0
resp = input('Press Enter to Run Again, or n to End:\n')
count = count + pic_num - 1
# Close Picamera and End Background Process (Return Servo to Original Position)
picam2.stop()
servo.angle = 0
time.sleep(1)
os.system("sudo killall pigpiod")