-
Notifications
You must be signed in to change notification settings - Fork 0
/
test2.py
67 lines (39 loc) · 1.41 KB
/
test2.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
#test camera program -tested with Raspberrty Pi camera v2.1
#program provides xx sec alignment preview and records jpg image
# application: align spectrometer or focus microscope
# annotates with filename and datetime
from picamera import PiCamera,Color
from time import sleep
import datetime as dt
#set filename/resolution/video time (sec)
#resolution size 4:3 options: (3280,2464),(1920,1080),(1640,1232),(640,480)
filename = '/home/pi/Desktop/testimage1.jpg'
SIZE = (3280,2464)
vidtime = 7.9
camera = PiCamera()
camera.start_preview(alpha=255)
#camera.annotate_background = picamera.Color('black')
camera.annotate_background = Color('blue')
camera.annotate_foreground = Color('yellow')
camera.annotate_text = filename + " " + dt.datetime.now().strftime ('%Y-%m-%d %H:%M:%S')
# Now fix the values
camera.shutter_speed = camera.exposure_speed
camera.exposure_mode = 'off'
g = camera.awb_gains
camera.awb_mode = 'off'
camera.awb_gains = g
iso = camera.iso
awbmode = camera.awb_mode
speed = camera.shutter_speed
resolution = camera.resolution
framerate = camera.framerate
awbgains = camera.awb_gains
print (vidtime)
print ({iso:.3f}, speed,resolution, framerate,awbmode,awbgains,g)
#camera.start_preview()
sleep(vidtime)
camera.resolution = (SIZE)
print (iso, speed,resolution, framerate,awbmode,awbgains)
camera.capture(filename)
print (iso, speed,resolution, framerate,awbmode,awbgains)
camera.stop_preview()