def create_capture(source):
 try:
  source = int(source)
 except ValueError:
  pass
 else:
  return cv2.VideoCapture(source)
 source = str(source).strip()
 if source.startswith('synth'):
  ss = filter(None, source.split(':'))
  params = dict((s.split('=') for s in ss[1:]))
  try:
   Class = classes[params['class']]
  except:
   Class = VideoSynthBase
  return Class(**params)
 return cv2.VideoCapture(source)

def create_capture ( source ) : try : source = int ( source ) except ValueError : pass else : return cv2 . VideoCapture ( source ) source = str ( source ) . strip ( ) if source . startswith ( 'synth' ) : ss = filter ( None , source . split ( ':' ) ) params = dict ( ( s . split ( '=' ) for s in ss [ 1 : ] ) ) try : Class = classes [ params [ 'class' ] ] except : Class = VideoSynthBase return Class ( ** params ) return cv2 . VideoCapture ( source )
source: <int> or <int> or <filename> or synth:<params> .