diff --git a/imutils/video/pivideostream.py b/imutils/video/pivideostream.py index c7c5931..337db69 100644 --- a/imutils/video/pivideostream.py +++ b/imutils/video/pivideostream.py @@ -5,11 +5,19 @@ import cv2 class PiVideoStream: - def __init__(self, resolution=(320, 240), framerate=32): - # initialize the camera and stream + def __init__(self, resolution=(320, 240), framerate=32, **kwargs): + # initialize the camera self.camera = PiCamera() + + # set camera parameters self.camera.resolution = resolution self.camera.framerate = framerate + + # set optional camera parameters (refer to PiCamera docs) + for (arg, value) in kwargs.items(): + setattr(self.camera, arg, value) + + # initialize the stream self.rawCapture = PiRGBArray(self.camera, size=resolution) self.stream = self.camera.capture_continuous(self.rawCapture, format="bgr", use_video_port=True) diff --git a/imutils/video/videostream.py b/imutils/video/videostream.py index f5d761c..4f9de0b 100644 --- a/imutils/video/videostream.py +++ b/imutils/video/videostream.py @@ -3,7 +3,7 @@ class VideoStream: def __init__(self, src=0, usePiCamera=False, resolution=(320, 240), - framerate=32): + framerate=32, **kwargs): # check to see if the picamera module should be used if usePiCamera: # only import the picamera packages unless we are @@ -15,7 +15,7 @@ def __init__(self, src=0, usePiCamera=False, resolution=(320, 240), # initialize the picamera stream and allow the camera # sensor to warmup self.stream = PiVideoStream(resolution=resolution, - framerate=framerate) + framerate=framerate, **kwargs) # otherwise, we are using OpenCV so initialize the webcam # stream @@ -36,4 +36,4 @@ def read(self): def stop(self): # stop the thread and release any resources - self.stream.stop() \ No newline at end of file + self.stream.stop()