| 2 | from .webcamvideostream import WebcamVideoStream |
| 3 | |
| 4 | class VideoStream: |
| 5 | def __init__(self, src=0, usePiCamera=False, resolution=(320, 240), |
| 6 | framerate=32, **kwargs): |
| 7 | # check to see if the picamera module should be used |
| 8 | if usePiCamera: |
| 9 | # only import the picamera packages unless we are |
| 10 | # explicity told to do so -- this helps remove the |
| 11 | # requirement of `picamera[array]` from desktops or |
| 12 | # laptops that still want to use the `imutils` package |
| 13 | from .pivideostream import PiVideoStream |
| 14 | |
| 15 | # initialize the picamera stream and allow the camera |
| 16 | # sensor to warmup |
| 17 | self.stream = PiVideoStream(resolution=resolution, |
| 18 | framerate=framerate, **kwargs) |
| 19 | |
| 20 | # otherwise, we are using OpenCV so initialize the webcam |
| 21 | # stream |
| 22 | else: |
| 23 | self.stream = WebcamVideoStream(src=src) |
| 24 | |
| 25 | def start(self): |
| 26 | # start the threaded video stream |
| 27 | return self.stream.start() |
| 28 | |
| 29 | def update(self): |
| 30 | # grab the next frame from the stream |
| 31 | self.stream.update() |
| 32 | |
| 33 | def read(self): |
| 34 | # return the current frame |
| 35 | return self.stream.read() |
| 36 | |
| 37 | def stop(self): |
| 38 | # stop the thread and release any resources |
| 39 | self.stream.stop() |
no outgoing calls
no test coverage detected
searching dependent graphs…