-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcamera.py
More file actions
29 lines (23 loc) · 852 Bytes
/
camera.py
File metadata and controls
29 lines (23 loc) · 852 Bytes
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
from picamera.array import PiRGBArray
from picamera import PiCamera
from fractions import Fraction
from time import sleep
class Camera:
SIZE = (640, 480)
def __init__(self, fps):
camera = PiCamera(resolution=self.SIZE, framerate=Fraction(fps, 1))
camera.shutter_speed = 1000000 / fps
camera.iso = 800
sleep(2)
camera.exposure_mode = 'off'
camera.awb_mode = 'off'
camera.awb_gains = (Fraction(299, 256), Fraction(49, 32))
self._camera = camera
self._stream = PiRGBArray(self._camera, size = self.SIZE)
def stream(self):
self._stream.truncate(0)
return self._stream
def image(self):
return self._stream.array
def capture_sequence(self, streams):
self._camera.capture_sequence(streams, format = 'bgr', use_video_port = True)