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

Classes

class  Bunch
 
class  Sketcher
 
class  StatValue
 
class  RectSelector
 

Functions

def splitfn (fn)
 
def anorm2 (a)
 
def anorm (a)
 
def homotrans (H, x, y)
 
def to_rect (a)
 
def rect2rect_mtx (src, dst)
 
def lookat (eye, target, up=(0, 0, 1))
 
def mtx2rvec (R)
 
def draw_str (dst, target, s)
 
def make_cmap (name, n=256)
 
def nothing (*arg, **kw)
 
def clock ()
 
def Timer (msg)
 
def grouper (n, iterable, fillvalue=None)
 
def mosaic (w, imgs)
 
def getsize (img)
 
def mdot (*args)
 
def draw_keypoints (vis, keypoints, color=(0, 255, 255))
 

Variables

int PY3 = 3
 
list image_extensions = ['.bmp', '.jpg', '.jpeg', '.png', '.tif', '.tiff', '.pbm', '.pgm', '.ppm']
 
dictionary cmap_data = { 'jet' : _jet_data }
 

Function Documentation

◆ anorm()

def var.common.anorm (   a)

Definition at line 70 of file common.py.

70 def anorm(a):
71  return np.sqrt( anorm2(a) )
72 
def anorm2(a)
Definition: common.py:68
def anorm(a)
Definition: common.py:70
Here is the call graph for this function:
Here is the caller graph for this function:

◆ anorm2()

def var.common.anorm2 (   a)

Definition at line 68 of file common.py.

68 def anorm2(a):
69  return (a*a).sum(-1)
Here is the caller graph for this function:

◆ clock()

def var.common.clock ( )

Definition at line 174 of file common.py.

174 def clock():
175  return cv.getTickCount() / cv.getTickFrequency()
176 
177 @contextmanager
def clock()
Definition: common.py:174
Here is the caller graph for this function:

◆ draw_keypoints()

def var.common.draw_keypoints (   vis,
  keypoints,
  color = (0, 255, 255) 
)

Definition at line 266 of file common.py.

266 def draw_keypoints(vis, keypoints, color = (0, 255, 255)):
267  for kp in keypoints:
268  x, y = kp.pt
269  cv.circle(vis, (int(x), int(y)), 2, color)
def draw_keypoints(vis, keypoints, color=(0, 255, 255))
Definition: common.py:266

◆ draw_str()

def var.common.draw_str (   dst,
  target,
  s 
)

Definition at line 113 of file common.py.

113 def draw_str(dst, target, s):
114  x, y = target
115  cv.putText(dst, s, (x+1, y+1), cv.FONT_HERSHEY_PLAIN, 1.0, (0, 0, 0), thickness = 2, lineType=cv.LINE_AA)
116  cv.putText(dst, s, (x, y), cv.FONT_HERSHEY_PLAIN, 1.0, (255, 255, 255), lineType=cv.LINE_AA)
117 
def draw_str(dst, target, s)
Definition: common.py:113
Here is the caller graph for this function:

◆ getsize()

def var.common.getsize (   img)

Definition at line 259 of file common.py.

259 def getsize(img):
260  h, w = img.shape[:2]
261  return w, h
262 
def getsize(img)
Definition: common.py:259

◆ grouper()

def var.common.grouper (   n,
  iterable,
  fillvalue = None 
)
grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx

Definition at line 234 of file common.py.

234 def grouper(n, iterable, fillvalue=None):
235  '''grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx'''
236  args = [iter(iterable)] * n
237  if PY3:
238  output = it.zip_longest(fillvalue=fillvalue, *args)
239  else:
240  output = it.izip_longest(fillvalue=fillvalue, *args)
241  return output
242 
def grouper(n, iterable, fillvalue=None)
Definition: common.py:234
Here is the caller graph for this function:

◆ homotrans()

def var.common.homotrans (   H,
  x,
  y 
)

Definition at line 73 of file common.py.

73 def homotrans(H, x, y):
74  xs = H[0, 0]*x + H[0, 1]*y + H[0, 2]
75  ys = H[1, 0]*x + H[1, 1]*y + H[1, 2]
76  s = H[2, 0]*x + H[2, 1]*y + H[2, 2]
77  return xs/s, ys/s
78 
def homotrans(H, x, y)
Definition: common.py:73

◆ lookat()

def var.common.lookat (   eye,
  target,
  up = (0, 0, 1) 
)

Definition at line 95 of file common.py.

95 def lookat(eye, target, up = (0, 0, 1)):
96  fwd = np.asarray(target, np.float64) - eye
97  fwd /= anorm(fwd)
98  right = np.cross(fwd, up)
99  right /= anorm(right)
100  down = np.cross(fwd, right)
101  R = np.float64([right, down, fwd])
102  tvec = -np.dot(R, eye)
103  return R, tvec
104 
def lookat(eye, target, up=(0, 0, 1))
Definition: common.py:95
Here is the call graph for this function:

◆ make_cmap()

def var.common.make_cmap (   name,
  n = 256 
)

Definition at line 156 of file common.py.

156 def make_cmap(name, n=256):
157  data = cmap_data[name]
158  xs = np.linspace(0.0, 1.0, n)
159  channels = []
160  eps = 1e-6
161  for ch_name in ['blue', 'green', 'red']:
162  ch_data = data[ch_name]
163  xp, yp = [], []
164  for x, y1, y2 in ch_data:
165  xp += [x, x+eps]
166  yp += [y1, y2]
167  ch = np.interp(xs, xp, yp)
168  channels.append(ch)
169  return np.uint8(np.array(channels).T*255)
170 
def make_cmap(name, n=256)
Definition: common.py:156

◆ mdot()

def var.common.mdot ( args)

Definition at line 263 of file common.py.

263 def mdot(*args):
264  return reduce(np.dot, args)
265 
def mdot(*args)
Definition: common.py:263

◆ mosaic()

def var.common.mosaic (   w,
  imgs 
)
Make a grid from images.

w    -- number of grid columns
imgs -- images (must have same size and format)

Definition at line 243 of file common.py.

243 def mosaic(w, imgs):
244  '''Make a grid from images.
245 
246  w -- number of grid columns
247  imgs -- images (must have same size and format)
248  '''
249  imgs = iter(imgs)
250  if PY3:
251  img0 = next(imgs)
252  else:
253  img0 = imgs.next()
254  pad = np.zeros_like(img0)
255  imgs = it.chain([img0], imgs)
256  rows = grouper(w, imgs, pad)
257  return np.vstack(map(np.hstack, rows))
258 
def mosaic(w, imgs)
Definition: common.py:243
Here is the call graph for this function:

◆ mtx2rvec()

def var.common.mtx2rvec (   R)

Definition at line 105 of file common.py.

105 def mtx2rvec(R):
106  w, u, vt = cv.SVDecomp(R - np.eye(3))
107  p = vt[0] + u[:,0]*w[0] # same as np.dot(R, vt[0])
108  c = np.dot(vt[0], p)
109  s = np.dot(vt[1], p)
110  axis = np.cross(vt[0], vt[1])
111  return axis * np.arctan2(s, c)
112 
def mtx2rvec(R)
Definition: common.py:105

◆ nothing()

def var.common.nothing ( arg,
**  kw 
)

Definition at line 171 of file common.py.

171 def nothing(*arg, **kw):
172  pass
173 
def nothing(*arg, **kw)
Definition: common.py:171

◆ rect2rect_mtx()

def var.common.rect2rect_mtx (   src,
  dst 
)

Definition at line 85 of file common.py.

85 def rect2rect_mtx(src, dst):
86  src, dst = to_rect(src), to_rect(dst)
87  cx, cy = (dst[1] - dst[0]) / (src[1] - src[0])
88  tx, ty = dst[0] - src[0] * (cx, cy)
89  M = np.float64([[ cx, 0, tx],
90  [ 0, cy, ty],
91  [ 0, 0, 1]])
92  return M
93 
94 
def to_rect(a)
Definition: common.py:79
def rect2rect_mtx(src, dst)
Definition: common.py:85
Here is the call graph for this function:

◆ splitfn()

def var.common.splitfn (   fn)

Definition at line 63 of file common.py.

63 def splitfn(fn):
64  path, fn = os.path.split(fn)
65  name, ext = os.path.splitext(fn)
66  return path, name, ext
67 
def splitfn(fn)
Definition: common.py:63

◆ Timer()

def var.common.Timer (   msg)

Definition at line 178 of file common.py.

178 def Timer(msg):
179  print(msg, '...',)
180  start = clock()
181  try:
182  yield
183  finally:
184  print("%.2f ms" % ((clock()-start)*1000))
185 
def Timer(msg)
Definition: common.py:178
Here is the call graph for this function:

◆ to_rect()

def var.common.to_rect (   a)

Definition at line 79 of file common.py.

79 def to_rect(a):
80  a = np.ravel(a)
81  if len(a) == 2:
82  a = (0, 0, a[0], a[1])
83  return np.array(a, np.float64).reshape(2, 2)
84 
Here is the caller graph for this function:

Variable Documentation

◆ cmap_data

dictionary var.common.cmap_data = { 'jet' : _jet_data }

Definition at line 154 of file common.py.

◆ image_extensions

list var.common.image_extensions = ['.bmp', '.jpg', '.jpeg', '.png', '.tif', '.tiff', '.pbm', '.pgm', '.ppm']

Definition at line 55 of file common.py.

◆ PY3

int var.common.PY3 = 3

Definition at line 42 of file common.py.