-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpvs_test_gui.py
130 lines (102 loc) · 2.62 KB
/
pvs_test_gui.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
from PiVideoStreamGUI import PiVideoStream
from picamera import PiCamera
import cv2
import time
from Tkinter import *
vs = PiVideoStream(resolution=(640,480))
master = Tk()
scale_iso = Scale(master,
from_=100,
to=1600,
label='ISO',
resolution=100,
orient=HORIZONTAL)
scale_iso.pack()
shutter_speed1 = Scale(master,
from_=1,
to=30000,
label='SS1',
resolution=1,
orient=HORIZONTAL)
shutter_speed1.pack()
shutter_speed2 = Scale(master,
from_=1,
to=30000,
label='SS2',
resolution=1,
orient=HORIZONTAL)
shutter_speed2.pack()
scale_swap_frames = Scale(master,
from_=1,
to=60,
label='swap frames',
orient=HORIZONTAL)
scale_swap_frames.pack()
scale_ev = Scale(master,
from_=-20,
to=20,
label='ev',
orient=HORIZONTAL)
scale_ev.pack()
global save_next_frame
save_next_frame = False
def saveNextFrame():
global save_next_frame
save_next_frame = True
btn_saveNextFrame = Button(master,
text='save',
command=saveNextFrame)
btn_saveNextFrame.pack()
entry_file_prefix = Entry(master, bd=5)
entry_file_prefix.pack()
vs.start()
framecount = 0
swap_frames = 30
try:
while True:
framecount += 1
frame = vs.read()
if save_next_frame:
save_next_frame = False
filename = 'imgs/%s_iso%d_ss%d.jpg' % (
entry_file_prefix.get(),
vs.camera.iso,
vs.camera.shutter_speed)
cv2.imwrite(filename, frame)
print('File saved: %s' % filename)
cv2.imshow('Preview', frame)
key = cv2.waitKey(1) & 0xff
if key == ord('q'):
break
master.update()
vs.camera.iso = scale_iso.get()
vs.camera.exposure_compensation = scale_ev.get()
swap_frames = scale_swap_frames.get()
if swap_frames == 1 or framecount % (swap_frames*2) > swap_frames:
vs.camera.shutter_speed = shutter_speed1.get()
else:
vs.camera.shutter_speed = shutter_speed2.get()
finally:
vs.stop()
master.destroy()
# camera = PiCamera()
# camera.resolution = (320, 240)
# camera.framerate = 32
# vs = PiHDRVideoStream(
# expseq=[0,600000],
# isoseq=[100,800],
# framerate=60).start()
# #time.sleep(2.0)
#
# while True:
# frame = vs.read()
# cv2.imshow('Preview', frame)
# #print(vs.camera.shutter_speed)
#
# key = cv2.waitKey(1) & 0xff
#
# if key == ord('q'):
# break
#
# cv2.destroyAllWindows()
# vs.stop()