Definition at line 47 of file tst_scene_render.py.
◆ __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):
52 self.timeStep = 1.0 / 30.0
53 self.foreground = fgImg
54 self.deformation = deformation
58 self.sceneBg = bgImg.copy()
60 self.sceneBg = np.zeros(defaultSize, defaultSize, np.uint8)
62 self.w = self.sceneBg.shape[0]
63 self.h = self.sceneBg.shape[1]
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))
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])
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
◆ getCurrentRect()
def var.tst_scene_render.TestSceneRender.getCurrentRect |
( |
|
self | ) |
|
Definition at line 98 of file tst_scene_render.py.
98 def getCurrentRect(self):
100 if self.foreground
is not None:
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])
108 x0, y0 = self.currentRect[0]
109 x1, y1 = self.currentRect[2]
110 return np.array([x0, y0, x1, y1])
◆ 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()
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
120 self.currentRect = self.initialRect + np.int( 30*cos(self.time*self.speed) + 50*sin(self.time*self.speed))
122 self.currentRect[1:3] +=
int(self.h/20*cos(self.time))
123 cv.fillConvexPoly(img, self.currentRect, (0, 0, 255))
125 self.time += self.timeStep
◆ 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):
88 if self.foreground
is not None:
89 tmp = np.array(self.center) + np.array((self.getXOffset(time), self.getYOffset(time)))
91 x1, y1 = tmp + self.foreground.shape[0:2]
92 return np.array([y0, x0, y1, x1])
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])
◆ 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))
◆ 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))
◆ resetTime()
def var.tst_scene_render.TestSceneRender.resetTime |
( |
|
self | ) |
|
◆ 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
◆ center
var.tst_scene_render.TestSceneRender.center |
◆ currentCenter
var.tst_scene_render.TestSceneRender.currentCenter |
◆ currentRect
var.tst_scene_render.TestSceneRender.currentRect |
◆ deformation
var.tst_scene_render.TestSceneRender.deformation |
◆ foreground
var.tst_scene_render.TestSceneRender.foreground |
var.tst_scene_render.TestSceneRender.h |
◆ initialRect
var.tst_scene_render.TestSceneRender.initialRect |
◆ sceneBg
var.tst_scene_render.TestSceneRender.sceneBg |
◆ speed
var.tst_scene_render.TestSceneRender.speed |
◆ time
var.tst_scene_render.TestSceneRender.time |
◆ timeStep
var.tst_scene_render.TestSceneRender.timeStep |
var.tst_scene_render.TestSceneRender.w |
◆ xAmpl
var.tst_scene_render.TestSceneRender.xAmpl |
◆ yAmpl
var.tst_scene_render.TestSceneRender.yAmpl |
The documentation for this class was generated from the following file: