200 '''source: <int> or '<int>|<filename>|synth [:<param_name>=<value> [:...]]'
202 source =
str(source).strip()
205 source = re.sub(
r'(^|=)([a-zA-Z]):([/\\a-zA-Z0-9])',
r'\1?disk\2?\3', source)
206 chunks = source.split(
':')
207 chunks = [re.sub(
r'\?disk([a-zA-Z])\?',
r'\1:', s)
for s
in chunks]
210 try: source =
int(source)
211 except ValueError:
pass
212 params = dict( s.split(
'=')
for s
in chunks[1:] )
215 if source ==
'synth':
216 Class = classes.get(params.get(
'class',
None), VideoSynthBase)
217 try: cap = Class(**params)
220 cap = cv.VideoCapture(source)
222 w, h = map(int, params[
'size'].
split(
'x'))
223 cap.set(cv.CAP_PROP_FRAME_WIDTH, w)
224 cap.set(cv.CAP_PROP_FRAME_HEIGHT, h)
225 if cap
is None or not cap.isOpened():
226 print(
'Warning: unable to open video source: ', source)
227 if fallback
is not None:
def create_capture(source=0, fallback=presets['chess'])