mirror of
https://github.com/ultralytics/yolov5.git
synced 2025-06-03 14:49:29 +08:00
generalize webcam detection with opt.source.isnumeric() (yolov3 #1462)
This commit is contained in:
parent
09402a2174
commit
82ed33a052
@ -21,7 +21,7 @@ from utils.torch_utils import select_device, load_classifier, time_synchronized
|
||||
def detect(save_img=False):
|
||||
out, source, weights, view_img, save_txt, imgsz = \
|
||||
opt.output, opt.source, opt.weights, opt.view_img, opt.save_txt, opt.img_size
|
||||
webcam = source == '0' or source.startswith('rtsp') or source.startswith('http') or source.endswith('.txt')
|
||||
webcam = source.isnumeric() or source.startswith('rtsp') or source.startswith('http') or source.endswith('.txt')
|
||||
|
||||
# Initialize
|
||||
set_logging()
|
||||
|
@ -235,7 +235,7 @@ class LoadStreams: # multiple IP or RTSP cameras
|
||||
for i, s in enumerate(sources):
|
||||
# Start the thread to read frames from the video stream
|
||||
print('%g/%g: %s... ' % (i + 1, n, s), end='')
|
||||
cap = cv2.VideoCapture(0 if s == '0' else s)
|
||||
cap = cv2.VideoCapture(eval(s) if s.isnumeric() else s)
|
||||
assert cap.isOpened(), 'Failed to open %s' % s
|
||||
w = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
|
||||
h = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
|
||||
|
Loading…
x
Reference in New Issue
Block a user