-
Notifications
You must be signed in to change notification settings - Fork 13
/
camera_maxfps.py
51 lines (36 loc) · 1.11 KB
/
camera_maxfps.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
import picamera
import signal
import numpy as np
stop_process = False
def signal_handler(signal, frame):
global stop_process
stop_process = True
signal.signal(signal.SIGINT, signal_handler)
RES = (640, 480)
FPS = 30
# Class to process camera messages
class Stream():
def __init__(self):
# Compute map1 and map2 for undistortion
pass
def undistort(self, I):
pass
# Called when new image is available
def write(self, data):
# Get the Y component which is the gray image
data_y = data[:RES[0]*RES[1]]
I_distorted = np.array(data_y).reshape(RES)
I = self.undistort(I_distorted)
if __name__ == "__main__":
# Start capturing camera images
with picamera.PiCamera() as camera:
camera.resolution = RES
camera.framerate = FPS
try:
camera.start_recording(Stream(), format='yuv')
while not stop_process:
camera.wait_recording(1)
except:
pass
#camera.stop_recording()
camera.close()