cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
var.video.Chess Class Reference
Inheritance diagram for var.video.Chess:
[legend]
Collaboration diagram for var.video.Chess:
[legend]

Public Member Functions

def __init__ (self, **kw)
 
def draw_quads (self, img, quads, color=(0, 255, 0))
 
def render (self, dst)
 
- Public Member Functions inherited from var.video.VideoSynthBase
def __init__ (self, size=None, noise=0.0, bg=None, **params)
 
def read (self, dst=None)
 
def isOpened (self)
 

Public Attributes

 grid_size
 
 white_quads
 
 black_quads
 
 K
 
 dist_coef
 
 t
 
 tvec
 
 rvec
 
- Public Attributes inherited from var.video.VideoSynthBase
 bg
 
 frame_size
 
 noise
 

Detailed Description

Definition at line 140 of file video.py.

Constructor & Destructor Documentation

◆ __init__()

def var.video.Chess.__init__ (   self,
**  kw 
)

Definition at line 141 of file video.py.

141  def __init__(self, **kw):
142  super(Chess, self).__init__(**kw)
143 
144  w, h = self.frame_size
145 
146  self.grid_size = sx, sy = 10, 7
147  white_quads = []
148  black_quads = []
149  for i, j in np.ndindex(sy, sx):
150  q = [[j, i, 0], [j+1, i, 0], [j+1, i+1, 0], [j, i+1, 0]]
151  [white_quads, black_quads][(i + j) % 2].append(q)
152  self.white_quads = np.float32(white_quads)
153  self.black_quads = np.float32(black_quads)
154 
155  fx = 0.9
156  self.K = np.float64([[fx*w, 0, 0.5*(w-1)],
157  [0, fx*w, 0.5*(h-1)],
158  [0.0,0.0, 1.0]])
159 
160  self.dist_coef = np.float64([-0.2, 0.1, 0, 0])
161  self.t = 0
162 

Member Function Documentation

◆ draw_quads()

def var.video.Chess.draw_quads (   self,
  img,
  quads,
  color = (0, 255, 0) 
)

Definition at line 163 of file video.py.

163  def draw_quads(self, img, quads, color = (0, 255, 0)):
164  img_quads = cv.projectPoints(quads.reshape(-1, 3), self.rvec, self.tvec, self.K, self.dist_coef) [0]
165  img_quads.shape = quads.shape[:2] + (2,)
166  for q in img_quads:
167  cv.fillConvexPoly(img, np.int32(q*4), color, cv.LINE_AA, shift=2)
168 

◆ render()

def var.video.Chess.render (   self,
  dst 
)

Reimplemented from var.video.VideoSynthBase.

Definition at line 169 of file video.py.

169  def render(self, dst):
170  t = self.t
171  self.t += 1.0/30.0
172 
173  sx, sy = self.grid_size
174  center = np.array([0.5*sx, 0.5*sy, 0.0])
175  phi = pi/3 + sin(t*3)*pi/8
176  c, s = cos(phi), sin(phi)
177  ofs = np.array([sin(1.2*t), cos(1.8*t), 0]) * sx * 0.2
178  eye_pos = center + np.array([cos(t)*c, sin(t)*c, s]) * 15.0 + ofs
179  target_pos = center + ofs
180 
181  R, self.tvec = common.lookat(eye_pos, target_pos)
182  self.rvec = common.mtx2rvec(R)
183 
184  self.draw_quads(dst, self.white_quads, (245, 245, 245))
185  self.draw_quads(dst, self.black_quads, (10, 10, 10))
186 
187 
Here is the caller graph for this function:

Member Data Documentation

◆ black_quads

var.video.Chess.black_quads

Definition at line 153 of file video.py.

◆ dist_coef

var.video.Chess.dist_coef

Definition at line 160 of file video.py.

◆ grid_size

var.video.Chess.grid_size

Definition at line 146 of file video.py.

◆ K

var.video.Chess.K

Definition at line 156 of file video.py.

◆ rvec

var.video.Chess.rvec

Definition at line 182 of file video.py.

◆ t

var.video.Chess.t

Definition at line 161 of file video.py.

◆ tvec

var.video.Chess.tvec

Definition at line 181 of file video.py.

◆ white_quads

var.video.Chess.white_quads

Definition at line 152 of file video.py.


The documentation for this class was generated from the following file: