mirror of
https://github.com/liberatedsystems/Sideband_CE.git
synced 2024-09-03 04:13:27 +02:00
Updated view example
This commit is contained in:
parent
48908842c6
commit
6700b7f8b7
@ -158,7 +158,7 @@ class CameraSource(ViewSource):
|
||||
self.camera_ready = False
|
||||
|
||||
class StreamSource(ViewSource):
|
||||
DEFAULT_IDLE_TIMEOUT = 5
|
||||
DEFAULT_IDLE_TIMEOUT = 10
|
||||
|
||||
def __init__(self, url=None):
|
||||
self.url = url
|
||||
@ -180,11 +180,10 @@ class StreamSource(ViewSource):
|
||||
try:
|
||||
while max(self.last_update, self.started)+self.idle_timeout > time.time():
|
||||
ret, frame = self.stream.read()
|
||||
self.stream_ready = True
|
||||
if not ret:
|
||||
self.stream_ready = False
|
||||
break
|
||||
|
||||
else:
|
||||
self.stream_ready = True
|
||||
if not self.frame_queue.empty():
|
||||
if self.frame_queue.qsize() > 1:
|
||||
try:
|
||||
@ -206,6 +205,9 @@ class StreamSource(ViewSource):
|
||||
self.start_reading()
|
||||
while not self.stream_ready:
|
||||
time.sleep(0.2)
|
||||
if self.stream == None:
|
||||
self.source_data = None
|
||||
return
|
||||
|
||||
frame = self.frame_queue.get()
|
||||
retval, buffer = cv2.imencode(".png", frame)
|
||||
|
Loading…
Reference in New Issue
Block a user