Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions imutils/video/pivideostream.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions imutils/video/videostream.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -36,4 +36,4 @@ def read(self):

def stop(self):
# stop the thread and release any resources
self.stream.stop()
self.stream.stop()