cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
var.video Namespace Reference

Classes

class  VideoSynthBase
 
class  Book
 
class  Cube
 
class  Chess
 

Functions

def create_capture (source=0, fallback=presets['chess'])
 

Variables

 classes = dict(chess=Chess, book=Book, cube=Cube)
 
 presets
 
 args = dict(args)
 
 sources = [ 0 ]
 
 shotdir = args.get('--shotdir', '.')
 
 caps = list(map(create_capture, sources))
 
int shot_idx = 0
 
list imgs = []
 
 ret
 
 img
 
 ch = cv.waitKey(1)
 
string fn = '%s/shot_%d_%03d.bmp' % (shotdir, i, shot_idx)
 

Function Documentation

◆ create_capture()

def var.video.create_capture (   source = 0,
  fallback = presets['chess'] 
)
source: <int> or '<int>|<filename>|synth [:<param_name>=<value> [:...]]'

Definition at line 199 of file video.py.

199 def create_capture(source = 0, fallback = presets['chess']):
200  '''source: <int> or '<int>|<filename>|synth [:<param_name>=<value> [:...]]'
201  '''
202  source = str(source).strip()
203 
204  # Win32: handle drive letter ('c:', ...)
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]
208 
209  source = chunks[0]
210  try: source = int(source)
211  except ValueError: pass
212  params = dict( s.split('=') for s in chunks[1:] )
213 
214  cap = None
215  if source == 'synth':
216  Class = classes.get(params.get('class', None), VideoSynthBase)
217  try: cap = Class(**params)
218  except: pass
219  else:
220  cap = cv.VideoCapture(source)
221  if 'size' in params:
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:
228  return create_capture(fallback, None)
229  return cap
230 
def create_capture(source=0, fallback=presets['chess'])
Definition: video.py:199

Variable Documentation

◆ args

var.video.args = dict(args)

Definition at line 237 of file video.py.

◆ caps

var.video.caps = list(map(create_capture, sources))

Definition at line 243 of file video.py.

◆ ch

var.video.ch = cv.waitKey(1)

Definition at line 251 of file video.py.

◆ classes

var.video.classes = dict(chess=Chess, book=Book, cube=Cube)

Definition at line 188 of file video.py.

◆ fn

string var.video.fn = '%s/shot_%d_%03d.bmp' % (shotdir, i, shot_idx)

Definition at line 256 of file video.py.

◆ img

var.video.img

Definition at line 248 of file video.py.

◆ imgs

list var.video.imgs = []

Definition at line 246 of file video.py.

◆ presets

var.video.presets
Initial value:
1 = dict(
2  empty = 'synth:',
3  lena = 'synth:bg=lena.jpg:noise=0.1',
4  chess = 'synth:class=chess:bg=lena.jpg:noise=0.1:size=640x480',
5  book = 'synth:class=book:bg=graf1.png:noise=0.1:size=640x480',
6  cube = 'synth:class=cube:bg=pca_test1.jpg:noise=0.0:size=640x480'
7 )

Definition at line 190 of file video.py.

◆ ret

var.video.ret

Definition at line 248 of file video.py.

◆ shot_idx

int var.video.shot_idx = 0

Definition at line 244 of file video.py.

◆ shotdir

var.video.shotdir = args.get('--shotdir', '.')

Definition at line 239 of file video.py.

◆ sources

list var.video.sources = [ 0 ]

Definition at line 237 of file video.py.