Skip to content

Commit 65e7ea6

Browse files
authored
Merge pull request #149 from drhoffma/master
PiCamera settings via kwargs
2 parents 4430083 + 7bab8c0 commit 65e7ea6

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

imutils/video/pivideostream.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,19 @@
55
import cv2
66

77
class PiVideoStream:
8-
def __init__(self, resolution=(320, 240), framerate=32):
9-
# initialize the camera and stream
8+
def __init__(self, resolution=(320, 240), framerate=32, **kwargs):
9+
# initialize the camera
1010
self.camera = PiCamera()
11+
12+
# set camera parameters
1113
self.camera.resolution = resolution
1214
self.camera.framerate = framerate
15+
16+
# set optional camera parameters (refer to PiCamera docs)
17+
for (arg, value) in kwargs.items():
18+
setattr(self.camera, arg, value)
19+
20+
# initialize the stream
1321
self.rawCapture = PiRGBArray(self.camera, size=resolution)
1422
self.stream = self.camera.capture_continuous(self.rawCapture,
1523
format="bgr", use_video_port=True)

imutils/video/videostream.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
class VideoStream:
55
def __init__(self, src=0, usePiCamera=False, resolution=(320, 240),
6-
framerate=32):
6+
framerate=32, **kwargs):
77
# check to see if the picamera module should be used
88
if usePiCamera:
99
# only import the picamera packages unless we are
@@ -15,7 +15,7 @@ def __init__(self, src=0, usePiCamera=False, resolution=(320, 240),
1515
# initialize the picamera stream and allow the camera
1616
# sensor to warmup
1717
self.stream = PiVideoStream(resolution=resolution,
18-
framerate=framerate)
18+
framerate=framerate, **kwargs)
1919

2020
# otherwise, we are using OpenCV so initialize the webcam
2121
# stream
@@ -36,4 +36,4 @@ def read(self):
3636

3737
def stop(self):
3838
# stop the thread and release any resources
39-
self.stream.stop()
39+
self.stream.stop()

0 commit comments

Comments
 (0)