cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
var.tst_scene_render.TestSceneRender Class Reference

Public Member Functions

def __init__ (self, bgImg=None, fgImg=None, deformation=False, speed=0.25, **params)
 
def getXOffset (self, time)
 
def getYOffset (self, time)
 
def setInitialRect (self, rect)
 
def getRectInTime (self, time)
 
def getCurrentRect (self)
 
def getNextFrame (self)
 
def resetTime (self)
 

Public Attributes

 time
 
 timeStep
 
 foreground
 
 deformation
 
 speed
 
 sceneBg
 
 w
 
 h
 
 center
 
 currentCenter
 
 xAmpl
 
 yAmpl
 
 initialRect
 
 currentRect
 

Detailed Description

Definition at line 47 of file tst_scene_render.py.

Constructor & Destructor Documentation

◆ __init__()

def var.tst_scene_render.TestSceneRender.__init__ (   self,
  bgImg = None,
  fgImg = None,
  deformation = False,
  speed = 0.25,
**  params 
)

Definition at line 49 of file tst_scene_render.py.

50  deformation = False, speed = 0.25, **params):
51  self.time = 0.0
52  self.timeStep = 1.0 / 30.0
53  self.foreground = fgImg
54  self.deformation = deformation
55  self.speed = speed
56 
57  if bgImg is not None:
58  self.sceneBg = bgImg.copy()
59  else:
60  self.sceneBg = np.zeros(defaultSize, defaultSize, np.uint8)
61 
62  self.w = self.sceneBg.shape[0]
63  self.h = self.sceneBg.shape[1]
64 
65  if fgImg is not None:
66  self.foreground = fgImg.copy()
67  self.center = self.currentCenter = (int(self.w/2 - fgImg.shape[0]/2), int(self.h/2 - fgImg.shape[1]/2))
68 
69  self.xAmpl = self.sceneBg.shape[0] - (self.center[0] + fgImg.shape[0])
70  self.yAmpl = self.sceneBg.shape[1] - (self.center[1] + fgImg.shape[1])
71 
72  self.initialRect = np.array([ (self.h/2, self.w/2), (self.h/2, self.w/2 + self.w/10),
73  (self.h/2 + self.h/10, self.w/2 + self.w/10), (self.h/2 + self.h/10, self.w/2)]).astype(int)
74  self.currentRect = self.initialRect
75 

Member Function Documentation

◆ getCurrentRect()

def var.tst_scene_render.TestSceneRender.getCurrentRect (   self)

Definition at line 98 of file tst_scene_render.py.

98  def getCurrentRect(self):
99 
100  if self.foreground is not None:
101 
102  x0 = self.currentCenter[0]
103  y0 = self.currentCenter[1]
104  x1 = self.currentCenter[0] + self.foreground.shape[0]
105  y1 = self.currentCenter[1] + self.foreground.shape[1]
106  return np.array([y0, x0, y1, x1])
107  else:
108  x0, y0 = self.currentRect[0]
109  x1, y1 = self.currentRect[2]
110  return np.array([x0, y0, x1, y1])
111 

◆ getNextFrame()

def var.tst_scene_render.TestSceneRender.getNextFrame (   self)

Definition at line 112 of file tst_scene_render.py.

112  def getNextFrame(self):
113  img = self.sceneBg.copy()
114 
115  if self.foreground is not None:
116  self.currentCenter = (self.center[0] + self.getXOffset(self.time), self.center[1] + self.getYOffset(self.time))
117  img[self.currentCenter[0]:self.currentCenter[0]+self.foreground.shape[0],
118  self.currentCenter[1]:self.currentCenter[1]+self.foreground.shape[1]] = self.foreground
119  else:
120  self.currentRect = self.initialRect + np.int( 30*cos(self.time*self.speed) + 50*sin(self.time*self.speed))
121  if self.deformation:
122  self.currentRect[1:3] += int(self.h/20*cos(self.time))
123  cv.fillConvexPoly(img, self.currentRect, (0, 0, 255))
124 
125  self.time += self.timeStep
126  return img
127 
Here is the call graph for this function:

◆ getRectInTime()

def var.tst_scene_render.TestSceneRender.getRectInTime (   self,
  time 
)

Definition at line 86 of file tst_scene_render.py.

86  def getRectInTime(self, time):
87 
88  if self.foreground is not None:
89  tmp = np.array(self.center) + np.array((self.getXOffset(time), self.getYOffset(time)))
90  x0, y0 = tmp
91  x1, y1 = tmp + self.foreground.shape[0:2]
92  return np.array([y0, x0, y1, x1])
93  else:
94  x0, y0 = self.initialRect[0] + np.array((self.getXOffset(time), self.getYOffset(time)))
95  x1, y1 = self.initialRect[2] + np.array((self.getXOffset(time), self.getYOffset(time)))
96  return np.array([y0, x0, y1, x1])
97 
Here is the call graph for this function:

◆ getXOffset()

def var.tst_scene_render.TestSceneRender.getXOffset (   self,
  time 
)

Definition at line 76 of file tst_scene_render.py.

76  def getXOffset(self, time):
77  return int( self.xAmpl*cos(time*self.speed))
78 
79 
Here is the caller graph for this function:

◆ getYOffset()

def var.tst_scene_render.TestSceneRender.getYOffset (   self,
  time 
)

Definition at line 80 of file tst_scene_render.py.

80  def getYOffset(self, time):
81  return int(self.yAmpl*sin(time*self.speed))
82 
Here is the caller graph for this function:

◆ resetTime()

def var.tst_scene_render.TestSceneRender.resetTime (   self)

Definition at line 128 of file tst_scene_render.py.

128  def resetTime(self):
129  self.time = 0.0
130 
131 

◆ setInitialRect()

def var.tst_scene_render.TestSceneRender.setInitialRect (   self,
  rect 
)

Definition at line 83 of file tst_scene_render.py.

83  def setInitialRect(self, rect):
84  self.initialRect = rect
85 

Member Data Documentation

◆ center

var.tst_scene_render.TestSceneRender.center

Definition at line 67 of file tst_scene_render.py.

◆ currentCenter

var.tst_scene_render.TestSceneRender.currentCenter

Definition at line 67 of file tst_scene_render.py.

◆ currentRect

var.tst_scene_render.TestSceneRender.currentRect

Definition at line 74 of file tst_scene_render.py.

◆ deformation

var.tst_scene_render.TestSceneRender.deformation

Definition at line 54 of file tst_scene_render.py.

◆ foreground

var.tst_scene_render.TestSceneRender.foreground

Definition at line 53 of file tst_scene_render.py.

◆ h

var.tst_scene_render.TestSceneRender.h

Definition at line 63 of file tst_scene_render.py.

◆ initialRect

var.tst_scene_render.TestSceneRender.initialRect

Definition at line 72 of file tst_scene_render.py.

◆ sceneBg

var.tst_scene_render.TestSceneRender.sceneBg

Definition at line 58 of file tst_scene_render.py.

◆ speed

var.tst_scene_render.TestSceneRender.speed

Definition at line 55 of file tst_scene_render.py.

◆ time

var.tst_scene_render.TestSceneRender.time

Definition at line 51 of file tst_scene_render.py.

◆ timeStep

var.tst_scene_render.TestSceneRender.timeStep

Definition at line 52 of file tst_scene_render.py.

◆ w

var.tst_scene_render.TestSceneRender.w

Definition at line 62 of file tst_scene_render.py.

◆ xAmpl

var.tst_scene_render.TestSceneRender.xAmpl

Definition at line 69 of file tst_scene_render.py.

◆ yAmpl

var.tst_scene_render.TestSceneRender.yAmpl

Definition at line 70 of file tst_scene_render.py.


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