Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Frank Tjado Ihmels
medienverarbeitung17.projectmood
Commits
c4eb2a94
Commit
c4eb2a94
authored
Dec 19, 2017
by
Arne Gerdes
Browse files
Neue Kommentare hinzugefügt
parent
c9a3225f
Changes
1
Hide whitespace changes
Inline
Side-by-side
projectmood/WebcamVideoStream.py
View file @
c4eb2a94
from
threading
import
Thread
import
cv2
class
WebcamVideoStream
:
def
__init__
(
self
,
src
=
0
):
# initialize the video camera stream and read the first frame
# from the stream
"""
initialisiere den Webcam Stream und liest den ersten Frame aus dem Stream
"""
self
.
stream
=
cv2
.
VideoCapture
(
src
)
(
self
.
grabbed
,
self
.
frame
)
=
self
.
stream
.
read
()
# initialize the variable used to indicate if the thread should
# be stopped
"""
Initialisiere die Variable, die angibt, ob der Thread gestoppt werden soll
"""
self
.
stopped
=
False
def
start
(
self
):
# start the thread to read frames from the video stream
"""
starte den Thread, um Frames aus dem Webcam Stream zu lesen
"""
Thread
(
target
=
self
.
update
,
args
=
()).
start
()
return
self
def
update
(
self
):
# keep looping infinitely until the thread is stopped
"""
Endloss Schleife, bis der Thread gestoppt wird
"""
while
True
:
# if the thread indicator variable is set, stop the thread
"""
Wenn die Thread-Indikator-Variable gesetzt ist, stoppt diese den Thread
"""
if
self
.
stopped
:
return
# otherwise, read the next frame from the stream
"""
Ansonsten wird der nächste Frame aus dem Stream gelesen
"""
(
self
.
grabbed
,
self
.
frame
)
=
self
.
stream
.
read
()
def
read
(
self
):
# return the frame most recently read
"""
gibt den zuletzt gelesenen Frame zurück
"""
return
self
.
frame
def
stop
(
self
):
# indicate that the thread should be stopped
self
.
stopped
=
True
\ No newline at end of file
"""
gibt an, dass der Thread gestoppt werden soll
"""
self
.
stopped
=
True
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment