glenn-jocher
commited on
Commit
•
82ed33a
1
Parent(s):
09402a2
generalize webcam detection with opt.source.isnumeric() (yolov3 #1462)
Browse files- detect.py +1 -1
- utils/datasets.py +1 -1
detect.py
CHANGED
@@ -21,7 +21,7 @@ from utils.torch_utils import select_device, load_classifier, time_synchronized
|
|
21 |
def detect(save_img=False):
|
22 |
out, source, weights, view_img, save_txt, imgsz = \
|
23 |
opt.output, opt.source, opt.weights, opt.view_img, opt.save_txt, opt.img_size
|
24 |
-
webcam = source
|
25 |
|
26 |
# Initialize
|
27 |
set_logging()
|
|
|
21 |
def detect(save_img=False):
|
22 |
out, source, weights, view_img, save_txt, imgsz = \
|
23 |
opt.output, opt.source, opt.weights, opt.view_img, opt.save_txt, opt.img_size
|
24 |
+
webcam = source.isnumeric() or source.startswith('rtsp') or source.startswith('http') or source.endswith('.txt')
|
25 |
|
26 |
# Initialize
|
27 |
set_logging()
|
utils/datasets.py
CHANGED
@@ -235,7 +235,7 @@ class LoadStreams: # multiple IP or RTSP cameras
|
|
235 |
for i, s in enumerate(sources):
|
236 |
# Start the thread to read frames from the video stream
|
237 |
print('%g/%g: %s... ' % (i + 1, n, s), end='')
|
238 |
-
cap = cv2.VideoCapture(
|
239 |
assert cap.isOpened(), 'Failed to open %s' % s
|
240 |
w = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
|
241 |
h = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
|
|
|
235 |
for i, s in enumerate(sources):
|
236 |
# Start the thread to read frames from the video stream
|
237 |
print('%g/%g: %s... ' % (i + 1, n, s), end='')
|
238 |
+
cap = cv2.VideoCapture(eval(s) if s.isnumeric() else s)
|
239 |
assert cap.isOpened(), 'Failed to open %s' % s
|
240 |
w = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
|
241 |
h = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
|