Skip to content
Open
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: 9 additions & 3 deletions imutils/video/webcamvideostream.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@ def __init__(self, src=0, name="WebcamVideoStream"):

# initialize the thread name
self.name = name

# intialize thread
self.thread = Thread(target=self.update, name=self.name, args=())
self.thread.daemon = True

# initialize the variable used to indicate if the thread should
# be stopped
self.stopped = False

def start(self):
# start the thread to read frames from the video stream
t = Thread(target=self.update, name=self.name, args=())
t.daemon = True
t.start()

self.thread.start()
return self

def update(self):
Expand All @@ -40,3 +43,6 @@ def read(self):
def stop(self):
# indicate that the thread should be stopped
self.stopped = True

# wait until stream resources are released (producer thread might be still grabbing frame)
self.thread.join()