glenn-jocher
commited on
Commit
•
0e2f2cb
1
Parent(s):
19100ba
Update LoadStreams init fallbacks (#3295)
Browse files- utils/datasets.py +2 -2
utils/datasets.py
CHANGED
@@ -284,8 +284,8 @@ class LoadStreams: # multiple IP or RTSP cameras
|
|
284 |
assert cap.isOpened(), f'Failed to open {s}'
|
285 |
w = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
|
286 |
h = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
|
287 |
-
self.fps[i] = (cap.get(cv2.CAP_PROP_FPS) % 100) or 30.0 #
|
288 |
-
self.frames[i] = int(cap.get(cv2.CAP_PROP_FRAME_COUNT)) or float('inf') #
|
289 |
|
290 |
_, self.imgs[i] = cap.read() # guarantee first frame
|
291 |
self.threads[i] = Thread(target=self.update, args=([i, cap]), daemon=True)
|
|
|
284 |
assert cap.isOpened(), f'Failed to open {s}'
|
285 |
w = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
|
286 |
h = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
|
287 |
+
self.fps[i] = max(cap.get(cv2.CAP_PROP_FPS) % 100, 0) or 30.0 # 30 FPS fallback
|
288 |
+
self.frames[i] = max(int(cap.get(cv2.CAP_PROP_FRAME_COUNT)), 0) or float('inf') # infinite stream fallback
|
289 |
|
290 |
_, self.imgs[i] = cap.read() # guarantee first frame
|
291 |
self.threads[i] = Thread(target=self.update, args=([i, cap]), daemon=True)
|